Support expanding nested groups

pull/1184/head
Paulus Schoutsen 2016-02-09 22:43:07 -08:00
parent 09b3aba51b
commit dc44ef7356
2 changed files with 12 additions and 1 deletions

View File

@ -71,7 +71,7 @@ def expand_entity_ids(hass, entity_ids):
if domain == DOMAIN: if domain == DOMAIN:
found_ids.extend( found_ids.extend(
ent_id for ent_id 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) if ent_id not in found_ids)
else: else:

View File

@ -236,3 +236,14 @@ class TestComponentsGroup(unittest.TestCase):
grp2 = group.Group(self.hass, 'Je suis Charlie') grp2 = group.Group(self.hass, 'Je suis Charlie')
self.assertNotEqual(grp1.entity_id, grp2.entity_id) 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'])))