mqtt: only clear nearest/nearest_drone topic once on transition to empty#56
Open
richmobile wants to merge 1 commit into
Open
mqtt: only clear nearest/nearest_drone topic once on transition to empty#56richmobile wants to merge 1 commit into
richmobile wants to merge 1 commit into
Conversation
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.
This was done by Claude.
When there's no aircraft in range,
publish_summary()(andpublish_drone_summary())republish an empty payload to
airspace/summary/nearest(andnearest_drone) on everytick — not just once on the transition into "empty". Since HA's MQTT integration tries
to JSON-decode every state_topic payload before running value_template, this logs a
WARNING "Erroneous JSON" + a template warning once per publish_summary_min_interval_s,
continuously, for as long as the airspace is empty (which for most installs is most of
the time).
Repro: leave airspace empty for a few minutes with debug/warning logging on the MQTT
integration. Watch homeassistant.log fill with:
WARNING (MainThread) [homeassistant.components.mqtt.entity] Erroneous JSON:
WARNING (MainThread) [homeassistant.helpers.template] Template variable warning:
'value_json' is undefined when rendering '{{ value_json.distance_to.home if
value_json else None }}'
Fix: only publish the empty-retained sentinel once, on the transition from
"has nearest" -> "no nearest", the same way
_last_receiver_statusalreadyavoids republishing unchanged receiver status every tick.