diff --git a/requirements.txt b/requirements.txt index 9838280..0096dc5 100644 --- a/requirements.txt +++ b/requirements.txt @@ -8,9 +8,9 @@ pytz tzlocal pandas seaborn -streamlit +streamlit==1.11.1 plotly -apprise +apprise==1.2.1 paho-mqtt pytest==7.1.2 pytest-mock==3.7.0 diff --git a/scripts/install_config.sh b/scripts/install_config.sh index d69e7d9..162b16d 100755 --- a/scripts/install_config.sh +++ b/scripts/install_config.sh @@ -7,6 +7,20 @@ trap 'exit 1' SIGINT SIGHUP echo "Beginning $0" birdnet_conf=$my_dir/birdnet.conf +# Retrieve latitude and longitude from web +LATITUDE=$(curl -s4 http://ip-api.com/json?fields=lat,lon | jq .lat) +LONGITUDE=$(curl -s4 http://ip-api.com/json?fields=lat,lon | jq .lon) + +# Define regular expression pattern +pattern='^[+-]?[0-9]{2}\.[0-9]{4}$' + +# Check if latitude and longitude match the pattern +if ! [[ $LATITUDE =~ $pattern ]] || ! [[ $LONGITUDE =~ $pattern ]]; then + echo -e "\033[33mCouldn't set latitude and longitude automatically, you will need to do this manually from the web interface by navigating to Tools -> Settings -> Location.\033[0m" + LATITUDE=0.0000 + LONGITUDE=0.0000 +fi + install_config() { cat << EOF > $birdnet_conf ################################################################################ @@ -24,8 +38,8 @@ SITE_NAME="$HOSTNAME" ## Please only go to 4 decimal places. Example:43.3984 -LATITUDE=$(curl -s4 ifconfig.co/json | jq .latitude) -LONGITUDE=$(curl -s4 ifconfig.co/json | jq .longitude) +LATITUDE=$LATITUDE +LONGITUDE=$LONGITUDE #--------------------------------- Model --------------------------------------# #_____________The variable below configures which BirdNET model is_____________# diff --git a/scripts/update_birdnet_snippets.sh b/scripts/update_birdnet_snippets.sh index ab35e2c..e9c85dd 100755 --- a/scripts/update_birdnet_snippets.sh +++ b/scripts/update_birdnet_snippets.sh @@ -158,6 +158,7 @@ CREATE INDEX IF NOT EXISTS "detections_Date_Time" ON "detections" ("Date" DESC, EOF $HOME/BirdNET-Pi/birdnet/bin/pip3 install apprise==1.2.1 >/dev/null +$HOME/BirdNET-Pi/birdnet/bin/pip3 install streamlit==1.11.1 >/dev/null if ! grep -q 'RuntimeMaxSec=' "$HOME/BirdNET-Pi/templates/birdnet_analysis.service"&>/dev/null; then sudo -E sed -i '/\[Service\]/a RuntimeMaxSec=3600' "$HOME/BirdNET-Pi/templates/birdnet_analysis.service" diff --git a/scripts/weekly_report.php b/scripts/weekly_report.php index ccc2e5c..b28ef2e 100644 --- a/scripts/weekly_report.php +++ b/scripts/weekly_report.php @@ -100,15 +100,19 @@ if(isset($_GET['ascii'])) { $priorweekcount = $totalcount['COUNT(*)']; // really percent changed - $percentagediff = round( (($scount - $priorweekcount) / $priorweekcount) * 100 ); + if($priorweekcount > 0){ + $percentagediff = round( (($scount - $priorweekcount) / $priorweekcount) * 100 ); - if($percentagediff > 0) { - $percentagediff = "+".$percentagediff."%"; - } else { - $percentagediff = "-".abs($percentagediff)."%"; - } + if($percentagediff > 0) { + $percentagediff = "+".$percentagediff."%"; + } else { + $percentagediff = "-".abs($percentagediff)."%"; + } - echo $com_name." - ".$scount." (".$percentagediff.")
"; + echo $com_name." - ".$scount." (".$percentagediff.")
"; + } else { + echo $com_name." - ".$scount ."
"; + } } }