diff --git a/.gitignore b/.gitignore index c622287..99afbb4 100644 --- a/.gitignore +++ b/.gitignore @@ -7,3 +7,14 @@ birdnet.conf IdentifiedSoFar.txt IdentifiedSoFar.txt.bak Birders_Guide_Installer_Configuration.txt +birdnet/ +templates/*.service +scripts/*.txt +scripts/birds.db +analyzing_now.txt +apprise.txt +BirdDB.txt +exclude_species_list.txt +firstrun.ini +HUMAN.txt +include_species_list.txt diff --git a/__init__.py b/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/homepage/views.php b/homepage/views.php index 3fc111c..dd75f00 100644 --- a/homepage/views.php +++ b/homepage/views.php @@ -116,7 +116,7 @@ if(isset($_GET['view'])){ - + diff --git a/requirements.txt b/requirements.txt index c407877..9838280 100644 --- a/requirements.txt +++ b/requirements.txt @@ -12,3 +12,5 @@ streamlit plotly apprise paho-mqtt +pytest==7.1.2 +pytest-mock==3.7.0 diff --git a/scripts/__init__.py b/scripts/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/scripts/config.php b/scripts/config.php index 9923158..023499e 100644 --- a/scripts/config.php +++ b/scripts/config.php @@ -41,6 +41,11 @@ if(isset($_GET["latitude"])){ } else { $apprise_notify_new_species = 0; } + if(isset($_GET['apprise_notify_new_species_each_day'])) { + $apprise_notify_new_species_each_day = 1; + } else { + $apprise_notify_new_species_each_day = 0; + } if(isset($timezone)) { shell_exec("sudo timedatectl set-timezone ".$timezone); @@ -92,9 +97,10 @@ if(isset($_GET["latitude"])){ $contents = preg_replace("/LONGITUDE=.*/", "LONGITUDE=$longitude", $contents); $contents = preg_replace("/BIRDWEATHER_ID=.*/", "BIRDWEATHER_ID=$birdweather_id", $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_BODY=.*/", "APPRISE_NOTIFICATION_BODY='$apprise_notification_body'", $contents); $contents = preg_replace("/APPRISE_NOTIFY_EACH_DETECTION=.*/", "APPRISE_NOTIFY_EACH_DETECTION=$apprise_notify_each_detection", $contents); $contents = preg_replace("/APPRISE_NOTIFY_NEW_SPECIES=.*/", "APPRISE_NOTIFY_NEW_SPECIES=$apprise_notify_new_species", $contents); + $contents = preg_replace("/APPRISE_NOTIFY_NEW_SPECIES_EACH_DAY=.*/", "APPRISE_NOTIFY_NEW_SPECIES_EACH_DAY=$apprise_notify_new_species_each_day", $contents); $contents = preg_replace("/FLICKR_API_KEY=.*/", "FLICKR_API_KEY=$flickr_api_key", $contents); $contents = preg_replace("/DATABASE_LANG=.*/", "DATABASE_LANG=$language", $contents); $contents = preg_replace("/FLICKR_FILTER_EMAIL=.*/", "FLICKR_FILTER_EMAIL=$flickr_filter_email", $contents); @@ -104,9 +110,10 @@ if(isset($_GET["latitude"])){ $contents2 = preg_replace("/LONGITUDE=.*/", "LONGITUDE=$longitude", $contents2); $contents2 = preg_replace("/BIRDWEATHER_ID=.*/", "BIRDWEATHER_ID=$birdweather_id", $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_BODY=.*/", "APPRISE_NOTIFICATION_BODY='$apprise_notification_body'", $contents2); $contents2 = preg_replace("/APPRISE_NOTIFY_EACH_DETECTION=.*/", "APPRISE_NOTIFY_EACH_DETECTION=$apprise_notify_each_detection", $contents2); $contents2 = preg_replace("/APPRISE_NOTIFY_NEW_SPECIES=.*/", "APPRISE_NOTIFY_NEW_SPECIES=$apprise_notify_new_species", $contents2); + $contents2 = preg_replace("/APPRISE_NOTIFY_NEW_SPECIES_EACH_DAY=.*/", "APPRISE_NOTIFY_NEW_SPECIES_EACH_DAY=$apprise_notify_new_species_each_day", $contents2); $contents2 = preg_replace("/FLICKR_API_KEY=.*/", "FLICKR_API_KEY=$flickr_api_key", $contents2); $contents2 = preg_replace("/DATABASE_LANG=.*/", "DATABASE_LANG=$language", $contents2); $contents2 = preg_replace("/FLICKR_FILTER_EMAIL=.*/", "FLICKR_FILTER_EMAIL=$flickr_filter_email", $contents2); @@ -150,10 +157,18 @@ if(isset($_GET['sendtest']) && $_GET['sendtest'] == "true") { $result0 = $statement0->execute(); while($todaytable=$result0->fetchArray(SQLITE3_ASSOC)) { - $comname = $todaytable['Com_Name']; - $filename = $todaytable['File_Name']; $sciname = $todaytable['Sci_Name']; - $confidence = $todaytable["Confidence"]; + $comname = $todaytable['Com_Name']; + $confidence = $todaytable['Confidence']; + $filename = $todaytable['File_Name']; + $date = $todaytable['Date']; + $time = $todaytable['Time']; + $week = $todaytable['Week']; + $latitude = $todaytable['Lat']; + $longitude = $todaytable['Lon']; + $cutoff = $todaytable['Cutoff']; + $sens = $todaytable['Sens']; + $overlap = $todaytable['Overlap']; } $title = $_GET['apprise_notification_title']; @@ -165,15 +180,31 @@ if(isset($_GET['sendtest']) && $_GET['sendtest'] == "true") { $filename = "http://birdnetpi.local/"."?filename=".$filename; } - $title = str_replace("\$comname", $comname, $title); $title = str_replace("\$sciname", $sciname, $title); + $title = str_replace("\$comname", $comname, $title); $title = str_replace("\$confidence", $confidence, $title); $title = str_replace("\$listenurl", $filename, $title); + $title = str_replace("\$date", $date, $title); + $title = str_replace("\$time", $time, $title); + $title = str_replace("\$week", $week, $title); + $title = str_replace("\$latitude", $latitude, $title); + $title = str_replace("\$longitude", $longitude, $title); + $title = str_replace("\$cutoff", $cutoff, $title); + $title = str_replace("\$sens", $sens, $title); + $title = str_replace("\$overlap", $overlap, $title); - $body = str_replace("\$comname", $comname, $body); $body = str_replace("\$sciname", $sciname, $body); + $body = str_replace("\$comname", $comname, $body); $body = str_replace("\$confidence", $confidence, $body); $body = str_replace("\$listenurl", $filename, $body); + $body = str_replace("\$date", $date, $body); + $body = str_replace("\$time", $time, $body); + $body = str_replace("\$week", $week, $body); + $body = str_replace("\$latitude", $latitude, $body); + $body = str_replace("\$longitude", $longitude, $body); + $body = str_replace("\$cutoff", $cutoff, $body); + $body = str_replace("\$sens", $sens, $body); + $body = str_replace("\$overlap", $overlap, $body); echo "
".shell_exec($home."/BirdNET-Pi/birdnet/bin/apprise -vv -t '".$title."' -b '".$body."' ".$cf." ")."
"; @@ -273,14 +304,32 @@ https://discordapp.com/api/webhooks/{WebhookID}/{WebhookToken}
Confidence Score
$listenurl
A link to the detection
+
$date
+
Date
+
$time
+
Time
+
$week
+
Week
+
$latitude
+
Latitude
+
$longitude
+
Longitude
+
$cutoff
+
Minimum Confidence set in "Advanced Settings"
+
$sens
+
Sigmoid Sensitivity set in "Advanced Settings"
+
$overlap
+
Overlap set in "Advanced Settings"

Use the variables defined above to customize your notification title and body.


-
+ ' />
>
+ > +
>

diff --git a/scripts/plotly_streamlit.py b/scripts/plotly_streamlit.py index d555e48..fe8fa08 100755 --- a/scripts/plotly_streamlit.py +++ b/scripts/plotly_streamlit.py @@ -6,13 +6,11 @@ from numpy import ma import plotly.graph_objects as go from plotly.subplots import make_subplots import plotly.io as pio -from datetime import timedelta, datetime -from pathlib import Path +from datetime import timedelta import sqlite3 from sqlite3 import Connection import plotly.express as px from sklearn.preprocessing import normalize -import time pio.templates.default = "plotly_white" @@ -40,9 +38,8 @@ st.markdown(""" """, unsafe_allow_html=True) - @st.cache(hash_funcs={Connection: id}) -#@st.cache(allow_output_mutation=True) +# @st.cache(allow_output_mutation=True) def get_connection(path: str): return sqlite3.connect(path, check_same_thread=False) @@ -58,19 +55,18 @@ df2 = df.copy() df2['DateTime'] = pd.to_datetime(df2['Date'] + " " + df2['Time']) df2 = df2.set_index('DateTime') -daily = st.sidebar.checkbox('Single Day View', help= 'Select if you want single day view, unselect for multi-day views') +daily = st.sidebar.checkbox('Single Day View', help='Select if you want single day view, unselect for multi-day views') if daily: -# Date as slider + # Date as slider Start_Date = pd.to_datetime(df2.index.min()).date() End_Date = pd.to_datetime(df2.index.max()).date() # cols1, cols2 = st.columns((1, 1)) end_date = st.sidebar.date_input('Date to View', - min_value = Start_Date, - max_value = End_Date, - value=(End_Date), - help= 'Select date for single day view' - ) + min_value=Start_Date, + max_value=End_Date, + value=(End_Date), + help='Select date for single day view') start_date = end_date else: Start_Date = pd.to_datetime(df2.index.min()).date() @@ -78,11 +74,10 @@ else: # cols1, cols2 = st.columns((1, 1)) start_date, end_date = st.sidebar.slider('Date Range', - min_value = Start_Date-timedelta(days=1), - max_value = End_Date, - value=(Start_Date, End_Date), - help= 'Select start and end date, if same date get a clockplot for a single day' - ) + min_value=Start_Date-timedelta(days=1), + max_value=End_Date, + value=(Start_Date, End_Date), + help='Select start and end date, if same date get a clockplot for a single day') # start_date, end_date = cols1.date_input( # "Date Input for Analysis - select Range for single specie analysis, select single date for daily view", @@ -93,12 +88,14 @@ else: # start_date = datetime(2022 ,5 ,17).date() # end_date = datetime(2022 ,5 ,17).date() + @st.cache() def date_filter(df, start_date, end_date): filt = (df2.index >= pd.Timestamp(start_date)) & (df2.index <= pd.Timestamp(end_date + timedelta(days=1))) df = df[filt] return(df) + df2 = date_filter(df2, start_date, end_date) st.write('', @@ -112,7 +109,7 @@ st.write('