A live bird collage card for your Home Assistant dashboard.
added 12/24h timestamp formatting as birdnet.conf variable defaults to 24h timestamps
Patrick McGuire50d6a56ae5c8
diff --git a/Birders_Guide_Installer.sh b/Birders_Guide_Installer.shindex ed91bfaf..5e045c88 100755--- a/Birders_Guide_Installer.sh+++ b/Birders_Guide_Installer.sh@@ -155,7 +155,7 @@ Good luck!"| uniq)"script -c "arecord -D ${SOUND_CARD} --dump-hw-params" -a ${SOUND_PARAMS} &> /dev/nullinstall_birdnet_config || exit 1- echo "Installing the BirdNET-Lite"+ echo "Installing BirdNET-Lite"if ${my_dir}/scripts/install_birdnet.sh << EOF ; thenn@@ -211,14 +211,32 @@ DO_EXTRACTIONS=y#################################################################################----------------------------- Recording Service ----------------------------#+#_______________The two variables below can be set to enable __________________#+#________________________the birdnet_recording.service ________________________## Keep this EMPTY if you do not want this device to perform the recording. #-## DO_RECORDING is simply a setting for enabling the 24/7 birdnet_recording.service.+## DO_RECORDING is simply a setting for enabling the 24/7+## birdnet_recording.service.## Set this to Y or y to enable recording.DO_RECORDING=y+## TIMESTAMP_FORMAT is the format the recording service will use to name its+## files. Setting this variable to "12" will name the recorded (and extracted)+## files using the 12-hour AM/PM time format. Setting this variable to "24"+## will name the files using the 24-hour time format. See examples below:+#+## TIMESTAMP_FORMAT=12+## example filename: 236-Northern_Cardinal-86%2021-09-30-birdnet-01:00:19pm.wav+#+## TIMESTAMP_FORMAT=24+## example filename: 236-Northern_Cardinal-86%2021-09-30-birdnet-13:00:19.wav+++TIMESTAMP_FORMAT=24++#################################################################################----------------- Mounting a remote directory with systemd -----------------##_______________The four variables below can be set to enable a_______________#diff --git a/birdnet.conf-defaults b/birdnet.conf-defaultsindex aff886a0..25784d0d 100644--- a/birdnet.conf-defaults+++ b/birdnet.conf-defaults@@ -28,6 +28,8 @@ LONGITUDE=#################################################################################------------------------------ Extraction Service ---------------------------#+#__________________The variable below can be set to enable the ________________#+#______________________________ extraction.service ____________________________## Keep this EMPTY if you do not want this device to perform the extractions #@@ -38,17 +40,34 @@ DO_EXTRACTIONS=#################################################################################----------------------------- Recording Service ----------------------------#+#_______________The two variables below can be set to enable __________________#+#________________________the birdnet_recording.service ________________________## Keep this EMPTY if you do not want this device to perform the recording. #-## DO_RECORDING is simply a setting for enabling the 24/7 birdnet_recording.service.+## DO_RECORDING is simply a setting for enabling the 24/7+## birdnet_recording.service.## Set this to Y or y to enable recording.DO_RECORDING=+## TIMESTAMP_FORMAT is the format the recording service will use to name its+## files. Setting this variable to "12" will name the recorded (and extracted)+## files using the 12-hour AM/PM time format. Setting this variable to "24"+## will name the files using the 24-hour time format. See examples below:+#+## TIMESTAMP_FORMAT=12+## example filename: 236-Northern_Cardinal-86%2021-09-30-birdnet-01:00:19pm.wav+#+## TIMESTAMP_FORMAT=24+## example filename: 236-Northern_Cardinal-86%2021-09-30-birdnet-13:00:19.wav+++TIMESTAMP_FORMAT=+#################################################################################----------------- Mounting a remote directory with systemd -----------------#-#_______________The four variables below can be set to enable a_______________#+#_______________The four variables below can be set to enable a________________##___________________systemd.mount for analysis, extraction,____________________##______________________________or file-serving_________________________________#@@ -155,11 +174,7 @@ INSTALL_NOMACHINE=## dsnoop device, you can set this explicitly from a list of the available## devices from the output of running 'aplay -L'-REC_CARD="\$(sudo -u pi aplay -L \- | grep dsnoop \- | cut -d, -f1 \- | grep -ve 'vc4' -e 'Head' -e 'PCH' \- | uniq)"+REC_CARD=default## PROCESSED is the directory where the formerly 'Analyzed' files are moved## after extractions have been made from them. This includes both WAVE anddiff --git a/scripts/birdnet_recording.sh b/scripts/birdnet_recording.shindex 7b44627d..c975d29c 100755--- a/scripts/birdnet_recording.sh+++ b/scripts/birdnet_recording.sh@@ -2,15 +2,21 @@set -xsource /etc/birdnet/birdnet.conf+if [ "${TIMESTAMP_FORMAT}" == "12" ];then+ STAMP="%I:%M:%S%P"+else+ STAMP="%H:%M:%S"+fi+if pgrep arecord &> /dev/null ;thenecho "Recording"elseif [ -z ${REC_CARD} ];thenarecord -f S16_LE -c${CHANNELS} -r48000 -t wav --max-file-time 9\- --use-strftime ${RECS_DIR}/%B-%Y/%d-%A/%F-birdnet-%I:%M:%S%P.wav+ --use-strftime ${RECS_DIR}/%B-%Y/%d-%A/%F-birdnet-${STAMP}.wavelsearecord -f S16_LE -c${CHANNELS} -r48000 -t wav --max-file-time 9\-D "${REC_CARD}" --use-strftime \- ${RECS_DIR}/%B-%Y/%d-%A/%F-birdnet-%I:%M:%S%P.wav+ ${RECS_DIR}/%B-%Y/%d-%A/%F-birdnet-${STAMP}.wavfifidiff --git a/scripts/install_config.sh b/scripts/install_config.shindex 7b011596..dcf5016d 100755--- a/scripts/install_config.sh+++ b/scripts/install_config.sh@@ -31,6 +31,17 @@ get_DO_EXTRACTIONS() {done}+get_TIMESTAMP_FORMAT() {+ read -n2 -p "Would you like recordings to be time stamped in 12-hour AM/PM+or 24-hour format? " TIMESTAMP_FORMAT+ echo+ case $TIMESTAMP_FORMAT in+ 12 ) ;;+ 24 ) ;;+ * ) TIMESTAMP_FORMAT=24;;+ esac+}+get_DO_RECORDING() {while true; doread -n1 -p "Is this device also doing the recording? " DO_RECORDING@@ -144,7 +155,7 @@ get_INSTALL_NOMACHINE() {}get_CHANNELS() {- REC_CARD="\$(sudo -u pi aplay -L \+ REC_CARD="$(sudo -u pi aplay -L \| grep dsnoop \| cut -d, -f1 \| grep -ve 'vc4' -e 'Head' -e 'PCH' \@@ -158,8 +169,8 @@ get_CHANNELS() {| uniq)"script -c "arecord -D ${SOUND_CARD} --dump-hw-params" -a "${SOUND_PARAMS}" &> /dev/nullCHANNELS=$(awk '/CHANN/ { print $2 }' "${SOUND_PARAMS}" | sed 's/\r$//')- [ ! -z REC_CARD ] || REC_CARD=default- [ ! -z CHANNELS ] || CHANNELS=2+ [ -z REC_CARD ] || REC_CARD=default+ [ -z CHANNELS ] || CHANNELS=2echo "REC_CARD variable set to ${REC_CARD}"echo "Number of channels available: ${CHANNELS}"}@@ -171,6 +182,7 @@ configure() {get_LONGITUDEget_DO_EXTRACTIONSget_DO_RECORDING+ get_TIMESTAMP_FORMATget_REMOTEget_EXTRACTIONS_URLget_PUSHED@@ -220,14 +232,32 @@ DO_EXTRACTIONS=${DO_EXTRACTIONS}#################################################################################----------------------------- Recording Service ----------------------------#+#_______________The two variables below can be set to enable __________________#+#________________________the birdnet_recording.service ________________________## Keep this EMPTY if you do not want this device to perform the recording. #-## DO_RECORDING is simply a setting for enabling the 24/7 birdnet_recording.service.+## DO_RECORDING is simply a setting for enabling the 24/7+## birdnet_recording.service.## Set this to Y or y to enable recording.DO_RECORDING=${DO_RECORDING}+## TIMESTAMP_FORMAT is the format the recording service will use to name its+## files. Setting this variable to "12" will name the recorded (and extracted)+## files using the 12-hour AM/PM time format. Setting this variable to "24"+## will name the files using the 24-hour time format. See examples below:+#+## TIMESTAMP_FORMAT=12+## example filename: 236-Northern_Cardinal-86%2021-09-30-birdnet-01:00:19pm.wav+#+## TIMESTAMP_FORMAT=24+## example filename: 236-Northern_Cardinal-86%2021-09-30-birdnet-13:00:19.wav+++TIMESTAMP_FORMAT=${TIMESTAMP_FORMAT}++#################################################################################----------------- Mounting a remote directory with systemd -----------------##_______________The four variables below can be set to enable a_______________#diff --git a/scripts/install_services.sh b/scripts/install_services.shindex 1d501e3a..994190e0 100755--- a/scripts/install_services.sh+++ b/scripts/install_services.sh@@ -421,7 +421,7 @@ install_selected_services() {install_livestream_servicefi- if [ ! -z "${INSTALL_NOMACHINE}" ];then+ if [[ "${INSTALL_NOMACHINE}" =~ [Yy] ]];theninstall_nomachinefidiff --git a/scripts/species_notifier.sh b/scripts/species_notifier.shindex d5b6b5c5..e4d0c6ff 100755--- a/scripts/species_notifier.sh+++ b/scripts/species_notifier.sh@@ -1,6 +1,6 @@#!/usr/bin/env bash# Sends a notification if a new species is detected-# set -x+#set -xtrap 'rm -f $TMPFILE' SIGINT SIGHUP EXITsource /etc/birdnet/birdnet.conf@@ -12,11 +12,14 @@ cat "${IDFILE}" > "${TMPFILE}"/usr/local/bin/update_species.sh &> /dev/null-if ! diff "${IDFILE}" "${TMPFILE}"; then- SPECIES=("$(diff "${IDFILE}" "${TMPFILE}" \- | awk '/</ {print $2" "$3}')")-- NOTIFICATION="New Species Detected: ${SPECIES[@]}"+if ! diff "${IDFILE}" "${TMPFILE}" &> /dev/null; then+ SPECIES=("$(diff "${IDFILE}" "${TMPFILE}" \+ | grep "Common Name" \+ | sort \+ | awk '{for(i=4;i<=NF;++i)printf $i""FS ; print ""}')")++ NOTIFICATION="New Species Detection: "${SPECIES[@]}""+ echo "${NOTIFICATION}" && exitsudo systemctl restart birdnet_analysis && sleep 30sudo systemctl start extraction