Hypfer / hass-scene_presets

Hue-like scene presets for lights in home assistant
Apache License 2.0
128 stars 9 forks source link

Question about unwrapping group childs #16

Closed marcelveldt closed 9 months ago

marcelveldt commented 9 months ago

What is happening?

I noticed you made a change where grouped lights automatically are expanded. While this is in principle a nice behavior its not always wanted. For example I have a few groups of lights I'd like to have the same color. So I manually specified multiple groups of lights.

Which are now (since recent versions) all expanded into individual lights. Even creating a "super group" and adding the subgroups in there expands them all. I don't think that is desired behavior.

What should be happening?

I'm asking you to consider to only unwrap/unfold one single iteration of groups and not expand the entire tree. Either that, or a simple option to not expand at all.

Reflection 1

Balanced View

Is this issue tracker the right place for this topic?

Sure and as you are aware I'm willing to PR the change myself.

Please enter the scene_preset version you're using

latest

Please enter the Home Assistant version you're using

2024.1

Details about your setup

irrelevant

Reflection 2

irrelevant

Time and Effort

Hypfer commented 9 months ago

Your use-case makes perfect sense, however unfortunately, there's also another use-case that also makes perfect sense: Specifically the one described in this forum post. Relevant quote:

Kitchen All Group and inside that the light groups Kitchen Bench, Kitchen Sink, Kitchen Galley

I wouldn't want to just add a toggle and be done with that though, as that will just clutter the interface, cause overall confusion and will look like an afterthought hack because it is an afterthought hack.

Instead, I think the best solution for this is to be found in working on the group component of Home Assistant. Specifically, I think that this could be an attribute of a group entity.

Actually, I thought that there already was something like that in HA. However, looking at the code, I just found out that the Hide members toggle doesn't hide the group members attribute as one would expect. Instead, it hides the entities that are members of that group...elsewhere? Everywhere?

To me, the group component seems to be in a mediocre state. I think it could greatly benefit from some additional thought going into it.

Maybe there could even be a better way of knowing if an entity_id is a group that needs to be resolved other than having to recursively fetch all entities by ID and check their attributes for more entity ids.

marcelveldt commented 9 months ago

Yeah, there are 2 usecases indeed that both make sense. My personal opinion is that a quick fix/win would be to not recursively unwrap groups by default but make that optional/configurable. Maybe make that a config entry option.

marcelveldt commented 9 months ago

Actually, I thought that there already was something like that in HA. However, looking at the code, I just found out that the Hide members toggle doesn't hide the group members attribute as one would expect. Instead, it hides the entities that are members of that group...elsewhere? Everywhere?

Yeah, that is how it works. That checkbox will mark the underlying entities as hidden so they won't show up in the UI. That is actually a perfect approach to fix this... except for the fact that I don't think that checkbox is exposed as its an option of that specific group.

To me, the group component seems to be in a mediocre state. I think it could greatly benefit from some additional thought going into it.

Well, I think the group in general works well and can be expanded with more features. A way to lookup if the members should be hidden (attribute perhaps) could be the simple solution