architecture icon indicating copy to clipboard operation
architecture copied to clipboard

Add new optional device_class compatible with binary_sensor to group

Open twhittock opened this issue 4 years ago • 1 comments

Context

I wanted to create a group of 4 window sensors, and have the 'or'd status presented in the user interface as 'open' or 'closed'. I also wanted to check which sensor was detected as open by clicking on the group. I could do one or the other - either a template binary sensor to show the correct adjective, or a group to show the members easily. I am not alone in this:

https://community.home-assistant.io/t/device-class-motion-for-a-group/66931 https://community.home-assistant.io/t/how-to-display-proper-binary-sensor-statuses-for-groups/122828 https://community.home-assistant.io/t/group-state-display-device-class/135393 ... I stopped the search after 3. There may be more

Proposal

Add an optional 'device_class' to the group entity. If the device_class is not present, behave as before. If it is present, use the binary_sensor device class rendering in the frontend to display the on/off status.

This is implemented in https://github.com/home-assistant/core/pull/36324 and associated changes in documentation and frontend repositories.

Consequences

The ability to show the status of groups with the device_class the user expects to see in the frontend becomes trivial. No negative consequences I can see, since the new behaviour is entirely optional.

twhittock avatar Jun 01 '20 20:06 twhittock

I think that this is the wrong approach. Groups can group more things than just binary sensors, to fallback to binary sensor text rendering would be weird. To look at the entities it wraps to determine rendering would be too expensive.

Instead, you should take the approach like light.group and cover.group and create a binary_sensor.group. This new binary sensor would be configured like a group and represent the combined state of the entities.

balloob avatar Jun 04 '20 15:06 balloob

This architecture issue is old, stale, and possibly obsolete. Things changed a lot over the years. Additionally, we have been moving to discussions for these architectural discussions.

For that reason, I'm going to close this issue.

../Frenck

frenck avatar May 11 '23 14:05 frenck