So interest has been shown in implementing "group" platforms for several PlatformComponents. To recap, group platforms are platforms that encapsulate and proxy the state of several "child" entities. (Just like Hue, ... light groups)
For example, if I have four lights along the corners of my room, I could now (using "light.group") let them show up as one in the front-end.
While I personally love this feature and can't wait for it be added, we definitely shouldn't rush this. We should first try to define what a "group" platform is, how the user expects it to behave, and how configuration should look like.
During this post I will mostly be referring to grouped lights, as that's the component I'm most familiar with. If there are other components that need different configs/behavior, please contribute.
I think our first concern should be abaut how a user expects the group to behave (maybe mimic the behavior of Hue, ... groups) and only then what features it should support.
Related: home-assistant/core#12229, home-assistant/core#11323, home-assistant/core#12303
Behavior
Features: Union / Intersection
So I think first we should define whether the functionality of a group is the union or the intersection of the features of its child components.
For example, if we're setting up several lights into a group, like all lights in the 1. floor, if one of the grouped lights doesn't support RGB colors and all others do, should we disable colors for the entire group? I think this would eventually happen quite often as light groups are potentially great for combining lights of different domains (for example Hue and MQTT lights). Maybe we could even add a configuration option to control this.
State reporting
Next, we should define what state should be reported to the front-end. For example, for a light it would IMHO make very little sense to report the average brightness of all child lights. So one option is to report the state of the first entity - another option would be to report the state of the first entity that is on. Maybe we could even have a "leader" option in the configuration to select this. If one light is on, should we display the whole group as on (as we do in the "normal" groups)? There are many different ways of doing this, and also one of the things we should really be consistent about.
As another example, in lights, should we report all possible effects you could set as effect_list
? Should we use the minimum possible min_mireds
value or the value of the leader. If we call light.toggle
on a light group, should we use our reported state to sync all lights to be of the same state after the toggle, or should we toggle each light individually (probably not too good IMO). So another question: Should we always try to sync the state of all children?
Initial state
Also: What do we report when no child entity has a state yet? Personally I would advocate for STATE_UNAVAILABLE
since that also visually shows in the front-end that you can't control it.
Configuration
Ideally, the configuration would look more or less exactly the same between different components. And I personally also think we should keep customization at a minimum and the default behavior "as dumb as it gets". Why? We have the template platforms to do more complicated stuff and lots of customizability will just scare off users IMHO.
So, do we want the configuration to look something like this: ?
light:
- platform: group
name: Cool Light Group
entities:
- light.amazing_light
- light.foobar
- light.sun
Are there any other features groups should definitely support? Anything we should consider concerning other components?
Front-end support
This is very much a hypothetical, but as @balloob said "We might even add frontend support for "group" platforms to show the child entities." I think we should at least think about how it should be done.