Skip to content

Commit

Permalink
Fix resolve group hidden members (#17)
Browse files Browse the repository at this point in the history
* Check hide_members option when resolving grouped lights

* remove typing

* Restore formatting

---------

Co-authored-by: Sören Beye <[email protected]>
  • Loading branch information
marcelveldt and Hypfer authored Feb 21, 2024
1 parent 7ec252c commit 0f3623f
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion custom_components/scene_presets/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ def resolve_targets(hass, entity_ids, device_ids, area_ids):


def resolve_entity_ids(hass, entity_id, depth=0):
entity_reg = entity_registry.async_get(hass)
resolved_ids = []

if not entity_id.startswith(("light", "group")):
Expand All @@ -61,7 +62,16 @@ def resolve_entity_ids(hass, entity_id, depth=0):
if not nested_entity_ids: # It's just a plain old light
resolved_ids.append(entity_id)
else: # It's a group possibly pretending to be a light
# We grab the config entry for this entity to determine if we should resolve the underlying entities
if entity_reg_entry := entity_reg.async_get(entity_id):
if conf_entry := hass.config_entries.async_get_entry(
entity_reg_entry.config_entry_id
):
if conf_entry.options.get("hide_members", False):
# The (group) config entry is configured to hide group members, so we do not resolve the underlying entities
return [entity_id]

for nested_entity_id in nested_entity_ids:
resolved_ids.extend(resolve_entity_ids(hass, nested_entity_id, depth + 1))

return resolved_ids
return resolved_ids

0 comments on commit 0f3623f

Please sign in to comment.