Skip to content

mqtt: only clear nearest/nearest_drone topic once on transition to empty#56

Open
richmobile wants to merge 1 commit into
ifnull:mainfrom
richmobile:fix/nearest-empty-json-spam
Open

mqtt: only clear nearest/nearest_drone topic once on transition to empty#56
richmobile wants to merge 1 commit into
ifnull:mainfrom
richmobile:fix/nearest-empty-json-spam

Conversation

@richmobile

Copy link
Copy Markdown

This was done by Claude.

When there's no aircraft in range, publish_summary() (and publish_drone_summary())
republish an empty payload to airspace/summary/nearest (and nearest_drone) on every
tick — 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_status already
avoids republishing unchanged receiver status every tick.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant