Add service to publish past detections to BirdWeather #250
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Problem
As of now, detections are posted to BirdWeather by
birdnet_analysis.py
at the time of detection. If the BirdNET-Pi station is offline during a detection, that detection is not published to BirdWeather, as described in issue #228.Proposed change
A dedicated service can be added to monitor network connectivity and automatically publish any past detection to BirdWeather when connectivity is restored.
These changes are quite extensive. This PR is intended to present ideas, and further discuss/iterate if there's any interest.
That said, I have tested these updates both on fresh installations and when applied via update_birdnet.sh, and they function as expected.
Detailed description of the changes
Detection class update (
helpers.py
)Detection
constructor no longer depends on theParseFileName
class, enabling handling detections without access to temporary audio files in theStreamData
folder. This improves flexibility (and could be implemented independently from this PR).start
andstop
(delays) withstart_datetime
andstop_datetime
(absolute times). Calculation of detection times are move outside of the constructor.Detection
class are updated accordingly inserver.py
andreporting.py
Centralize logging setup
birdnet_analysis.py
tohelpers.py
to allow reuse across multiple scriptsNew BirdWeather module (
birdweather.py
):reporting.py
and by the new script for processing past detectionsNew python script for past detections publication (
birdweather_past_publication.py
):scripts_metadata
.New table in the SQL database:
birdweather_past_publication.py
is:createdb.sh
for fresh installsupdate_db.sh
script executed byupdate_birdnet_snippets.sh
to ensure this table is presentNew systemd service
birdweather_past_publication
:ExecStartPre
key ensures the service runs only once BirdWeather is reachableinstall_helpers.sh
,install_services.sh
, andupdate_birdnet_snippets.sh
Networkd-dispatcher integration:
networkd-dispatcher
to trigger actions on network status changes.birdweather_past_publication
service when connectivity is restored.install_helpers.sh
,install_services.sh
, andupdate_birdnet_snippets.sh
, including setting root ownership (required for networkd-dispatcher scripts).