Properly handle the case when a group includes itself. (#8398)

* Properly handle the case when a group includes itself.

* Fix lint
This commit is contained in:
Andrey authored and Paulus Schoutsen committed 2017-07-08 09:20:11 -07:00
1 parent 57c5ed33ee
commit c5bf4fe339
2 files changed
+41 -25

No files matched your search

+5 -3
View File
@@ -184,7 +184,6 @@ def expand_entity_ids(hass, entity_ids):
Async friendly.
"""
found_ids = []
for entity_id in entity_ids:
if not isinstance(entity_id, str):
continue
@@ -196,9 +195,13 @@ def expand_entity_ids(hass, entity_ids):
domain, _ = ha.split_entity_id(entity_id)
if domain == DOMAIN:
child_entities = get_entity_ids(hass, entity_id)
if entity_id in child_entities:
child_entities = list(child_entities)
child_entities.remove(entity_id)
found_ids.extend(
ent_id for ent_id
in expand_entity_ids(hass, get_entity_ids(hass, entity_id))
in expand_entity_ids(hass, child_entities)
if ent_id not in found_ids)
else:
@@ -223,7 +226,6 @@ def get_entity_ids(hass, entity_id, domain_filter=None):
return []
entity_ids = group.attributes[ATTR_ENTITY_ID]
if not domain_filter:
return entity_ids