fix(drone): self-consistent detection notify + durable detection log#50
Merged
Conversation
The drone-detected notification could describe the wrong drone with "unknown nm". The example automation triggered on sensor.airspace_drone_count but rendered its message from sensor.airspace_nearest_drone — two independent entities fed by two MQTT topics. The count includes drones with no position yet (Basic ID heard before a Location message); the nearest sensor only carries positioned drones. So a new positionless drone bumped the count and fired the automation while the nearest sensor still held an earlier (or stale-retained) drone — wrong aircraft, no distance. Trigger on the nearest sensor's track_id attribute instead, so the trigger and the message body are the same self-consistent entity, and the automation only fires once a positioned drone exists (distance always present). self_id is untrusted operator free-text (e.g. "Spoofing test") and now appears only as a last-resort label, never beside a registry-resolved make/model. Add a durable `drone_detected` log line, emitted once per drone after enrichment. It records serial, make/model, self_id, distance, AGL and operator-located in journald / docker logs, independent of MQTT retention — so detections can be audited after the retained topics rotate (the gap that made this bug un-diagnosable from MQTT alone). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
The drone-detected notification could describe the wrong drone with "unknown nm". The example automation triggered on sensor.airspace_drone_count but rendered its message from sensor.airspace_nearest_drone — two independent entities fed by two MQTT topics. The count includes drones with no position yet (Basic ID heard before a Location message); the nearest sensor only carries positioned drones. So a new positionless drone bumped the count and fired the automation while the nearest sensor still held an earlier (or stale-retained) drone — wrong aircraft, no distance.
Trigger on the nearest sensor's track_id attribute instead, so the trigger and the message body are the same self-consistent entity, and the automation only fires once a positioned drone exists (distance always present). self_id is untrusted operator free-text (e.g. "Spoofing test") and now appears only as a last-resort label, never beside a registry-resolved make/model.
Add a durable
drone_detectedlog line, emitted once per drone after enrichment. It records serial, make/model, self_id, distance, AGL and operator-located in journald / docker logs, independent of MQTT retention — so detections can be audited after the retained topics rotate (the gap that made this bug un-diagnosable from MQTT alone).