From a9893c519ba6aa362699443f028a0004b4ac99d9 Mon Sep 17 00:00:00 2001
From: ehpersonal38 <103586016+ehpersonal38@users.noreply.github.com>
Date: Thu, 28 Apr 2022 08:44:51 -0400
Subject: [PATCH 01/25] Adding notify.run browser notifications
---
birdnet.conf-defaults | 11 +++++++++++
scripts/config.php | 8 ++++++++
scripts/install_config.sh | 11 +++++++++++
scripts/species_notifier.sh | 4 ++++
scripts/update_birdnet.sh | 4 ++++
5 files changed, 38 insertions(+)
diff --git a/birdnet.conf-defaults b/birdnet.conf-defaults
index 5863aab..6a7aa7f 100644
--- a/birdnet.conf-defaults
+++ b/birdnet.conf-defaults
@@ -61,6 +61,17 @@ BIRDNETPI_URL=
PUSHED_APP_KEY=
PUSHED_APP_SECRET=
+#------------------- Browser Notifications via Notify.run -------------------#
+#________________The variable below enables browser notifications______________#
+#________________________See https://notify.run/ to get________________________#
+#_________________ __these subscription URL for your device.___________________#
+
+# Keep these EMPTY if haven't setup a Notify.run Channel yet. #
+
+## Notify.run Channel ID
+
+NOTIFY_RUN_CHANNEL_ID=
+
################################################################################
#-------------------------------- Defaults ----------------------------------#
################################################################################
diff --git a/scripts/config.php b/scripts/config.php
index fa6388a..cebf813 100644
--- a/scripts/config.php
+++ b/scripts/config.php
@@ -9,6 +9,7 @@ $longitude = $_GET["longitude"];
$birdweather_id = $_GET["birdweather_id"];
$pushed_app_key = $_GET["pushed_app_key"];
$pushed_app_secret = $_GET["pushed_app_secret"];
+$notify_run_channel = $_GET["notify_run_channel"];
$contents = file_get_contents("/etc/birdnet/birdnet.conf");
$contents = preg_replace("/LATITUDE=.*/", "LATITUDE=$latitude", $contents);
@@ -16,6 +17,7 @@ $contents = preg_replace("/LONGITUDE=.*/", "LONGITUDE=$longitude", $contents);
$contents = preg_replace("/BIRDWEATHER_ID=.*/", "BIRDWEATHER_ID=$birdweather_id", $contents);
$contents = preg_replace("/PUSHED_APP_KEY=.*/", "PUSHED_APP_KEY=$pushed_app_key", $contents);
$contents = preg_replace("/PUSHED_APP_SECRET=.*/", "PUSHED_APP_SECRET=$pushed_app_secret", $contents);
+$contents = preg_replace("/NOTIFY_RUN_CHANNEL_ID=.*/", "NOTIFY_RUN_CHANNEL_ID=$notify_run_channel", $contents);
$contents2 = file_get_contents("./scripts/thisrun.txt");
$contents2 = preg_replace("/LATITUDE=.*/", "LATITUDE=$latitude", $contents2);
@@ -23,6 +25,7 @@ $contents2 = preg_replace("/LONGITUDE=.*/", "LONGITUDE=$longitude", $contents2);
$contents2 = preg_replace("/BIRDWEATHER_ID=.*/", "BIRDWEATHER_ID=$birdweather_id", $contents2);
$contents2 = preg_replace("/PUSHED_APP_KEY=.*/", "PUSHED_APP_KEY=$pushed_app_key", $contents2);
$contents2 = preg_replace("/PUSHED_APP_SECRET=.*/", "PUSHED_APP_SECRET=$pushed_app_secret", $contents2);
+$contents2 = preg_replace("/NOTIFY_RUN_CHANNEL_ID=.*/", "NOTIFY_RUN_CHANNEL_ID=$notify_run_channel", $contents2);
$fh = fopen("/etc/birdnet/birdnet.conf", "w");
$fh2 = fopen("./scripts/thisrun.txt", "w");
@@ -84,6 +87,11 @@ if (!isset($_SERVER['PHP_AUTH_USER'])) {
Pushed App Secret:
Pushed iOS Notifications can be setup and enabled for New Species notifications. Be sure to "Enable" the "Pushed Notifications" in "Tools" > "Services" if you would like to use this feature. Sorry, Android users, this only works on iOS.
+
+ Notify.run Channel ID:
+
+ Notify.run browser notifications can be setup and enabled for New Species notifications.
+
Database Language:
Select your language
diff --git a/scripts/install_config.sh b/scripts/install_config.sh
index cbd29f1..094a3b4 100755
--- a/scripts/install_config.sh
+++ b/scripts/install_config.sh
@@ -74,6 +74,17 @@ BIRDNETPI_URL=
PUSHED_APP_KEY=
PUSHED_APP_SECRET=
+#------------------- Browser Notifications via Notify.run -------------------#
+#________________The variable below enables browser notifications______________#
+#________________________See https://notify.run/ to get________________________#
+#_________________ __these subscription URL for your device.___________________#
+
+# Keep these EMPTY if haven't setup a Notify.run Channel yet. #
+
+## Notify.run Channel ID
+
+NOTIFY_RUN_CHANNEL_ID=
+
################################################################################
#-------------------------------- Defaults ----------------------------------#
################################################################################
diff --git a/scripts/species_notifier.sh b/scripts/species_notifier.sh
index 9596754..a441612 100755
--- a/scripts/species_notifier.sh
+++ b/scripts/species_notifier.sh
@@ -21,6 +21,10 @@ if ! diff ${IDFILE} ${lastcheck} &> /dev/null;then
echo "Sending the following notification:
${NOTIFICATION}"
+ if [ ! -z ${NOTIFY_RUN_CHANNEL_ID} ];then
+ curl https://notify.run/${NOTIFY_RUN_CHANNEL_ID} -d ${NOTIFICATION}
+ fi
+
if [ ! -z ${PUSHED_APP_KEY} ];then
curl -X POST \
--form-string "app_key=${PUSHED_APP_KEY}" \
diff --git a/scripts/update_birdnet.sh b/scripts/update_birdnet.sh
index a48e7d6..f003123 100755
--- a/scripts/update_birdnet.sh
+++ b/scripts/update_birdnet.sh
@@ -18,3 +18,7 @@ fi
if ! grep PRIVACY_MODE /etc/birdnet/birdnet.conf;then
sudo -u${USER} echo "PRIVACY_MODE=off" >> /etc/birdnet/birdnet.conf
fi
+if ! grep NOTIFY_RUN_CHANNEL_ID /etc/birdnet/birdnet.conf;then
+ sudo -u${USER} echo "NOTIFY_RUN_CHANNEL_ID=" >> /etc/birdnet/birdnet.conf
+fi
+
From 9e5331168c03d87edcad18ec1a48940027bed9ae Mon Sep 17 00:00:00 2001
From: ehpersonal38 <103586016+ehpersonal38@users.noreply.github.com>
Date: Sat, 7 May 2022 12:33:14 -0400
Subject: [PATCH 02/25] apprise starting point
---
birdnet.conf-defaults | 10 ----------
requirements.txt | 1 +
scripts/config.php | 17 +++++++++++++----
scripts/species_notifier.sh | 4 ++++
scripts/update_birdnet_snippets.sh | 5 +++++
5 files changed, 23 insertions(+), 14 deletions(-)
diff --git a/birdnet.conf-defaults b/birdnet.conf-defaults
index d1dd7b9..e0e38a2 100644
--- a/birdnet.conf-defaults
+++ b/birdnet.conf-defaults
@@ -68,16 +68,6 @@ RTSP_STREAM=
PUSHED_APP_KEY=
PUSHED_APP_SECRET=
-#------------------- Browser Notifications via Notify.run -------------------#
-#________________The variable below enables browser notifications______________#
-#________________________See https://notify.run/ to get________________________#
-#_________________ __these subscription URL for your device.___________________#
-
-# Keep these EMPTY if haven't setup a Notify.run Channel yet. #
-
-## Notify.run Channel ID
-
-NOTIFY_RUN_CHANNEL_ID=
################################################################################
#-------------------------------- Defaults ----------------------------------#
diff --git a/requirements.txt b/requirements.txt
index 9f651b4..22f27e2 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -10,3 +10,4 @@ pandas
seaborn
streamlit
plotly
+apprise
\ No newline at end of file
diff --git a/scripts/config.php b/scripts/config.php
index cebf813..a71e529 100644
--- a/scripts/config.php
+++ b/scripts/config.php
@@ -9,7 +9,7 @@ $longitude = $_GET["longitude"];
$birdweather_id = $_GET["birdweather_id"];
$pushed_app_key = $_GET["pushed_app_key"];
$pushed_app_secret = $_GET["pushed_app_secret"];
-$notify_run_channel = $_GET["notify_run_channel"];
+$apprise_input = $_GET['apprise_input'];
$contents = file_get_contents("/etc/birdnet/birdnet.conf");
$contents = preg_replace("/LATITUDE=.*/", "LATITUDE=$latitude", $contents);
@@ -32,6 +32,10 @@ $fh2 = fopen("./scripts/thisrun.txt", "w");
fwrite($fh, $contents);
fwrite($fh2, $contents2);
+$appriseconfig = fopen("~/.apprise");
+fwrite($appriseconfig, $apprise_input);
+
+
$language = $_GET["language"];
if ($language != "none"){
$user = shell_exec("awk -F: '/1000/{print $1}' /etc/passwd");
@@ -57,6 +61,11 @@ if (file_exists('./scripts/thisrun.txt')) {
} elseif (file_exists('./scripts/firstrun.ini')) {
$config = parse_ini_file('./scripts/firstrun.ini');
}
+if (file_exists('~/.apprise')) {
+ $apprise_config = file_get_contents('~/.apprise');
+} else {
+ $apprise_config = "";
+}
$caddypwd = $config['CADDY_PWD'];
if (!isset($_SERVER['PHP_AUTH_USER'])) {
header('WWW-Authenticate: Basic realm="My Realm"');
@@ -88,9 +97,9 @@ if (!isset($_SERVER['PHP_AUTH_USER'])) {
Pushed iOS Notifications can be setup and enabled for New Species notifications. Be sure to "Enable" the "Pushed Notifications" in "Tools" > "Services" if you would like to use this feature. Sorry, Android users, this only works on iOS.
- Notify.run Channel ID:
-
- Notify.run browser notifications can be setup and enabled for New Species notifications.
+ Apprise Notifications Configuration:
+
+ Apprise Notifications can be setup and enabled for New Species notifications.
Database Language:
diff --git a/scripts/species_notifier.sh b/scripts/species_notifier.sh
index a441612..95b6720 100755
--- a/scripts/species_notifier.sh
+++ b/scripts/species_notifier.sh
@@ -33,5 +33,9 @@ ${NOTIFICATION}"
--form-string "content=${NOTIFICATION}" \
https://api.pushed.co/1/push
fi
+
+ if [ ! -s ~/.apprise ];then
+ apprise -vv -t 'New Species Detected' -b ${NOTIFICATION}
+ fi
fi
diff --git a/scripts/update_birdnet_snippets.sh b/scripts/update_birdnet_snippets.sh
index 3c45174..88a9bc4 100755
--- a/scripts/update_birdnet_snippets.sh
+++ b/scripts/update_birdnet_snippets.sh
@@ -15,3 +15,8 @@ fi
if ! which lsof &>/dev/null;then
sudo apt update && sudo apt -y install lsof
fi
+apprise_installation_status=$(~/BirdNET-Pi/birdnet/bin/python3 -c 'import pkgutil; print("installed" if pkgutil.find_loader("apprise") else "not installed")')
+if [[ "$apprise_installation_status" = "not installed" ]];then
+ ~/BirdNET-Pi/birdnet/bin/pip3 install -U pip
+ ~/BirdNET-Pi/birdnet/bin/pip3 install apprise
+fi
\ No newline at end of file
From 65ddee22b1943ecbd0d46ea8204e098dca348e64 Mon Sep 17 00:00:00 2001
From: ehpersonal38 <103586016+ehpersonal38@users.noreply.github.com>
Date: Sat, 7 May 2022 12:41:46 -0400
Subject: [PATCH 03/25] Update config.php
---
scripts/config.php | 2 --
1 file changed, 2 deletions(-)
diff --git a/scripts/config.php b/scripts/config.php
index a71e529..b49d9f6 100644
--- a/scripts/config.php
+++ b/scripts/config.php
@@ -17,7 +17,6 @@ $contents = preg_replace("/LONGITUDE=.*/", "LONGITUDE=$longitude", $contents);
$contents = preg_replace("/BIRDWEATHER_ID=.*/", "BIRDWEATHER_ID=$birdweather_id", $contents);
$contents = preg_replace("/PUSHED_APP_KEY=.*/", "PUSHED_APP_KEY=$pushed_app_key", $contents);
$contents = preg_replace("/PUSHED_APP_SECRET=.*/", "PUSHED_APP_SECRET=$pushed_app_secret", $contents);
-$contents = preg_replace("/NOTIFY_RUN_CHANNEL_ID=.*/", "NOTIFY_RUN_CHANNEL_ID=$notify_run_channel", $contents);
$contents2 = file_get_contents("./scripts/thisrun.txt");
$contents2 = preg_replace("/LATITUDE=.*/", "LATITUDE=$latitude", $contents2);
@@ -25,7 +24,6 @@ $contents2 = preg_replace("/LONGITUDE=.*/", "LONGITUDE=$longitude", $contents2);
$contents2 = preg_replace("/BIRDWEATHER_ID=.*/", "BIRDWEATHER_ID=$birdweather_id", $contents2);
$contents2 = preg_replace("/PUSHED_APP_KEY=.*/", "PUSHED_APP_KEY=$pushed_app_key", $contents2);
$contents2 = preg_replace("/PUSHED_APP_SECRET=.*/", "PUSHED_APP_SECRET=$pushed_app_secret", $contents2);
-$contents2 = preg_replace("/NOTIFY_RUN_CHANNEL_ID=.*/", "NOTIFY_RUN_CHANNEL_ID=$notify_run_channel", $contents2);
$fh = fopen("/etc/birdnet/birdnet.conf", "w");
$fh2 = fopen("./scripts/thisrun.txt", "w");
From 7d6f55d2eeed05aa0a01b2cd175e9d726fc690f5 Mon Sep 17 00:00:00 2001
From: ehpersonal38 <103586016+ehpersonal38@users.noreply.github.com>
Date: Sat, 7 May 2022 12:43:10 -0400
Subject: [PATCH 04/25] Update config.php
---
scripts/config.php | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/scripts/config.php b/scripts/config.php
index b49d9f6..45d7fe0 100644
--- a/scripts/config.php
+++ b/scripts/config.php
@@ -30,8 +30,10 @@ $fh2 = fopen("./scripts/thisrun.txt", "w");
fwrite($fh, $contents);
fwrite($fh2, $contents2);
-$appriseconfig = fopen("~/.apprise");
-fwrite($appriseconfig, $apprise_input);
+if(strlen($apprise_input) > 0){
+ $appriseconfig = fopen("~/.apprise", "w");
+ fwrite($appriseconfig, $apprise_input);
+}
$language = $_GET["language"];
From 18bfdccab032f48c492307c3b71e71c98c39d521 Mon Sep 17 00:00:00 2001
From: ehpersonal38 <103586016+ehpersonal38@users.noreply.github.com>
Date: Sat, 7 May 2022 13:00:44 -0400
Subject: [PATCH 05/25] testy
---
scripts/config.php | 2 +-
scripts/species_notifier.sh | 3 +--
2 files changed, 2 insertions(+), 3 deletions(-)
diff --git a/scripts/config.php b/scripts/config.php
index 45d7fe0..5c32469 100644
--- a/scripts/config.php
+++ b/scripts/config.php
@@ -31,7 +31,7 @@ fwrite($fh, $contents);
fwrite($fh2, $contents2);
if(strlen($apprise_input) > 0){
- $appriseconfig = fopen("~/.apprise", "w");
+ $appriseconfig = fopen("".exec("~/").".apprise", "w");
fwrite($appriseconfig, $apprise_input);
}
diff --git a/scripts/species_notifier.sh b/scripts/species_notifier.sh
index 95b6720..21f6640 100755
--- a/scripts/species_notifier.sh
+++ b/scripts/species_notifier.sh
@@ -1,6 +1,5 @@
#!/usr/bin/env bash
# Sends a notification if a new species is detected
-#set -x
trap 'rm -f $lastcheck' EXIT
source /etc/birdnet/birdnet.conf
@@ -35,7 +34,7 @@ ${NOTIFICATION}"
fi
if [ ! -s ~/.apprise ];then
- apprise -vv -t 'New Species Detected' -b ${NOTIFICATION}
+ $HOME/BirdNET-Pi/birdnet/bin/apprise -vv -t 'New Species Detected' -b ${NOTIFICATION}
fi
fi
From 8d774e0efa699ec2e2bffd4ac17bce91a9371102 Mon Sep 17 00:00:00 2001
From: ehpersonal38 <103586016+ehpersonal38@users.noreply.github.com>
Date: Sat, 7 May 2022 13:05:37 -0400
Subject: [PATCH 06/25] ah
---
scripts/config.php | 2 +-
scripts/species_notifier.sh | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/scripts/config.php b/scripts/config.php
index 5c32469..3d6b442 100644
--- a/scripts/config.php
+++ b/scripts/config.php
@@ -31,7 +31,7 @@ fwrite($fh, $contents);
fwrite($fh2, $contents2);
if(strlen($apprise_input) > 0){
- $appriseconfig = fopen("".exec("~/").".apprise", "w");
+ $appriseconfig = fopen("/etc/birdnet/.apprise", "w");
fwrite($appriseconfig, $apprise_input);
}
diff --git a/scripts/species_notifier.sh b/scripts/species_notifier.sh
index 21f6640..bbd3ee2 100755
--- a/scripts/species_notifier.sh
+++ b/scripts/species_notifier.sh
@@ -34,7 +34,7 @@ ${NOTIFICATION}"
fi
if [ ! -s ~/.apprise ];then
- $HOME/BirdNET-Pi/birdnet/bin/apprise -vv -t 'New Species Detected' -b ${NOTIFICATION}
+ $HOME/BirdNET-Pi/birdnet/bin/apprise -vv -t 'New Species Detected' -b ${NOTIFICATION} --config=/etc/birdnet/.apprise
fi
fi
From f1a972b9433f5bed02a1b68b31ff1394160f618e Mon Sep 17 00:00:00 2001
From: ehpersonal38 <103586016+ehpersonal38@users.noreply.github.com>
Date: Sat, 7 May 2022 13:07:49 -0400
Subject: [PATCH 07/25] patricks old code to the rescue!!
---
scripts/config.php | 6 +++++-
scripts/species_notifier.sh | 2 +-
2 files changed, 6 insertions(+), 2 deletions(-)
diff --git a/scripts/config.php b/scripts/config.php
index 3d6b442..147b807 100644
--- a/scripts/config.php
+++ b/scripts/config.php
@@ -31,7 +31,11 @@ fwrite($fh, $contents);
fwrite($fh2, $contents2);
if(strlen($apprise_input) > 0){
- $appriseconfig = fopen("/etc/birdnet/.apprise", "w");
+ $user = shell_exec("awk -F: '/1000/{print $1}' /etc/passwd");
+ $home = shell_exec("awk -F: '/1000/{print $6}' /etc/passwd");
+ $home = trim($home);
+
+ $appriseconfig = fopen($home."/BirdNET-Pi/.apprise", "w");
fwrite($appriseconfig, $apprise_input);
}
diff --git a/scripts/species_notifier.sh b/scripts/species_notifier.sh
index bbd3ee2..8d0364a 100755
--- a/scripts/species_notifier.sh
+++ b/scripts/species_notifier.sh
@@ -34,7 +34,7 @@ ${NOTIFICATION}"
fi
if [ ! -s ~/.apprise ];then
- $HOME/BirdNET-Pi/birdnet/bin/apprise -vv -t 'New Species Detected' -b ${NOTIFICATION} --config=/etc/birdnet/.apprise
+ $HOME/BirdNET-Pi/birdnet/bin/apprise -vv -t 'New Species Detected' -b ${NOTIFICATION} --config=$HOME/BirdNET-Pi/.apprise
fi
fi
From 1757cdc961ece6ab5c69c8bf1c8e498108bb7564 Mon Sep 17 00:00:00 2001
From: ehpersonal38 <103586016+ehpersonal38@users.noreply.github.com>
Date: Sat, 7 May 2022 13:11:00 -0400
Subject: [PATCH 08/25] done for today
---
scripts/config.php | 9 ++++++---
scripts/species_notifier.sh | 2 +-
2 files changed, 7 insertions(+), 4 deletions(-)
diff --git a/scripts/config.php b/scripts/config.php
index 147b807..86d1b2c 100644
--- a/scripts/config.php
+++ b/scripts/config.php
@@ -35,7 +35,7 @@ if(strlen($apprise_input) > 0){
$home = shell_exec("awk -F: '/1000/{print $6}' /etc/passwd");
$home = trim($home);
- $appriseconfig = fopen($home."/BirdNET-Pi/.apprise", "w");
+ $appriseconfig = fopen($home."/BirdNET-Pi/apprise.txt", "w");
fwrite($appriseconfig, $apprise_input);
}
@@ -65,8 +65,11 @@ if (file_exists('./scripts/thisrun.txt')) {
} elseif (file_exists('./scripts/firstrun.ini')) {
$config = parse_ini_file('./scripts/firstrun.ini');
}
-if (file_exists('~/.apprise')) {
- $apprise_config = file_get_contents('~/.apprise');
+$user = shell_exec("awk -F: '/1000/{print $1}' /etc/passwd");
+$home = shell_exec("awk -F: '/1000/{print $6}' /etc/passwd");
+$home = trim($home);
+if (file_exists($home."/BirdNET-Pi/apprise.txt")) {
+ $apprise_config = file_get_contents($home."/BirdNET-Pi/apprise.txt");
} else {
$apprise_config = "";
}
diff --git a/scripts/species_notifier.sh b/scripts/species_notifier.sh
index 8d0364a..8dad30c 100755
--- a/scripts/species_notifier.sh
+++ b/scripts/species_notifier.sh
@@ -34,7 +34,7 @@ ${NOTIFICATION}"
fi
if [ ! -s ~/.apprise ];then
- $HOME/BirdNET-Pi/birdnet/bin/apprise -vv -t 'New Species Detected' -b ${NOTIFICATION} --config=$HOME/BirdNET-Pi/.apprise
+ $HOME/BirdNET-Pi/birdnet/bin/apprise -vv -t 'New Species Detected' -b ${NOTIFICATION} --config=$HOME/BirdNET-Pi/apprise.txt
fi
fi
From 629f8522249b12b75cf6484237219dd720611386 Mon Sep 17 00:00:00 2001
From: ehpersonal38
Date: Sat, 7 May 2022 13:13:58 -0400
Subject: [PATCH 09/25] perms
---
scripts/update_birdnet.sh | 0
1 file changed, 0 insertions(+), 0 deletions(-)
mode change 100644 => 100755 scripts/update_birdnet.sh
diff --git a/scripts/update_birdnet.sh b/scripts/update_birdnet.sh
old mode 100644
new mode 100755
From aeb4cc389dd5930ab5eccff5472ffa91ce4c8552 Mon Sep 17 00:00:00 2001
From: ehpersonal38 <103586016+ehpersonal38@users.noreply.github.com>
Date: Sat, 7 May 2022 13:22:04 -0400
Subject: [PATCH 10/25] Update species_notifier.sh
---
scripts/species_notifier.sh | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/scripts/species_notifier.sh b/scripts/species_notifier.sh
index 8dad30c..99638ae 100755
--- a/scripts/species_notifier.sh
+++ b/scripts/species_notifier.sh
@@ -33,8 +33,8 @@ ${NOTIFICATION}"
https://api.pushed.co/1/push
fi
- if [ ! -s ~/.apprise ];then
- $HOME/BirdNET-Pi/birdnet/bin/apprise -vv -t 'New Species Detected' -b ${NOTIFICATION} --config=$HOME/BirdNET-Pi/apprise.txt
+ if [ ! -s $HOME/BirdNET-Pi/apprise.txt ];then
+ $HOME/BirdNET-Pi/birdnet/bin/apprise -vv -t 'New Species Detected' -b "${NOTIFICATION}" --config=$HOME/BirdNET-Pi/apprise.txt
fi
fi
From 185e17de9eac4d61dd4ce1873842400036a9983e Mon Sep 17 00:00:00 2001
From: ehpersonal38 <103586016+ehpersonal38@users.noreply.github.com>
Date: Sun, 8 May 2022 08:29:30 -0400
Subject: [PATCH 11/25] adding notifications for each detection
---
scripts/config.php | 2 +-
scripts/server.py | 14 ++++++++++++++
2 files changed, 15 insertions(+), 1 deletion(-)
diff --git a/scripts/config.php b/scripts/config.php
index 86d1b2c..f9d0aba 100644
--- a/scripts/config.php
+++ b/scripts/config.php
@@ -105,7 +105,7 @@ if (!isset($_SERVER['PHP_AUTH_USER'])) {
Pushed iOS Notifications can be setup and enabled for New Species notifications. Be sure to "Enable" the "Pushed Notifications" in "Tools" > "Services" if you would like to use this feature. Sorry, Android users, this only works on iOS.
Apprise Notifications Configuration:
-
+
Apprise Notifications can be setup and enabled for New Species notifications.
Database Language:
diff --git a/scripts/server.py b/scripts/server.py
index d025f32..b81f13e 100755
--- a/scripts/server.py
+++ b/scripts/server.py
@@ -24,6 +24,7 @@ from time import sleep
import pytz
from tzlocal import get_localzone
from pathlib import Path
+import apprise
HEADER = 64
@@ -203,6 +204,17 @@ def analyzeAudioData(chunks, lat, lon, week, sensitivity, overlap,):
return detections
+def sendAppriseNotifications(species,confidence):
+ apobj = apprise.Apprise()
+ config = apprise.AppriseConfig()
+ config.add(userDir + '/BirdNET-Pi/apprise.txt')
+ apobj.add(config)
+
+ apobj.notify(
+ body='A '+species+' was just detected with a confidence of '+confidence,
+ title='New BirdNET-Pi Detection',
+ )
+
def writeResultsToFile(detections, min_conf, path):
print('WRITING RESULTS TO', path, '...', end=' ')
@@ -212,6 +224,8 @@ def writeResultsToFile(detections, min_conf, path):
for d in detections:
for entry in detections[d]:
if entry[1] >= min_conf and ((entry[0] in INCLUDE_LIST or len(INCLUDE_LIST) == 0) and (entry[0] not in EXCLUDE_LIST or len(EXCLUDE_LIST) == 0) ):
+ if os.path.getsize(userDir + '/BirdNET-Pi/apprise.txt') > 0:
+ sendAppriseNotifications(str(entry[0]),str(entry[1]));
rfile.write(d + ';' + entry[0].replace('_', ';') + ';' + str(entry[1]) + '\n')
rcnt += 1
print('DONE! WROTE', rcnt, 'RESULTS.')
From 98de55bf4e1626c75cc1703fe651025f9da358a0 Mon Sep 17 00:00:00 2001
From: ehpersonal38 <103586016+ehpersonal38@users.noreply.github.com>
Date: Sun, 8 May 2022 08:55:39 -0400
Subject: [PATCH 12/25] adding more customization
---
birdnet.conf-defaults | 5 +++++
scripts/config.php | 17 ++++++++++++++++-
scripts/install_config.sh | 13 ++++---------
scripts/server.py | 26 ++++++++++++++++----------
scripts/species_notifier.sh | 4 ----
scripts/update_birdnet_snippets.sh | 9 +++++++++
6 files changed, 50 insertions(+), 24 deletions(-)
diff --git a/birdnet.conf-defaults b/birdnet.conf-defaults
index e0e38a2..61b33f5 100644
--- a/birdnet.conf-defaults
+++ b/birdnet.conf-defaults
@@ -68,6 +68,11 @@ RTSP_STREAM=
PUSHED_APP_KEY=
PUSHED_APP_SECRET=
+#----------------------- Apprise Miscellanous Configuration -------------------#
+
+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
################################################################################
#-------------------------------- Defaults ----------------------------------#
diff --git a/scripts/config.php b/scripts/config.php
index f9d0aba..fa8c204 100644
--- a/scripts/config.php
+++ b/scripts/config.php
@@ -10,6 +10,9 @@ $birdweather_id = $_GET["birdweather_id"];
$pushed_app_key = $_GET["pushed_app_key"];
$pushed_app_secret = $_GET["pushed_app_secret"];
$apprise_input = $_GET['apprise_input'];
+$apprise_notification_title = $_GET['apprise_notification_title'];
+$apprise_notification_body = $_GET['apprise_notification_body'];
+$apprise_notify_each_detection = $_GET['apprise_notify_each_detection'];
$contents = file_get_contents("/etc/birdnet/birdnet.conf");
$contents = preg_replace("/LATITUDE=.*/", "LATITUDE=$latitude", $contents);
@@ -17,6 +20,10 @@ $contents = preg_replace("/LONGITUDE=.*/", "LONGITUDE=$longitude", $contents);
$contents = preg_replace("/BIRDWEATHER_ID=.*/", "BIRDWEATHER_ID=$birdweather_id", $contents);
$contents = preg_replace("/PUSHED_APP_KEY=.*/", "PUSHED_APP_KEY=$pushed_app_key", $contents);
$contents = preg_replace("/PUSHED_APP_SECRET=.*/", "PUSHED_APP_SECRET=$pushed_app_secret", $contents);
+$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);
+
$contents2 = file_get_contents("./scripts/thisrun.txt");
$contents2 = preg_replace("/LATITUDE=.*/", "LATITUDE=$latitude", $contents2);
@@ -105,7 +112,15 @@ if (!isset($_SERVER['PHP_AUTH_USER'])) {
Pushed iOS Notifications can be setup and enabled for New Species notifications. Be sure to "Enable" the "Pushed Notifications" in "Tools" > "Services" if you would like to use this feature. Sorry, Android users, this only works on iOS.
Apprise Notifications Configuration:
-
+
+ Notification Title:
+
+ Notification Body (use variables $sciname, $comname, or $confidence):
+
+
+ Notify each new species
+
+ Notify each new detection
Apprise Notifications can be setup and enabled for New Species notifications.
Database Language:
diff --git a/scripts/install_config.sh b/scripts/install_config.sh
index 0ad72eb..94f7ca3 100755
--- a/scripts/install_config.sh
+++ b/scripts/install_config.sh
@@ -81,16 +81,11 @@ RTSP_STREAM=
PUSHED_APP_KEY=
PUSHED_APP_SECRET=
-#------------------- Browser Notifications via Notify.run -------------------#
-#________________The variable below enables browser notifications______________#
-#________________________See https://notify.run/ to get________________________#
-#_________________ __these subscription URL for your device.___________________#
+#----------------------- Apprise Miscellanous Configuration -------------------#
-# Keep these EMPTY if haven't setup a Notify.run Channel yet. #
-
-## Notify.run Channel ID
-
-NOTIFY_RUN_CHANNEL_ID=
+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
################################################################################
#-------------------------------- Defaults ----------------------------------#
diff --git a/scripts/server.py b/scripts/server.py
index b81f13e..c367a1b 100755
--- a/scripts/server.py
+++ b/scripts/server.py
@@ -205,15 +205,21 @@ def analyzeAudioData(chunks, lat, lon, week, sensitivity, overlap,):
return detections
def sendAppriseNotifications(species,confidence):
- apobj = apprise.Apprise()
- config = apprise.AppriseConfig()
- config.add(userDir + '/BirdNET-Pi/apprise.txt')
- apobj.add(config)
-
- apobj.notify(
- body='A '+species+' was just detected with a confidence of '+confidence,
- title='New BirdNET-Pi Detection',
- )
+ 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])
+ body = "." + str(str(str([i for i in this_run if i.startswith('APPRISE_NOTIFICATION_BODY')]).split('=')[1]).split('\\')[0])
+
+ 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):
@@ -224,7 +230,7 @@ def writeResultsToFile(detections, min_conf, path):
for d in detections:
for entry in detections[d]:
if entry[1] >= min_conf and ((entry[0] in INCLUDE_LIST or len(INCLUDE_LIST) == 0) and (entry[0] not in EXCLUDE_LIST or len(EXCLUDE_LIST) == 0) ):
- if os.path.getsize(userDir + '/BirdNET-Pi/apprise.txt') > 0:
+ if str(str(str([i for i in this_run if i.startswith('APPRISE_NOTIFY_EACH_DETECTION')]).split('=')[1]).split('\\')[0]) == "true":
sendAppriseNotifications(str(entry[0]),str(entry[1]));
rfile.write(d + ';' + entry[0].replace('_', ';') + ';' + str(entry[1]) + '\n')
rcnt += 1
diff --git a/scripts/species_notifier.sh b/scripts/species_notifier.sh
index 99638ae..bad7a98 100755
--- a/scripts/species_notifier.sh
+++ b/scripts/species_notifier.sh
@@ -20,10 +20,6 @@ if ! diff ${IDFILE} ${lastcheck} &> /dev/null;then
echo "Sending the following notification:
${NOTIFICATION}"
- if [ ! -z ${NOTIFY_RUN_CHANNEL_ID} ];then
- curl https://notify.run/${NOTIFY_RUN_CHANNEL_ID} -d ${NOTIFICATION}
- fi
-
if [ ! -z ${PUSHED_APP_KEY} ];then
curl -X POST \
--form-string "app_key=${PUSHED_APP_KEY}" \
diff --git a/scripts/update_birdnet_snippets.sh b/scripts/update_birdnet_snippets.sh
index 88a9bc4..107feb5 100755
--- a/scripts/update_birdnet_snippets.sh
+++ b/scripts/update_birdnet_snippets.sh
@@ -12,6 +12,15 @@ fi
if ! grep PRIVACY_MODE /etc/birdnet/birdnet.conf &>/dev/null;then
sudo -u$USER echo "PRIVACY_MODE=off" >> /etc/birdnet/birdnet.conf
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
From f1595950bb7aad29af38258ee934a60bc3931369 Mon Sep 17 00:00:00 2001
From: ehpersonal38 <103586016+ehpersonal38@users.noreply.github.com>
Date: Sun, 8 May 2022 09:01:04 -0400
Subject: [PATCH 13/25] quotes
---
birdnet.conf-defaults | 4 ++--
scripts/install_config.sh | 4 ++--
scripts/update_birdnet_snippets.sh | 4 ++--
3 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/birdnet.conf-defaults b/birdnet.conf-defaults
index 61b33f5..21773cc 100644
--- a/birdnet.conf-defaults
+++ b/birdnet.conf-defaults
@@ -70,8 +70,8 @@ PUSHED_APP_SECRET=
#----------------------- Apprise Miscellanous Configuration -------------------#
-APPRISE_NOTIFICATION_TITLE=New BirdNET-Pi Detection
-APPRISE_NOTIFICATION_BODY=A $sciname $comname was just detected with a confidence of $confidence
+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
################################################################################
diff --git a/scripts/install_config.sh b/scripts/install_config.sh
index 94f7ca3..69ea796 100755
--- a/scripts/install_config.sh
+++ b/scripts/install_config.sh
@@ -83,8 +83,8 @@ PUSHED_APP_SECRET=
#----------------------- Apprise Miscellanous Configuration -------------------#
-APPRISE_NOTIFICATION_TITLE=New BirdNET-Pi Detection
-APPRISE_NOTIFICATION_BODY=A $sciname $comname was just detected with a confidence of $confidence
+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
################################################################################
diff --git a/scripts/update_birdnet_snippets.sh b/scripts/update_birdnet_snippets.sh
index 107feb5..43a71cd 100755
--- a/scripts/update_birdnet_snippets.sh
+++ b/scripts/update_birdnet_snippets.sh
@@ -13,10 +13,10 @@ if ! grep PRIVACY_MODE /etc/birdnet/birdnet.conf &>/dev/null;then
sudo -u$USER echo "PRIVACY_MODE=off" >> /etc/birdnet/birdnet.conf
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
+ 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
+ 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
From 0de100663c6787277f7ecc0c402d9c325fa344aa Mon Sep 17 00:00:00 2001
From: ehpersonal38 <103586016+ehpersonal38@users.noreply.github.com>
Date: Sun, 8 May 2022 09:20:32 -0400
Subject: [PATCH 14/25] fixed
---
scripts/config.php | 13 +++++++++++--
scripts/update_birdnet_snippets.sh | 2 +-
2 files changed, 12 insertions(+), 3 deletions(-)
diff --git a/scripts/config.php b/scripts/config.php
index fa8c204..589d3f8 100644
--- a/scripts/config.php
+++ b/scripts/config.php
@@ -12,7 +12,13 @@ $pushed_app_secret = $_GET["pushed_app_secret"];
$apprise_input = $_GET['apprise_input'];
$apprise_notification_title = $_GET['apprise_notification_title'];
$apprise_notification_body = $_GET['apprise_notification_body'];
-$apprise_notify_each_detection = $_GET['apprise_notify_each_detection'];
+if(isset($_GET['apprise_notify_each_detection'])) {
+ $apprise_notify_each_detection = 1;
+} else {
+ $apprise_notify_each_detection = 0;
+}
+
+
$contents = file_get_contents("/etc/birdnet/birdnet.conf");
$contents = preg_replace("/LATITUDE=.*/", "LATITUDE=$latitude", $contents);
@@ -31,6 +37,9 @@ $contents2 = preg_replace("/LONGITUDE=.*/", "LONGITUDE=$longitude", $contents2);
$contents2 = preg_replace("/BIRDWEATHER_ID=.*/", "BIRDWEATHER_ID=$birdweather_id", $contents2);
$contents2 = preg_replace("/PUSHED_APP_KEY=.*/", "PUSHED_APP_KEY=$pushed_app_key", $contents2);
$contents2 = preg_replace("/PUSHED_APP_SECRET=.*/", "PUSHED_APP_SECRET=$pushed_app_secret", $contents2);
+$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);
$fh = fopen("/etc/birdnet/birdnet.conf", "w");
$fh2 = fopen("./scripts/thisrun.txt", "w");
@@ -119,7 +128,7 @@ if (!isset($_SERVER['PHP_AUTH_USER'])) {
Notify each new species
-
+ >
Notify each new detection
Apprise Notifications can be setup and enabled for New Species notifications.
diff --git a/scripts/update_birdnet_snippets.sh b/scripts/update_birdnet_snippets.sh
index 43a71cd..e6ff1eb 100755
--- a/scripts/update_birdnet_snippets.sh
+++ b/scripts/update_birdnet_snippets.sh
@@ -13,7 +13,7 @@ if ! grep PRIVACY_MODE /etc/birdnet/birdnet.conf &>/dev/null;then
sudo -u$USER echo "PRIVACY_MODE=off" >> /etc/birdnet/birdnet.conf
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
+ 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
From 4e1cea01872512e9b4b27a108b041326b4c42264 Mon Sep 17 00:00:00 2001
From: ehpersonal38 <103586016+ehpersonal38@users.noreply.github.com>
Date: Sun, 8 May 2022 09:32:24 -0400
Subject: [PATCH 15/25] last touches
---
scripts/config.php | 8 ++++----
scripts/server.py | 6 +++---
2 files changed, 7 insertions(+), 7 deletions(-)
diff --git a/scripts/config.php b/scripts/config.php
index 589d3f8..1f1e31b 100644
--- a/scripts/config.php
+++ b/scripts/config.php
@@ -26,8 +26,8 @@ $contents = preg_replace("/LONGITUDE=.*/", "LONGITUDE=$longitude", $contents);
$contents = preg_replace("/BIRDWEATHER_ID=.*/", "BIRDWEATHER_ID=$birdweather_id", $contents);
$contents = preg_replace("/PUSHED_APP_KEY=.*/", "PUSHED_APP_KEY=$pushed_app_key", $contents);
$contents = preg_replace("/PUSHED_APP_SECRET=.*/", "PUSHED_APP_SECRET=$pushed_app_secret", $contents);
-$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_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);
@@ -37,8 +37,8 @@ $contents2 = preg_replace("/LONGITUDE=.*/", "LONGITUDE=$longitude", $contents2);
$contents2 = preg_replace("/BIRDWEATHER_ID=.*/", "BIRDWEATHER_ID=$birdweather_id", $contents2);
$contents2 = preg_replace("/PUSHED_APP_KEY=.*/", "PUSHED_APP_KEY=$pushed_app_key", $contents2);
$contents2 = preg_replace("/PUSHED_APP_SECRET=.*/", "PUSHED_APP_SECRET=$pushed_app_secret", $contents2);
-$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_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);
$fh = fopen("/etc/birdnet/birdnet.conf", "w");
diff --git a/scripts/server.py b/scripts/server.py
index c367a1b..4bb6e40 100755
--- a/scripts/server.py
+++ b/scripts/server.py
@@ -208,8 +208,8 @@ 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])
- body = "." + str(str(str([i for i in this_run if i.startswith('APPRISE_NOTIFICATION_BODY')]).split('=')[1]).split('\\')[0])
+ 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('"', '')
apobj = apprise.Apprise()
config = apprise.AppriseConfig()
@@ -230,7 +230,7 @@ def writeResultsToFile(detections, min_conf, path):
for d in detections:
for entry in detections[d]:
if entry[1] >= min_conf and ((entry[0] in INCLUDE_LIST or len(INCLUDE_LIST) == 0) and (entry[0] not in EXCLUDE_LIST or len(EXCLUDE_LIST) == 0) ):
- if str(str(str([i for i in this_run if i.startswith('APPRISE_NOTIFY_EACH_DETECTION')]).split('=')[1]).split('\\')[0]) == "true":
+ if str(str(str([i for i in this_run if i.startswith('APPRISE_NOTIFY_EACH_DETECTION')]).split('=')[1]).split('\\')[0]) == "1":
sendAppriseNotifications(str(entry[0]),str(entry[1]));
rfile.write(d + ';' + entry[0].replace('_', ';') + ';' + str(entry[1]) + '\n')
rcnt += 1
From 799e8ce7f9ac14eb1482d2b6b779faae3eeb9b29 Mon Sep 17 00:00:00 2001
From: ehpersonal38 <103586016+ehpersonal38@users.noreply.github.com>
Date: Sun, 8 May 2022 09:47:07 -0400
Subject: [PATCH 16/25] Update server.py
---
scripts/server.py | 21 +++++++++++----------
1 file changed, 11 insertions(+), 10 deletions(-)
diff --git a/scripts/server.py b/scripts/server.py
index 4bb6e40..34bf938 100755
--- a/scripts/server.py
+++ b/scripts/server.py
@@ -211,15 +211,17 @@ def sendAppriseNotifications(species,confidence):
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('"', '')
- apobj = apprise.Apprise()
- config = apprise.AppriseConfig()
- config.add(userDir + '/BirdNET-Pi/apprise.txt')
- apobj.add(config)
+ 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,
- )
+ 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):
@@ -230,8 +232,7 @@ def writeResultsToFile(detections, min_conf, path):
for d in detections:
for entry in detections[d]:
if entry[1] >= min_conf and ((entry[0] in INCLUDE_LIST or len(INCLUDE_LIST) == 0) and (entry[0] not in EXCLUDE_LIST or len(EXCLUDE_LIST) == 0) ):
- if str(str(str([i for i in this_run if i.startswith('APPRISE_NOTIFY_EACH_DETECTION')]).split('=')[1]).split('\\')[0]) == "1":
- sendAppriseNotifications(str(entry[0]),str(entry[1]));
+ sendAppriseNotifications(str(entry[0]),str(entry[1]));
rfile.write(d + ';' + entry[0].replace('_', ';') + ';' + str(entry[1]) + '\n')
rcnt += 1
print('DONE! WROTE', rcnt, 'RESULTS.')
From 919abf16517b2a2ce9f443edb872d03ead622113 Mon Sep 17 00:00:00 2001
From: ehpersonal38 <103586016+ehpersonal38@users.noreply.github.com>
Date: Sun, 8 May 2022 10:37:47 -0400
Subject: [PATCH 17/25] clarity
---
scripts/config.php | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/scripts/config.php b/scripts/config.php
index 1f1e31b..37d2994 100644
--- a/scripts/config.php
+++ b/scripts/config.php
@@ -121,7 +121,11 @@ if (!isset($_SERVER['PHP_AUTH_USER'])) {
Pushed iOS Notifications can be setup and enabled for New Species notifications. Be sure to "Enable" the "Pushed Notifications" in "Tools" > "Services" if you would like to use this feature. Sorry, Android users, this only works on iOS.
Apprise Notifications Configuration:
-
+
Notification Title:
Notification Body (use variables $sciname, $comname, or $confidence):
@@ -130,7 +134,7 @@ if (!isset($_SERVER['PHP_AUTH_USER'])) {
Notify each new species
>
Notify each new detection
- Apprise Notifications can be setup and enabled for New Species notifications.
+ Apprise Notifications can be setup and enabled for notifications. Each service should be on its own line.
Database Language:
From 5e93ce7bf346268c40cf360a49bc659eff88fe14 Mon Sep 17 00:00:00 2001
From: ehpersonal38 <103586016+ehpersonal38@users.noreply.github.com>
Date: Mon, 9 May 2022 09:54:39 -0400
Subject: [PATCH 18/25] Update config.php
---
scripts/config.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/scripts/config.php b/scripts/config.php
index 37d2994..98ffcb4 100644
--- a/scripts/config.php
+++ b/scripts/config.php
@@ -134,7 +134,7 @@ https://discordapp.com/api/webhooks/{WebhookID}/{WebhookToken}
Notify each new species
>
Notify each new detection
- Apprise Notifications can be setup and enabled for notifications. Each service should be on its own line.
+ Apprise Notifications can be setup and enabled for 70+ notification services. Each service should be on its own line.
Database Language:
From 9e6be6cfaa5e2bda41a584cbcc5d5535d85fb1f2 Mon Sep 17 00:00:00 2001
From: mcguirepr89
Date: Mon, 9 May 2022 16:13:43 -0400
Subject: [PATCH 19/25] this fixes the "TinyFileManager" "bug" (not a bug!!!)
---
scripts/update_species.sh | 2 ++
1 file changed, 2 insertions(+)
diff --git a/scripts/update_species.sh b/scripts/update_species.sh
index 3989e73..954dd17 100755
--- a/scripts/update_species.sh
+++ b/scripts/update_species.sh
@@ -2,4 +2,6 @@
# Update the species list
#set -x
source /etc/birdnet/birdnet.conf
+if [ -f $HOME/BirdNET-Pi/scripts/birds.db ];then
sqlite3 $HOME/BirdNET-Pi/scripts/birds.db "SELECT DISTINCT(Com_Name) FROM detections" | sort > ${IDFILE}
+fi
From cfea4115bbdd11d89a9d131e9838287c5ccf55f2 Mon Sep 17 00:00:00 2001
From: mcguirepr89
Date: Mon, 9 May 2022 16:18:28 -0400
Subject: [PATCH 20/25] removed Pushed.co and made it "Notifications"
---
scripts/config.php | 19 +++++--------------
1 file changed, 5 insertions(+), 14 deletions(-)
diff --git a/scripts/config.php b/scripts/config.php
index 98ffcb4..8a66d5e 100644
--- a/scripts/config.php
+++ b/scripts/config.php
@@ -24,8 +24,6 @@ $contents = file_get_contents("/etc/birdnet/birdnet.conf");
$contents = preg_replace("/LATITUDE=.*/", "LATITUDE=$latitude", $contents);
$contents = preg_replace("/LONGITUDE=.*/", "LONGITUDE=$longitude", $contents);
$contents = preg_replace("/BIRDWEATHER_ID=.*/", "BIRDWEATHER_ID=$birdweather_id", $contents);
-$contents = preg_replace("/PUSHED_APP_KEY=.*/", "PUSHED_APP_KEY=$pushed_app_key", $contents);
-$contents = preg_replace("/PUSHED_APP_SECRET=.*/", "PUSHED_APP_SECRET=$pushed_app_secret", $contents);
$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);
@@ -35,8 +33,6 @@ $contents2 = file_get_contents("./scripts/thisrun.txt");
$contents2 = preg_replace("/LATITUDE=.*/", "LATITUDE=$latitude", $contents2);
$contents2 = preg_replace("/LONGITUDE=.*/", "LONGITUDE=$longitude", $contents2);
$contents2 = preg_replace("/BIRDWEATHER_ID=.*/", "BIRDWEATHER_ID=$birdweather_id", $contents2);
-$contents2 = preg_replace("/PUSHED_APP_KEY=.*/", "PUSHED_APP_KEY=$pushed_app_key", $contents2);
-$contents2 = preg_replace("/PUSHED_APP_SECRET=.*/", "PUSHED_APP_SECRET=$pushed_app_secret", $contents2);
$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);
@@ -113,13 +109,9 @@ if (!isset($_SERVER['PHP_AUTH_USER'])) {
Set your Latitude and Longitude to 4 decimal places. Get your coordinates here .
BirdWeather ID:
- BirdWeather.com is a weather map for bird sounds. Stations around the world supply audio and video streams to BirdWeather where they are then analyzed by BirdNET and compared to eBird Grid data. BirdWeather catalogues the bird audio and spectrogram visualizations so that you can listen to, view, and read about birds throughout the world. Email Tim to request a BirdWeather ID
- Pushed App Key:
-
- Pushed App Secret:
-
- Pushed iOS Notifications can be setup and enabled for New Species notifications. Be sure to "Enable" the "Pushed Notifications" in "Tools" > "Services" if you would like to use this feature. Sorry, Android users, this only works on iOS.
-
+ BirdWeather.com is a weather map for bird sounds. Stations around the world supply audio and video streams to BirdWeather where they are then analyzed by BirdNET and compared to eBird Grid data. BirdWeather catalogues the bird audio and spectrogram visualizations so that you can listen to, view, and read about birds throughout the world. Email Tim to request a BirdWeather ID
+ Notifications
+ Apprise Notifications can be setup and enabled for 70+ notification services. Each service should be on its own line.
Apprise Notifications Configuration: