Skip to content

A live bird collage card for your Home Assistant dashboard.

Merge branch 'main' into notifications

Patrick McGuire062f720add44
diff --cc scripts/server.py
index 34bf9385,b5238847..98ab4102
--- a/scripts/server.py
+++ b/scripts/server.py
@@@ -201,27 -220,10 +221,27 @@@ def analyzeAudioData(chunks, lat, lon,
pred_start = pred_end - overlap
print('DONE! Time', int((time.time() - start) * 10) / 10.0, 'SECONDS')
-
+ # print('DETECTIONS:::::',detections)
return detections
+def sendAppriseNotifications(species,confidence):
+ if os.path.getsize(userDir + '/BirdNET-Pi/apprise.txt') > 0:
+ with open(userDir + '/BirdNET-Pi/scripts/thisrun.txt', 'r') as f:
+ this_run = f.readlines()
+ title = str(str(str([i for i in this_run if i.startswith('APPRISE_NOTIFICATION_TITLE')]).split('=')[1]).split('\\')[0]).replace('"', '')
+ body = str(str(str([i for i in this_run if i.startswith('APPRISE_NOTIFICATION_BODY')]).split('=')[1]).split('\\')[0]).replace('"', '')
+ if str(str(str([i for i in this_run if i.startswith('APPRISE_NOTIFY_EACH_DETECTION')]).split('=')[1]).split('\\')[0]) == "1":
+
+ 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,
+ )
def writeResultsToFile(detections, min_conf, path):
diff --cc scripts/update_birdnet_snippets.sh
index e6ff1eb3,9edc03e0..c0e972b8
--- a/scripts/update_birdnet_snippets.sh
+++ b/scripts/update_birdnet_snippets.sh
@@@ -9,18 -9,16 +9,25 @@@ if ! grep python3 <(head -n1 $my_dir/an
echo "Ensure all python scripts use the virtual environment"
sudo -u$USER sed -si "1 i\\#\!$HOME/BirdNET-Pi/birdnet/bin/python3" $my_dir/*.py
fi
- if ! grep PRIVACY_MODE /etc/birdnet/birdnet.conf &>/dev/null;then
- sudo -u$USER echo "PRIVACY_MODE=off" >> /etc/birdnet/birdnet.conf
+ if ! grep PRIVACY_THRESHOLD /etc/birdnet/birdnet.conf &>/dev/null;then
+ sudo -u$USER echo "PRIVACY_THRESHOLD=0" >> /etc/birdnet/birdnet.conf
+ git -C $HOME/BirdNET-Pi rm $my_dir/privacy_server.py
+ fi
+ if grep privacy ~/BirdNET-Pi/templates/birdnet_server.service &>/dev/null;then
+ sudo -E sed -i 's/privacy_server.py/server.py/g' \
+ ~/BirdNET-Pi/templates/birdnet_server.service
+ sudo systemctl daemon-reload
+ restart_services.sh
fi
+if ! grep APPRISE_NOTIFICATION_TITLE /etc/birdnet/birdnet.conf &>/dev/null;then
+ sudo -u$USER echo "APPRISE_NOTIFICATION_TITLE=\"New BirdNET-Pi Detection\"" >> /etc/birdnet/birdnet.conf
+fi
+if ! grep APPRISE_NOTIFICATION_BODY /etc/birdnet/birdnet.conf &>/dev/null;then
+ sudo -u$USER echo "APPRISE_NOTIFICATION_BODY=\"A \$sciname \$comname was just detected with a confidence of \$confidence\"" >> /etc/birdnet/birdnet.conf
+fi
+if ! grep APPRISE_NOTIFY_EACH_DETECTION /etc/birdnet/birdnet.conf &>/dev/null;then
+ sudo -u$USER echo "APPRISE_NOTIFY_EACH_DETECTION=false" >> /etc/birdnet/birdnet.conf
+fi
if ! which lsof &>/dev/null;then
sudo apt update && sudo apt -y install lsof
fi