diff --git a/birdnet.conf-defaults b/birdnet.conf-defaults index e75cda1..e53af20 100644 --- a/birdnet.conf-defaults +++ b/birdnet.conf-defaults @@ -60,7 +60,8 @@ RTSP_STREAM= APPRISE_NOTIFICATION_TITLE="New BirdNET-Pi Detection" APPRISE_NOTIFICATION_BODY="A \$sciname \$comname was just detected with a confidence of \$confidence" -APPRISE_NOTIFY_EACH_DETECTION=false +APPRISE_NOTIFY_EACH_DETECTION=0 +APPRISE_NOTIFY_NEW_SPECIES=0 #---------------------- Flickr Images API Configuration -----------------------# diff --git a/homepage/views.php b/homepage/views.php index 4dbd247..33f4621 100644 --- a/homepage/views.php +++ b/homepage/views.php @@ -250,10 +250,6 @@ if(isset($_GET['view'])){ 'sudo systemctl restart spectrogram_viewer.service', 'sudo systemctl disable --now spectrogram_viewer.service', 'sudo systemctl enable --now spectrogram_viewer.service', - 'sudo systemctl stop pushed_notifications.service', - 'sudo systemctl restart pushed_notifications.service', - 'sudo systemctl disable --now pushed_notifications.service', - 'sudo systemctl enable --now pushed_notifications.service', 'stop_core_services.sh', 'restart_services.sh', 'sudo reboot', diff --git a/scripts/config.php b/scripts/config.php index 78f0055..8b13084 100644 --- a/scripts/config.php +++ b/scripts/config.php @@ -16,10 +16,10 @@ if(isset($_GET['apprise_notify_each_detection'])) { } else { $apprise_notify_each_detection = 0; } -if(isset($_GET['apprise_notify_each_species'])) { - exec('sudo systemctl start pushed_notifications.service'); +if(isset($_GET['apprise_notify_new_species'])) { + $apprise_notify_new_species = 1; } else { - exec('sudo systemctl stop pushed_notifications.service'); + $apprise_notify_new_species = 0; } // logic for setting the date and time based on user inputs from the form below @@ -46,6 +46,7 @@ $contents = preg_replace("/BIRDWEATHER_ID=.*/", "BIRDWEATHER_ID=$birdweather_id" $contents = preg_replace("/APPRISE_NOTIFICATION_TITLE=.*/", "APPRISE_NOTIFICATION_TITLE=\"$apprise_notification_title\"", $contents); $contents = preg_replace("/APPRISE_NOTIFICATION_BODY=.*/", "APPRISE_NOTIFICATION_BODY=\"$apprise_notification_body\"", $contents); $contents = preg_replace("/APPRISE_NOTIFY_EACH_DETECTION=.*/", "APPRISE_NOTIFY_EACH_DETECTION=$apprise_notify_each_detection", $contents); +$contents = preg_replace("/APPRISE_NOTIFY_NEW_SPECIES=.*/", "APPRISE_NOTIFY_NEW_SPECIES=$apprise_notify_new_species", $contents); $contents = preg_replace("/FLICKR_API_KEY=.*/", "FLICKR_API_KEY=$flickr_api_key", $contents); @@ -56,6 +57,7 @@ $contents2 = preg_replace("/BIRDWEATHER_ID=.*/", "BIRDWEATHER_ID=$birdweather_id $contents2 = preg_replace("/APPRISE_NOTIFICATION_TITLE=.*/", "APPRISE_NOTIFICATION_TITLE=\"$apprise_notification_title\"", $contents2); $contents2 = preg_replace("/APPRISE_NOTIFICATION_BODY=.*/", "APPRISE_NOTIFICATION_BODY=\"$apprise_notification_body\"", $contents2); $contents2 = preg_replace("/APPRISE_NOTIFY_EACH_DETECTION=.*/", "APPRISE_NOTIFY_EACH_DETECTION=$apprise_notify_each_detection", $contents2); +$contents2 = preg_replace("/APPRISE_NOTIFY_NEW_SPECIES=.*/", "APPRISE_NOTIFY_NEW_SPECIES=$apprise_notify_new_species", $contents2); $contents2 = preg_replace("/FLICKR_API_KEY=.*/", "FLICKR_API_KEY=$flickr_api_key", $contents2); @@ -144,8 +146,8 @@ https://discordapp.com/api/webhooks/{WebhookID}/{WebhookToken}

- > -
+ > +
>

Bird Photos from Flickr

diff --git a/scripts/install_config.sh b/scripts/install_config.sh index e74ac56..daab688 100755 --- a/scripts/install_config.sh +++ b/scripts/install_config.sh @@ -74,6 +74,7 @@ RTSP_STREAM= APPRISE_NOTIFICATION_TITLE="New BirdNET-Pi Detection" APPRISE_NOTIFICATION_BODY="A \$sciname \$comname was just detected with a confidence of \$confidence" APPRISE_NOTIFY_EACH_DETECTION=0 +APPRISE_NOTIFY_NEW_SPECIES=0 #---------------------- Flickr Images API Configuration -----------------------# diff --git a/scripts/install_services.sh b/scripts/install_services.sh index 093047b..1d038b9 100755 --- a/scripts/install_services.sh +++ b/scripts/install_services.sh @@ -91,22 +91,6 @@ EOF systemctl enable extraction.service } -install_pushed_notifications() { - cat << EOF > $HOME/BirdNET-Pi/templates/pushed_notifications.service -[Unit] -Description=BirdNET-Pi Pushed.co Notifications -[Service] -Restart=on-success -RestartSec=3 -Type=simple -User=$USER -ExecStart=/usr/local/bin/species_notifier.sh -[Install] -WantedBy=multi-user.target -EOF - ln -sf $HOME/BirdNET-Pi/templates/pushed_notifications.service /usr/lib/systemd/system -} - create_necessary_dirs() { echo "Creating necessary directories" [ -d ${EXTRACTED} ] || sudo -u ${USER} mkdir -p ${EXTRACTED} @@ -436,7 +420,6 @@ install_services() { install_recording_service install_custom_recording_service # But does not enable install_extraction_service - install_pushed_notifications install_spectrogram_service install_chart_viewer_service install_gotty_logs diff --git a/scripts/restart_services.sh b/scripts/restart_services.sh index 98993af..ad4e9f3 100755 --- a/scripts/restart_services.sh +++ b/scripts/restart_services.sh @@ -9,7 +9,6 @@ sudo pkill server.py sudo systemctl stop birdnet_recording.service services=(web_terminal.service spectrogram_viewer.service -pushed_notifications.service livestream.service icecast2.service extraction.service @@ -22,6 +21,6 @@ sudo systemctl restart "${i}" done until grep 5050 <(netstat -tulpn 2>&1);do sudo systemctl restart birdnet_server.service -sleep 30 +sleep 45 done sudo systemctl restart birdnet_analysis.service diff --git a/scripts/server.py b/scripts/server.py index 35833e1..627b1a0 100755 --- a/scripts/server.py +++ b/scripts/server.py @@ -243,6 +243,32 @@ def sendAppriseNotifications(species,confidence): title=title, ) + if str(str(str([i for i in this_run if i.startswith('APPRISE_NOTIFY_NEW_SPECIES')]).split('=')[1]).split('\\')[0]) == "1": + try: + con = sqlite3.connect(userDir + '/BirdNET-Pi/scripts/birds.db') + cur = con.cursor() + cur.execute("SELECT DISTINCT(Com_Name) FROM detections") + known_species = cur.fetchall() + sciName,comName = species.split("_") + + print("\ncomName: ",comName) + print("\nknown_species: ",known_species) + if comName not in known_species: + apobj = apprise.Apprise() + config = apprise.AppriseConfig() + config.add(userDir + '/BirdNET-Pi/apprise.txt') + apobj.add(config) + + apobj.notify( + body=body.replace("$sciname",species.split("_")[0]).replace("$comname",species.split("_")[1]).replace("$confidence",confidence), + title=title, + ) + + con.close() + except: + print("Database busy") + time.sleep(2) + def writeResultsToFile(detections, min_conf, path): print('WRITING RESULTS TO', path, '...', end=' ') diff --git a/scripts/service_controls.php b/scripts/service_controls.php index 8abde5e..e81952b 100644 --- a/scripts/service_controls.php +++ b/scripts/service_controls.php @@ -73,13 +73,6 @@ -
-

Pushed Notifications

- - - - -