zigpy / zha

Zigbee Home Automation
Apache License 2.0
26 stars 25 forks source link

entities aren't created from groups with less than 2 members #47

Open ryanwinter opened 7 months ago

ryanwinter commented 7 months ago

My situation here is that I have a group with 2 lights, and one of them failed so I ordered a new one from Ikea. However in the interim, because there was now only one light in the group, it was never discovered (from this logic) and therefor all my dashboards and automations that depended on that entity are broken.

My proposal would be to surface all groups, regardless of the number of members in situations like above.

teskanoo commented 7 months ago

I wholeheartedly concur. I experience the exact situation. I get it that mathematically one is not a group, but functionally, this logic breaks automations.

I have a dead smart bulb to replace in a vaulted ceiling fixture, one of two bulbs in a group... Had to change my UI and automations to be able to turn it off manually or automatically.

agoode commented 6 months ago

I agree it would be useful to avoid this kind of filtering for exactly this reason: if a group of size 2 has a device failure, it shouldn't result in destroying the whole group.

ryanwinter commented 6 months ago

I'm wishing if this was implemented because so situations groups of 1 are automatically created. Perhaps a config option would work?

agoode commented 5 months ago

I've spent some time digging into the code. The assumption that groups have a minimum of 2 members is in a few places, so it's not super trivial to fix. There are tests that assume this as well, so it's taking a while to fix everything.

puddly commented 5 months ago

@agoode I would put your efforts on hold for a bit. This repository is not the ZHA you use in Home Assistant (yet) and not in a state to accept contributions and new features.

agoode commented 5 months ago

Ok, thanks! I did notice both repositories and assumed this one would eventually replace the one in HA.

dmulcahey commented 4 months ago

OK... started thinking about this. Here is a challenge: you add a fan, a light, and a switch to a group. What platform should the group entity get created for? One of the reasons for the 2 device with entities from the same domain restriction is so we know what platform to create the entity for.

There are other edge cases as well... what happens when you have 1 light and 1 switch in a group? we could arbitrarily pick a platform to create the entity for... but then if you add another device for either platform we may swap the group entity platform and therefore the entity id... that would break stuff.

Let me know if I am not explaining this clearly and I'll try to table out some examples.

DarthSonic commented 3 months ago

OK... started thinking about this. Here is a challenge: you add a fan, a light, and a switch to a group. What platform should the group entity get created for? One of the reasons for the 2 device with entities from the same domain restriction is so we know what platform to create the entity for.

There are other edge cases as well... what happens when you have 1 light and 1 switch in a group? we could arbitrarily pick a platform to create the entity for... but then if you add another device for either platform we may swap the group entity platform and therefore the entity id... that would break stuff.

Let me know if I am not explaining this clearly and I'll try to table out some examples.

? If there is only one device, it is clear which domain to choose. I do not see how this connects to the request to enable groups with one device member only.

And for your comment - I do not know if this is technically possible - on group creation one could select the domain the group is for and then can only add devices of that domain.