Skip to content

Optional node level for Home Assistant discovery topics (#1195)#1220

Open
gskjold wants to merge 1 commit into
mainfrom
feature/ha-mqtt-node-id
Open

Optional node level for Home Assistant discovery topics (#1195)#1220
gskjold wants to merge 1 commit into
mainfrom
feature/ha-mqtt-node-id

Conversation

@gskjold

@gskjold gskjold commented Jun 25, 2026

Copy link
Copy Markdown
Member

Closes #1195.

What

Adds an opt-in "Nest sensors under a node level" checkbox to the Home Assistant MQTT configuration. When enabled, sensor discovery topics use HA's optional node_id segment:

<prefix>/sensor/<deviceUid>/<uid>/config      (nested, new opt-in)
<prefix>/sensor/<deviceUid>_<uid>/config      (flat, current default)

This keeps the 20+ discovery entities grouped under a single node in the broker topic tree instead of cluttering the sensor/ root, as requested in #1195.

Why it's safe

  • No entity duplication in HA: uniq_id is built independently in hadiscover.json (still <deviceUid>_<uid>), so moving the topic does not change entity identity.
  • Default off: existing installs keep the current flat layout untouched.
  • EEPROM migration: HomeAssistantConfig gains a trailing nodeId byte in previously-unused space; EEPROM_CHECK_SUM bumps 104 → 105 with a relocateConfig104() step that defaults the flag off. No offsets move.

Caveat

Toggling the option leaves the old retained discovery configs orphaned on the broker until manually cleared (noted in a code comment). The cosmetic nature is intentional — HA already groups entities via the dev block; this only tidies the raw MQTT topic tree.

Size cost

Target Flash RAM
esp32dev +812 B +0 B
esp8266dev +592 B +0 B

Most of the firmware cost is the one-time relocateConfig104() migration, which can be removed in a future release once 104-era configs are gone.

Verification

  • pio run -e esp32dev — SUCCESS
  • pio run -e esp8266dev — SUCCESS (97.8% flash, ~22.5 KB headroom)

Follow-up

New UI string conf.mqtt.ha.nodeid added to localazy/source/en.json; needs the usual Localazy upload after merge.

🤖 Generated with Claude Code

Adds an opt-in "Nest sensors under a node level" toggle to the Home
Assistant MQTT config. When enabled, sensor discovery topics use HA's
optional node_id segment:

  <prefix>/sensor/<deviceUid>/<uid>/config

instead of the flat

  <prefix>/sensor/<deviceUid>_<uid>/config

keeping the 20+ entities tidy under a single node in the broker tree.
uniq_id is unchanged (still <deviceUid>_<uid>), so HA entities are not
duplicated. Default is off; existing installs are unaffected.

HomeAssistantConfig gains a trailing nodeId byte; EEPROM_CHECK_SUM bumps
to 105 with a relocateConfig104() migration that defaults the flag off
(no offsets move, so it is a safe trailing-byte add).

Cost: +812 B flash / +0 RAM on esp32dev, +592 B flash / +0 RAM on
esp8266dev. Builds verified on both.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@github-actions

Copy link
Copy Markdown

🔧 PR Build Artifacts

Version: 79d7c5d

All environments built successfully. Download the zip files:

Artifacts expire after 7 days. View workflow run

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.

subnode in mqtt announcement for homeassistant

1 participant