Skip to content

A live bird collage card for your Home Assistant dashboard.

Notification conf and cron setups

ehpersonal385896f00a559e
diff --git a/birdnet.conf-defaults b/birdnet.conf-defaults
index 88732b9c..9baad168 100644
--- a/birdnet.conf-defaults
+++ b/birdnet.conf-defaults
@@ -62,6 +62,7 @@ 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
+APPRISE_WEEKLY_REPORT=0
#---------------------- Flickr Images API Configuration -----------------------#
## If FLICKR_API_KEY is set, the web interface will try and display bird images
diff --git a/scripts/install_config.sh b/scripts/install_config.sh
index dcb78c1c..432146fb 100755
--- a/scripts/install_config.sh
+++ b/scripts/install_config.sh
@@ -75,6 +75,7 @@ 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
+APPRISE_WEEKLY_REPORT=0
#---------------------- Flickr Images API Configuration -----------------------#
## If FLICKR_API_KEY is set, the web interface will try and display bird images
diff --git a/scripts/install_services.sh b/scripts/install_services.sh
index 17c43975..9df1fd21 100755
--- a/scripts/install_services.sh
+++ b/scripts/install_services.sh
@@ -111,6 +111,7 @@ create_necessary_dirs() {
sudo -u ${USER} ln -fs $my_dir/scripts/stats.php ${EXTRACTED}
sudo -u ${USER} ln -fs $my_dir/scripts/todays_detections.php ${EXTRACTED}
sudo -u ${USER} ln -fs $my_dir/scripts/history.php ${EXTRACTED}
+ sudo -u ${USER} ln -fs $my_dir/scripts/weekly_report.php ${EXTRACTED}
sudo -u ${USER} ln -fs $my_dir/homepage/images/favicon.ico ${EXTRACTED}
sudo -u ${USER} ln -fs ${HOME}/phpsysinfo ${EXTRACTED}
sudo -u ${USER} ln -fs $my_dir/templates/phpsysinfo.ini ${HOME}/phpsysinfo/
@@ -406,6 +407,10 @@ install_cleanup_cron() {
sed "s/\$USER/$USER/g" $my_dir/templates/cleanup.cron >> /etc/crontab
}
+install_weekly_cron() {
+ sed "s/\$USER/$USER/g" $my_dir/templates/weekly_report.cron >> /etc/crontab
+}
+
chown_things() {
chown -R $USER:$USER $HOME/Bird*
}
@@ -431,6 +436,7 @@ install_services() {
install_phpsysinfo
install_livestream_service
install_cleanup_cron
+ install_weekly_cron
create_necessary_dirs
generate_BirdDB
diff --git a/scripts/update_birdnet_snippets.sh b/scripts/update_birdnet_snippets.sh
index b03a0d7f..3bcb7740 100755
--- a/scripts/update_birdnet_snippets.sh
+++ b/scripts/update_birdnet_snippets.sh
@@ -95,6 +95,11 @@ if [[ "$pytest_installation_status" = "not installed" ]];then
fi
[ -L ~/BirdSongs/Extracted/weekly_report.php ] || ln -sf ~/BirdNET-Pi/scripts/weekly_report.php ~/BirdSongs/Extracted
+[ -L /usr/local/bin/weekly_report.sh ] || ln -sf ~/BirdNET-Pi/scripts/weekly_report.php /usr/local/bin/weekly_report.sh
+sed "s/\$USER/$USER/g" $HOME/BirdNET-Pi/templates/weekly_report.cron >> /etc/crontab
+if ! grep APPRISE_WEEKLY_REPORT /etc/birdnet/birdnet.conf &>/dev/null;then
+ sudo -u$USER echo "APPRISE_WEEKLY_REPORT=0" >> /etc/birdnet/birdnet.conf
+fi
sudo systemctl daemon-reload
restart_services.sh
diff --git a/scripts/weekly_report_notification.sh b/scripts/weekly_report.sh
similarity index 71%
rename from scripts/weekly_report_notification.sh
rename to scripts/weekly_report.sh
index b78983b3..f52f4d23 100644
--- a/scripts/weekly_report_notification.sh
+++ b/scripts/weekly_report.sh
@@ -1,4 +1,7 @@
#!/usr/bin/env bash
+source /etc/birdnet/birdnet.conf
+echo ${APPRISE_WEEKLY_REPORT}
+
NOTIFICATION=$(curl 'localhost/views.php?view=Weekly%20Report&ascii=true')
NOTIFICATION=${NOTIFICATION#*#}
firstLine=`echo "${NOTIFICATION}" | head -1`
diff --git a/templates/weekly_report.cron b/templates/weekly_report.cron
new file mode 100644
index 00000000..466c7499
--- /dev/null
+++ b/templates/weekly_report.cron
@@ -0,0 +1,2 @@
+#birdnet
+0 7 * * 1 $USER /usr/local/bin/weekly_report.sh >/dev/null 2>&1
\ No newline at end of file