feat: add group entities in discovery config#31663
Conversation
baa0c2d to
046183a
Compare
| const endpointName = device.endpointName(member); | ||
| const expectedObjectId = endpointName ? `${config.object_id}_${endpointName}` : config.object_id; | ||
|
|
||
| for (const dc of this.getConfigs(device)) { |
There was a problem hiding this comment.
I'm wondering if we can prevent all this looping, as this function is quite heavy and already had performance issues in the past. What if we first discover all devices and keep a lookup of device -> object_id, then we can easily use that here preventing a getConfigs() call.
There was a problem hiding this comment.
Thanks for your review. Please see my latest commit where I tried to keep a config lookup map for devices to avoid the getConfigs() call.
As I'm not really familiar with the codebase, please say if you had something else in mind. Also I'm not sure if I haven't missed any of the important events like onEntityRemoved().
There was a problem hiding this comment.
Pull request overview
Adds Home Assistant MQTT “entity grouping” support to Zigbee2MQTT group discovery payloads, enabling HA to show group entities with their member entities (requires HA > 2026.4).
Changes:
- Track per-device discovered HA configs to know which member entities exist.
- Include a
groupfield in group entity discovery payloads containing member entityunique_ids. - Update Home Assistant extension tests to assert the new
groupdiscovery field.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| lib/extension/homeassistant.ts | Builds and publishes payload.group for group entities using stored per-device config lookups. |
| test/extensions/homeassistant.test.ts | Updates expected discovery payloads to include group member unique_ids. |
|
Thanks! |
This PR implements feature #28512.
It requires Home Assistant >2026.4 for MQTT grouping (home-assistant/core#152270).
Screenshot:

Note that the member entities must be already configured before the member entities will become visible in the UI at the moment a group entity is loaded. So basically you need the reload your MQTT integration after having this in Zigbee2MQTT.