Skip to content

Commit

Permalink
fix: Only resolve entities of domain group into their individual enti…
Browse files Browse the repository at this point in the history
…ties
  • Loading branch information
Hypfer committed Apr 30, 2024
1 parent 05b953c commit 3b62b27
Showing 1 changed file with 19 additions and 6 deletions.
25 changes: 19 additions & 6 deletions custom_components/scene_presets/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,14 +76,27 @@ def resolve_entity_ids(hass, entity_id, depth=0):
else: # It's a group possibly pretending to be a light
conf_entry = get_config_entry(hass, entity_id)

if conf_entry is not None and conf_entry.options.get("hide_members", False):
# Assume that by enabling hide_members, the user intended to have a single logical light consisting of multiple physical ones
# => Don't resolve further to not make a single fixture light up with different settings
resolved_ids.append(entity_id)
if conf_entry is not None:
if conf_entry.domain != "group":
# If the domain isn't "group", the entity is something unexpected (e.g. a lightener custom_component entity)
# Thus, we don't resolve them further as we can't make assumptions over the purpose of the entity
resolved_ids.append(entity_id)
else:
# It's a group
# noinspection PySimplifyBooleanCheck
if conf_entry.options.get("hide_members", False) == False:
# If hide_members is not enabled, we assume that the user uses this group to just organize multiple things
# Therefore, we do resolve them further
for nested_entity_id in nested_entity_ids:
resolved_ids.extend(resolve_entity_ids(hass, nested_entity_id, depth + 1))
else:
# If hide_members is enabled, we assume that the user intended to have a single logical light
# consisting of multiple physical ones
# Consequently, we don't resolve further to not make a single fixture light up with different settings
resolved_ids.append(entity_id)
else:
# If there is no config entry (e.g. YAML-configured group), continue resolving further
for nested_entity_id in nested_entity_ids:
# Assume that by not hiding the individual members, the user uses this group to organize multiple things
# => Resolve further until we've arrived at the individual light entities
resolved_ids.extend(resolve_entity_ids(hass, nested_entity_id, depth + 1))

return resolved_ids
Expand Down

0 comments on commit 3b62b27

Please sign in to comment.