π fix(mqtt): fall back to installed tag in HASS latest_version template (#491)#492
π fix(mqtt): fall back to installed tag in HASS latest_version template (#491)#492scttbnsn wants to merge 1 commit into
Conversation
β¦te (#491) The Home Assistant MQTT discovery latest_version template rendered an empty string for any container with no pending update (no `result` in the flattened state payload, so no `result_tag`/`result_digest`). HA silently discards an empty template render, leaving "Newest version" unset β and because HA blanks the whole `update.*` entity state when either version is missing, the entity read "Unknown" forever instead of resolving to "up to date". The template now falls back to `image_tag_value` (the installed tag) in both the digest and tag branches, and guards the digest slice with `if value_json.result_digest` so a digest-kind report carrying no digest no longer trips HA's `Undefined[:15]` slice error. - β test(mqtt): lock the flattened-payload contract the template reads (up-to-date β image_tag_value + no result_*; tag/digest β matching result_*) - β test(mqtt): pin the new latest_version_template string in the HA discovery payload Fixes: #491
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
No actionable comments were generated in the recent review. π βΉοΈ Recent review infoβοΈ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: β Files ignored due to path filters (1)
π Files selected for processing (3)
π WalkthroughWalkthroughModifies the Home Assistant MQTT discovery Changes
Sequence Diagram(s)Not applicable β changes are template logic and test assertions, not runtime call flows. Related Issues: Related PRs: None identified. Suggested labels: bug, mqtt, home-assistant Suggested reviewers: None identified. Review note: Poem: π₯ Pre-merge checks | β 2β Passed checks (2 passed)
β¨ Finishing Touchesπ Generate docstrings
π§ͺ Generate unit tests (beta)
Comment |
β¦te (#491) Forward-port of b5a9e00 (PR #492, 1.5.1 line) onto dev/v1.6. The Home Assistant MQTT discovery latest_version template rendered an empty string for any container with no pending update (no `result` in the flattened state payload, so no `result_tag`/`result_digest`). HA silently discards an empty template render, leaving "Newest version" unset β and because HA blanks the whole `update.*` entity state when either version is missing, the entity read "Unknown" forever instead of resolving to "up to date". The template now falls back to `image_tag_value` (the installed tag) in both the digest and tag branches, and guards the digest slice with `if value_json.result_digest` so a digest-kind report carrying no digest no longer trips HA's `Undefined[:15]` slice error. CHANGELOG entry intentionally omitted β it lives on the 1.5.1 line; the fix ships there first, so v1.6 inherits it without a duplicate changelog note. Fixes: #491
What
Fixes the Home Assistant
update.dd_container_*entities showing "Unknown" for the "Newest version" attribute (and the entity state as a whole) on containers that are up to date, reported over MQTT + HASS discovery.Root cause
The HASS discovery
latest_versiontemplate was:When a container has no pending update,
container.resultis absent, so the flattened MQTT state payload carries noresult_tag/result_digest. Both branches of the template then render an empty string. Home Assistant silently discards an emptylatest_versionrender, so the "Newest version" attribute never gets set β and because HA blanks the wholeupdate.*entity state when either the installed or latest version is missing, the entity readsUnknownforever instead of resolving to "up to date".Fix
Fall back to the installed image tag (
image_tag_value) in both branches when no update result is present, and guard the digest slice so a digest-kind report that somehow carries no digest doesn't trip HA'sUndefined[:15]Jinja error:Now an up-to-date container reports
latest == installed, which HA renders as "up to date".Tests
Mqtt.test.tsβ new payload-contract test that builds real containers through the model pipeline and locks the flattened-payload shape the template depends on: an up-to-date container carriesimage_tag_valuebut noresult_*keys (exactly the case that used to render empty); a tag update carriesresult_tag; a digest update carriesresult_digest.Hass.test.tsβ the existing HA-discovery-payload assertion is updated to pin the newlatest_version_templatestring, so a future "simplification" can't silently regress this.Note on the reporter's "0 messages"
The issue log also shows
0 most recent received messageson the state topicdd/container/local/homeassistant, which would independently blank both Installed and Newest. That half isn't reproducible from the source βmustTriggerpasses for a plain up-to-date container andtrigger()publishes a retained state payload on every container event regardless of update status. Confirming it needs the reporter's debug-level logs (thePublish container result to β¦line). This PR fixes the template bug that is reproducible and real; the state-delivery question is being followed up on the issue.Fixes #491
π Fixed
update.dd_container_*so up-to-date containers no longer renderUnknownfor installed/newest version fields.image_tag_valuewhen no update result is present.result_digestno longer causes template errors.π§ Changed
Adjusted the Home Assistant discovery payload test to match the new template behavior.
Added MQTT payload contract coverage for up-to-date, tag-update, and digest-update cases.
Verify the flattened MQTT payload shape still matches all existing Home Assistant discovery consumers.
Confirm the
latest_version_templatebehavior with both tag-based and digest-based updates in Home Assistant.