Skip to content

Publish retained per-zone MQTT states with optional Home Assistant discovery - #4

Open
bharat wants to merge 1 commit into
r26D:mainfrom
bharat:feat/mqtt-zone-events
Open

bharat wants to merge 1 commit into
r26D:mainfrom
bharat:feat/mqtt-zone-events

Conversation

@bharat

@bharat bharat commented Aug 17, 2026

Copy link
Copy Markdown

Implements the optional phase from the MQTT panel events design doc: zone state parity with HTTP, without polling.

When --mqtt-zones (or [mqtt] zones = true) is set, every ZONE_STATUS / ZONE_DATA message publishes a retained per-zone state to {prefix}/zone/{number}/state. The payload mirrors the /zones REST field names (partition, area, group, number, name, state, type) and adds a tripped boolean, so MQTT consumers do not need to reimplement state-list parsing. The bootstrap zone scan publishes all zones at startup, and retained delivery means late subscribers (or a restarting Home Assistant) see current state immediately.

With --mqtt-discovery-prefix homeassistant (or [mqtt] discovery_prefix), a retained Home Assistant MQTT discovery config is also published once per zone, so zone binary sensors appear in HA automatically, grouped under a Concord232 device, with availability bound to {prefix}/status. A last-will message now marks {prefix}/status offline (retained) so availability tracks reality when the server dies.

Both features are opt-in and default off; existing MQTT behavior (ALARM / TOUCHPAD events, online status) is unchanged apart from the added LWT. Zone publishing is decoupled from the panel interface via a small handler factory so it stays unit-testable; 5 new tests cover payload shape, retained publishing, one-time discovery, the disabled path, and merged-record lookup.

Context: we run this server against a Concord 4 with Home Assistant consuming /zones at a 1 second poll. This lets us retire that polling entirely.

Design doc table updated to reflect the implemented topic shape.

@bharat
bharat marked this pull request as ready for review August 17, 2026 02:20
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