A live bird collage card for your Home Assistant dashboard.
adding new custom_recording.service in the installer (but not enabled) cuz why not new viewdb.php > todays_detections.php
mcguirepr895896a44889d5
diff --git a/homepage/views.php b/homepage/views.phpindex 797e47c4..1aba1830 100644--- a/homepage/views.php+++ b/homepage/views.php@@ -37,7 +37,7 @@ if(isset($_POST['view'])){if($_POST['view'] == "Services"){include('scripts/service_controls.php');}if($_POST['view'] == "Spectrogram"){include('spectrogram.php');}if($_POST['view'] == "Overview"){include('overview.php');}- if($_POST['view'] == "Today's Detections"){include('viewdb.php');}+ if($_POST['view'] == "Today's Detections"){include('todays_detections.php');}if($_POST['view'] == "Species Stats"){echo "<br><br>";include('stats.php');}if($_POST['view'] == "Daily Charts"){include('history.php');}if($_POST['view'] == "Tools"){diff --git a/scripts/custom_recording.sh b/scripts/custom_recording.shnew file mode 100755index 00000000..ccf43033--- /dev/null+++ b/scripts/custom_recording.sh@@ -0,0 +1,75 @@+#!/usr/bin/env bash+set -x+source /etc/birdnet/birdnet.conf++STAMP="%H:%M:%S"++[ -z $RECORDING_LENGTH ] && RECORDING_LENGTH=15++if ! pulseaudio --check;then pulseaudio --start;fi++CUSTOM_WINDOW_START=(0 3 15 22)+CUSTOM_WINDOW_END=(0 7 19 23)+RECORDING_DURATION=60+PAUSE_DURATION=240++now=$(date +%H)++while [ $now -ge ${CUSTOM_WINDOW_START[0]} ] && [ $now -le ${CUSTOM_WINDOW_END[0]} ];do+ echo $now+ # If you prefer no directory structure under "Raw", comment out the+ # lines below and uncommend the commands at the bottom.+ arecord -f S16_LE -c${CHANNELS} -r48000 -t wav -d $RECORDING_DURATION \+ --use-strftime ${EXTRACTED}/Raw/%B-%Y/%d-%A/%F-birdnet-${STAMP}.wav++ # Uncomment the lines below if you'd prefer having no directory scructure+ # under the "Raw" directory. Be sure to comment out the command above.+ #arecord -f S16_LE -c${CHANNELS} -r48000 -t wav -d $RECORDING_DURATION \+ # --use-strftime ${EXTRACTED}/Raw/%F-birdnet-${STAMP}.wav+ sleep $PAUSE_DURATION+ now=$(date +%H)+done+while [ $now -ge ${CUSTOM_WINDOW_START[1]} ] && [ $now -le ${CUSTOM_WINDOW_END[1]} ];do+ echo $now+ # If you prefer no directory structure under "Raw", comment out the+ # lines below and uncommend the commands at the bottom.+ arecord -f S16_LE -c${CHANNELS} -r48000 -t wav -d $RECORDING_DURATION \+ --use-strftime ${EXTRACTED}/Raw/%B-%Y/%d-%A/%F-birdnet-${STAMP}.wav++ # Uncomment the lines below if you'd prefer having no directory scructure+ # under the "Raw" directory. Be sure to comment out the command above.+ #arecord -f S16_LE -c${CHANNELS} -r48000 -t wav -d $RECORDING_DURATION \+ # --use-strftime ${EXTRACTED}/Raw/%F-birdnet-${STAMP}.wav+ sleep $PAUSE_DURATION+ now=$(date +%H)+done+while [ $now -ge ${CUSTOM_WINDOW_START[2]} ] && [ $now -le ${CUSTOM_WINDOW_END[2]} ];do+ echo $now+ # If you prefer no directory structure under "Raw", comment out the+ # lines below and uncommend the commands at the bottom.+ arecord -f S16_LE -c${CHANNELS} -r48000 -t wav -d $RECORDING_DURATION \+ --use-strftime ${EXTRACTED}/Raw/%B-%Y/%d-%A/%F-birdnet-${STAMP}.wav++ # Uncomment the lines below if you'd prefer having no directory scructure+ # under the "Raw" directory. Be sure to comment out the command above.+ #arecord -f S16_LE -c${CHANNELS} -r48000 -t wav -d $RECORDING_DURATION \+ # --use-strftime ${EXTRACTED}/Raw/%F-birdnet-${STAMP}.wav+ sleep $PAUSE_DURATION+ now=$(date +%H)+done+while [ $now -ge ${CUSTOM_WINDOW_START[3]} ] && [ $now -le ${CUSTOM_WINDOW_END[3]} ];do+ echo $now+ # If you prefer no directory structure under "Raw", comment out the+ # lines below and uncommend the commands at the bottom.+ arecord -f S16_LE -c${CHANNELS} -r48000 -t wav -d $RECORDING_DURATION \+ --use-strftime ${EXTRACTED}/Raw/%B-%Y/%d-%A/%F-birdnet-${STAMP}.wav++ # Uncomment the lines below if you'd prefer having no directory scructure+ # under the "Raw" directory. Be sure to comment out the command above.+ #arecord -f S16_LE -c${CHANNELS} -r48000 -t wav -d $RECORDING_DURATION \+ # --use-strftime ${EXTRACTED}/Raw/%F-birdnet-${STAMP}.wav+ sleep $PAUSE_DURATION+ now=$(date +%H)+done++diff --git a/scripts/install_services.sh b/scripts/install_services.shindex 58c5c31f..297fb511 100755--- a/scripts/install_services.sh+++ b/scripts/install_services.sh@@ -176,6 +176,24 @@ EOFsystemctl enable birdnet_recording.service}+install_custom_recording_service() {+ echo "Installing custom_recording.service"+ cat << EOF > /home/pi/BirdNET-Pi/templates/custom_recording.service+[Unit]+Description=BirdNET Custom Recording+[Service]+Environment=XDG_RUNTIME_DIR=/run/user/1000+Restart=always+Type=simple+RestartSec=3+User=${USER}+ExecStart=/usr/local/bin/custom_recording.sh+[Install]+WantedBy=multi-user.target+EOF+ ln -sf /home/pi/BirdNET-Pi/templates/birdnet_recording.service /usr/lib/systemd/system+}+install_Caddyfile() {[ -d /etc/caddy ] || mkdir /etc/caddyif [ -f /etc/caddy/Caddyfile ];then@@ -412,6 +430,7 @@ install_services() {install_birdnet_serverinstall_birdnet_stats_serviceinstall_recording_service+ install_custom_recording_service # But does not enableinstall_extraction_serviceinstall_pushed_notificationsinstall_spectrogram_servicediff --git a/scripts/viewdb.php b/scripts/todays_detections.phpsimilarity index 93%rename from scripts/viewdb.phprename to scripts/todays_detections.phpindex e29e01f4..dbdd8b96 100644--- a/scripts/viewdb.php+++ b/scripts/todays_detections.php@@ -9,7 +9,7 @@ if($db == False){header("refresh: 0;");}-$statement0 = $db->prepare('SELECT Time, Com_Name, Sci_Name, Confidence, File_Name FROM detections WHERE Date == Date(\'now\', \'localtime\') GROUP BY Time ORDER BY Time DESC, MAX(Confidence) ASC');+$statement0 = $db->prepare('SELECT Time, Com_Name, Sci_Name, Confidence, File_Name FROM detections WHERE Date == Date(\'now\', \'localtime\') ORDER BY Time DESC');if($statement0 == False){echo "Database is busy";header("refresh: 0;");@@ -103,7 +103,7 @@ $sciname = preg_replace('/ /', '_', $todaytable['Sci_Name']);<b><a class="a2" href="https://allaboutbirds.org/guide/<?php echo $comname;?>" target="top"><?php echo $todaytable['Com_Name'];?></a></b><br><a class="a2" href="https://wikipedia.org/wiki/<?php echo $sciname;?>" target="top"><i><?php echo $todaytable['Sci_Name'];?></i></a><br><b>Confidence:</b> <?php echo $todaytable['Confidence'];?><br>- <video controls poster="<?php echo $filename.".png";?>" preload="none" title="<?php echo $filename;?>"><source src="<?php echo $filename;?>"></video></td>+ <a href="<?php echo $filename;?>"><img src="<?php echo $filename.".png";?>"></a></td><?php }?></tr></table>