Skip to content

fix(mqtt): align Home Assistant discovery and state topics - #1204

Merged
scttbnsn merged 3 commits into
dev/v1.7from
scttbnsn/fix-v1.7-ha-state-topics
Sep 15, 2026
Merged

scttbnsn merged 3 commits into
dev/v1.7from
scttbnsn/fix-v1.7-ha-state-topics

Conversation

@scttbnsn

@scttbnsn scttbnsn commented Sep 15, 2026 •

Copy link
Copy Markdown
Contributor

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.

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.
@vercel

vercel Bot commented Sep 15, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
drydock-website Ready Ready Preview Sep 15, 2026 12:53pm UTC
drydockdemo-website Ready Ready Preview Sep 15, 2026 12:53pm UTC

@coderabbitai

coderabbitai Bot commented Sep 15, 2026 •

Copy link
Copy Markdown

Warning

Review limit reached

Next included review available in 50 minutes.

Check out review usage here.

View limit details

Limit 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.

Learn how review limits work.

Review configuration:

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Advanced

Run ID: 794547f5-a722-4e80-8114-c3dbd6a3a6be

📥 Commits

Reviewing files that changed from the base of the PR and between 7148848 and c9cb4a6.

⛔ Files ignored due to path filters (1)
  • CHANGELOG.md is excluded by !CHANGELOG.md
📒 Files selected for processing (7)
  • Dockerfile
  • app/configuration/dockerfile-defaults.test.ts
  • app/triggers/providers/mqtt/Hass.ts
  • app/triggers/providers/mqtt/Mqtt.test.ts
  • app/triggers/providers/mqtt/Mqtt.ts
  • app/triggers/providers/mqtt/topics.ts
  • content/docs/current/configuration/triggers/mqtt/index.mdx

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@codecov

codecov Bot commented Sep 15, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@scttbnsn

Copy link
Copy Markdown
Contributor Author

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.

@scttbnsn

Copy link
Copy Markdown
Contributor Author

@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.

@coderabbitai

coderabbitai Bot commented Sep 15, 2026 •

Copy link
Copy Markdown
🧩 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
done

Length 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.ts

Length 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' || true

Length of output: 26504


@scttbnsn No actionable findings in the requested scope.

Checked commit c9cb4a6c977bcaeb5268f90c03659ebc1ca557b5. The shared topic builder is used by MQTT state publishing and Home Assistant discovery. The coverage includes default segmentation, opt-out, canonical container names, aliases, controller-local containers, and plain MQTT with HASS_ENABLED=false. The Alpine timezone pin is tzdata=2026d-r0.

⚠️ Action not completed

Review rate limited.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@scttbnsn
scttbnsn merged commit 271a12f into dev/v1.7 Sep 15, 2026
35 of 36 checks passed
@scttbnsn
scttbnsn deleted the scttbnsn/fix-v1.7-ha-state-topics branch September 15, 2026 13:26

This branch was successfully deployed

2 active deployments
Preview – drydock-website — c9cb4a6c Deployed Sep 15, 2026 by vercel[bot]
Preview – drydockdemo-website — c9cb4a6c Deployed Sep 15, 2026 by vercel[bot]
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