Support expanding nested groups
parent
09b3aba51b
commit
dc44ef7356
|
@ -71,7 +71,7 @@ def expand_entity_ids(hass, entity_ids):
|
|||
if domain == DOMAIN:
|
||||
found_ids.extend(
|
||||
ent_id for ent_id
|
||||
in get_entity_ids(hass, entity_id)
|
||||
in expand_entity_ids(hass, get_entity_ids(hass, entity_id))
|
||||
if ent_id not in found_ids)
|
||||
|
||||
else:
|
||||
|
|
|
@ -236,3 +236,14 @@ class TestComponentsGroup(unittest.TestCase):
|
|||
grp2 = group.Group(self.hass, 'Je suis Charlie')
|
||||
|
||||
self.assertNotEqual(grp1.entity_id, grp2.entity_id)
|
||||
|
||||
def test_expand_entity_ids_expands_nested_groups(self):
|
||||
group.Group(self.hass, 'light', ['light.test_1', 'light.test_2'])
|
||||
group.Group(self.hass, 'switch', ['switch.test_1', 'switch.test_2'])
|
||||
group.Group(self.hass, 'group_of_groups', ['group.light',
|
||||
'group.switch'])
|
||||
|
||||
self.assertEqual(
|
||||
['light.test_1', 'light.test_2', 'switch.test_1', 'switch.test_2'],
|
||||
sorted(group.expand_entity_ids(self.hass,
|
||||
['group.group_of_groups'])))
|
||||
|
|
Loading…
Reference in New Issue