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.pyat 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)Detectionconstructor no longer depends on theParseFileNameclass, enabling handling detections without access to temporary audio files in theStreamDatafolder. This improves flexibility (and could be implemented independently from this PR).startandstop(delays) withstart_datetimeandstop_datetime(absolute times). Calculation of detection times are move outside of the constructor.Detectionclass are updated accordingly inserver.pyandreporting.pyCentralize logging setup
birdnet_analysis.pytohelpers.pyto allow reuse across multiple scriptsNew BirdWeather module (
birdweather.py):reporting.pyand 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.pyis:createdb.shfor fresh installsupdate_db.shscript executed byupdate_birdnet_snippets.shto ensure this table is presentNew systemd service
birdweather_past_publication:ExecStartPrekey ensures the service runs only once BirdWeather is reachableinstall_helpers.sh,install_services.sh, andupdate_birdnet_snippets.shNetworkd-dispatcher integration:
networkd-dispatcherto trigger actions on network status changes.birdweather_past_publicationservice when connectivity is restored.install_helpers.sh,install_services.sh, andupdate_birdnet_snippets.sh, including setting root ownership (required for networkd-dispatcher scripts).