1
mirror of https://github.com/home-assistant/core synced 2024-08-02 23:40:32 +02:00

Merge pull request #1184 from balloob/group-of-groups

Support expanding nested groups
This commit is contained in:
Paulus Schoutsen 2016-02-09 22:56:30 -08:00
commit 70a528c04b
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:
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:

View File

@ -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'])))