Skip to content

feat: add group entities in discovery config#31663

Merged
Koenkk merged 5 commits intoKoenkk:devfrom
hoellen:feat/ha-entity-grouping
Apr 17, 2026
Merged

feat: add group entities in discovery config#31663
Koenkk merged 5 commits intoKoenkk:devfrom
hoellen:feat/ha-entity-grouping

Conversation

@hoellen
Copy link
Copy Markdown

@hoellen hoellen commented Apr 10, 2026

This PR implements feature #28512.
It requires Home Assistant >2026.4 for MQTT grouping (home-assistant/core#152270).

Screenshot:
image

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.

@hoellen hoellen force-pushed the feat/ha-entity-grouping branch from baa0c2d to 046183a Compare April 10, 2026 17:38
Comment thread lib/extension/homeassistant.ts
Comment thread lib/extension/homeassistant.ts Outdated
const endpointName = device.endpointName(member);
const expectedObjectId = endpointName ? `${config.object_id}_${endpointName}` : config.object_id;

for (const dc of this.getConfigs(device)) {
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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().

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 group field in group entity discovery payloads containing member entity unique_ids.
  • Update Home Assistant extension tests to assert the new group discovery 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.

@Koenkk Koenkk merged commit 0419726 into Koenkk:dev Apr 17, 2026
11 checks passed
@Koenkk
Copy link
Copy Markdown
Owner

Koenkk commented Apr 17, 2026

Thanks!

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.

3 participants