Repository navigation
fix(mqtt): align Home Assistant discovery and state topics - #1204
Conversation
Backport the reviewed fix from PR #1139, f6b5e82, by Scott Benson. Share topic construction between state publishing and HA discovery while retaining the v1.7 canonical container naming and agenttopicsegment=true default. Keep the original hass.enabled guard so plain MQTT retains its existing layout; omit v1.8 Compose identity and update-state features. Compare actual retained state publishes with emitted discovery state, latest-version, attributes, and command topics. Six agent cases failed on the maintenance base before implementation; all 259 scoped MQTT tests pass afterward with 100% scoped coverage, and the backend builds. Document the unreleased fix and retained old-topic caveat.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Warning Review limit reachedNext included review available in 50 minutes. View limit detailsLimit details: You’ve used all 2 included reviews currently available. You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Review configuration: ⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Advanced Run ID: ⛔ Files ignored due to path filters (1)
📒 Files selected for processing (7)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
|
c9cb4a6 also includes the Alpine timezone-pin repair needed for clean image builds. The MQTT implementation is unchanged. The full normal pre-push gate passed again in 287.11 seconds with 100% app/UI coverage, both builds and all applicable quality checks. Hosted checks and CodeRabbit review are still pending; no release has been cut. |
|
@coderabbitai review Please review exact head c9cb4a6. This backports MQTT/HA shared topic construction while preserving the 1.7 enabled agent-segmentation default, canonical names, and unchanged plain MQTT layout. It also carries the same timezone build repair reviewed in #1203 and #1206, with the existing 1.7 curl removal unchanged. The regression cases failed before the fix; full local gates passed with 100% app/UI coverage. Threat model: a self-hosted Docker manager and operator-configured broker/agent names. Focus on discovery/state parity, default compatibility and no unintended topic-layout changes. |
🧩 Analysis chain🏁 Script executed: #!/bin/bash
set -euo pipefail
printf '%s\n' '== HEAD =='
git rev-parse HEAD
printf '%s\n' '== STATUS =='
git status --short
printf '%s\n' '== PR DIFF STAT (merge-base) =='
base="$(git merge-base HEAD origin/main 2>/dev/null || git merge-base HEAD origin/master)"
git diff --stat "$base"...HEAD
printf '%s\n' '== CHANGED FILES =='
git diff --name-status "$base"...HEAD
printf '%s\n' '== MQTT-RELATED REFERENCES =='
rg -n -i -C 3 '(home assistant|homeassistant|discovery|mqtt|topic)' \
-g '!node_modules/**' -g '!dist/**' -g '!build/**' . | head -n 500
printf '%s\n' '== CANDIDATE FILE OUTLINES =='
fd -t f -i '(mqtt|dockerfile|alpine|timezone|tzdata)' . \
-E node_modules -E dist -E build | while IFS= read -r file; do
printf '\n-- %s --\n' "$file"
ast-grep outline "$file" --items all 2>/dev/null | head -n 160 || true
doneLength of output: 104848 🏁 Script executed: #!/bin/bash
set -euo pipefail
printf '%s\n' '== ISOLATED COMMIT =='
git show --no-ext-diff --format=fuller --stat HEAD
printf '%s\n' '== ISOLATED DIFF: MQTT AND DOCKERFILE =='
git diff --no-ext-diff HEAD^ HEAD -- \
app/triggers/providers/mqtt/Hass.ts \
app/triggers/providers/mqtt/Mqtt.ts \
app/triggers/providers/mqtt/Mqtt.test.ts \
app/triggers/providers/mqtt/topics.ts \
Dockerfile \
app/configuration/dockerfile-defaults.test.ts
printf '%s\n' '== CURRENT MQTT IMPLEMENTATION =='
cat -n app/triggers/providers/mqtt/topics.ts
sed -n '1,260p' app/triggers/providers/mqtt/Mqtt.ts | cat -n
sed -n '1,420p' app/triggers/providers/mqtt/Hass.ts | cat -n
printf '%s\n' '== TOPIC BUILDER AND HASS CALL SITES =='
rg -n -C 5 '\b(getContainerStateTopic|build.*Topic|topic.*container|publish\s*\()' \
app/triggers/providers/mqtt --glob '*.ts'
printf '%s\n' '== FOCUSED TEST LOCATIONS =='
rg -n -C 10 '(agenttopicsegment|agent/|discovery|state topic|HASS|hass)' \
app/triggers/providers/mqtt/Mqtt.test.ts
printf '%s\n' '== DOCKERFILE AND TEST =='
cat -n Dockerfile
cat -n app/configuration/dockerfile-defaults.test.tsLength of output: 135977 🏁 Script executed: #!/bin/bash
set -euo pipefail
base="$(git merge-base HEAD origin/main 2>/dev/null || git merge-base HEAD origin/master)"
printf '%s\n' '== STACK COMMITS =='
git log --reverse --format='%H %s' "$base"..HEAD
printf '%s\n' '== COMMITS TOUCHING MQTT OR DOCKERFILE =='
git log --reverse --format='%H %s' "$base"..HEAD -- \
app/triggers/providers/mqtt Dockerfile app/configuration/dockerfile-defaults.test.ts
printf '%s\n' '== HISTORICAL MQTT/TZDATA DIFFS =='
for commit in $(git log --reverse --format='%H' "$base"..HEAD -- app/triggers/providers/mqtt Dockerfile); do
echo "-- $commit --"
git show --format='format:%s' --no-ext-diff --find-renames "$commit" -- \
app/triggers/providers/mqtt Dockerfile
done
printf '%s\n' '== HASS PATH AND CLEANUP IMPLEMENTATIONS =='
sed -n '420,700p' app/triggers/providers/mqtt/Hass.ts | cat -n
sed -n '760,960p' app/triggers/providers/mqtt/Hass.ts | cat -n
sed -n '1120,1280p' app/triggers/providers/mqtt/Hass.ts | cat -n
printf '%s\n' '== TOPIC INTERPOLATION OUTSIDE topics.ts =='
rg -n -P '(?:\$\{[^}]*topic[^}]*\}|topic\s*\+|/agent/|/total_count|/update_count|/update_status)' \
app/triggers/providers/mqtt --glob '*.ts' -g '!topics.ts'
printf '%s\n' '== TOPIC UNIT TESTS =='
fd -t f 'topics*.test.ts' app/triggers/providers/mqtt -x sh -c 'echo "-- $1 --"; cat -n "$1"' sh {} \;Length of output: 102437 🏁 Script executed: #!/bin/bash
set -euo pipefail
printf '%s\n' '== MQTT TOPIC-SELECTION LINES =='
nl -ba app/triggers/providers/mqtt/Mqtt.ts | sed -n '255,335p'
printf '%s\n' '== HASS CONFIGURATION SCHEMA LINES =='
nl -ba app/triggers/providers/mqtt/Mqtt.ts | sed -n '120,180p'
printf '%s\n' '== MQTT CONFIGURATION DOCUMENTATION =='
rg -n -i -C 5 '(agenttopicsegment|hass.*discovery|discovery.*hass|HASS_DISCOVERY)' \
content/docs/current/configuration/triggers/mqtt/index.mdx \
README.md \
DEPRECATIONS.md
printf '%s\n' '== TESTS WITH HASS ENABLED BUT DISCOVERY DISABLED =='
rg -n -P -U -C 5 'hass:\s*\{(?:(?!\n\s*\}).)*enabled:\s*true(?:(?!\n\s*\}).)*discovery:\s*false|hass:\s*\{(?:(?!\n\s*\}).)*discovery:\s*false(?:(?!\n\s*\}).)*enabled:\s*true' \
app/triggers/providers/mqtt --glob '*.test.ts' || trueLength of output: 26504
Checked commit
|
Backports the shared MQTT topic construction from #1139 to the 1.7 line for discussion #1201. Discovery and state publication now use the same canonical container identity and optional agent segment. The existing 1.7 default stays enabled, and plain MQTT topics are unchanged when Home Assistant discovery is disabled.
Credit to Scott Benson for the original implementation in #1139.
Validation: regression cases failed before the fix; focused MQTT tests pass with 100% coverage. The full pre-push gate passed with 100% backend and UI coverage, builds, lint, static analysis, and workflow tests. All required hosted checks passed on c9cb4a6, and CodeRabbit found no actionable issues. The reporter confirmed 1.7.0-rc.14 and the agent-scoped discovery topic, matching the mismatch in that tag’s publisher. Live broker verification on the fixed build remains outstanding. The accompanying Alpine timezone pin repair also passed both hosted image builds.