Add service to publish past detections to BirdWeather#250
Add service to publish past detections to BirdWeather#250tvoirand wants to merge 9 commits intoNachtzuster:mainfrom
Conversation
This allows to decorrelate the Detection class and the .wav audio files that are temporarily stored in the "StreamData" folder.
This allows to reuse this function in another service.
|
Thanks for the PR & writeup. I probably won't have time to really look at it this week (maybe during the weekend) |
This suppresses the output of the curl command, used to check if BirdWeather is accessible, by redirecting it to /dev/null.
Take date *and time* into account (and not just the date) when fetching recent detections from the database.
|
Hi, I just wanted to check in on this PR and see whether you think we can move it forward at some point. I have been watching the repo lately and I can see that it's very active, which is great, though I imagine it must be quite demanding. If this kind of extensive change isn't something you'd like to prioritize or doesn't align with the project's direction, I'd perfectly understand. If that's the case it might make sense to close this PR. On the other hand, if you're still interested in the proposed feature and would prefer to keep the PR open for a potential review later on, that's fine too. As a side note, after reviewing the changes, I remembered that some parts could be implemented independently from the full past detections publication service, like the Happy to hear your thoughts ! |
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).