From 446d367aeb182fbf5327940654a1c6ad1d525dce Mon Sep 17 00:00:00 2001 From: Jan Harkes Date: Sat, 9 Apr 2016 12:24:18 -0400 Subject: [PATCH] Accept group without entities in configuration. (#1768) * Accept group without entities in configuration. People seem to use these as placeholders for future expansion of their home automation dreams, and we used to accept them. We still have to specify at least one of 'name', 'view' or 'icon' so that the group is parsed as a dictionary. * Also accept empty entities: key in a group. * Additional fix for empty entities value in a group config. --- homeassistant/components/group.py | 4 ++-- tests/components/test_group.py | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/homeassistant/components/group.py b/homeassistant/components/group.py index aade1493c0b..c289cca42c5 100644 --- a/homeassistant/components/group.py +++ b/homeassistant/components/group.py @@ -39,7 +39,7 @@ def _conf_preprocess(value): return value _SINGLE_GROUP_CONFIG = vol.Schema(vol.All(_conf_preprocess, { - vol.Required(CONF_ENTITIES): cv.entity_ids, + vol.Optional(CONF_ENTITIES): vol.Any(None, cv.entity_ids), CONF_VIEW: bool, CONF_NAME: str, CONF_ICON: cv.icon, @@ -145,7 +145,7 @@ def setup(hass, config): """Setup all groups found definded in the configuration.""" for object_id, conf in config.get(DOMAIN, {}).items(): name = conf.get(CONF_NAME, object_id) - entity_ids = conf[CONF_ENTITIES] + entity_ids = conf.get(CONF_ENTITIES) or [] icon = conf.get(CONF_ICON) view = conf.get(CONF_VIEW) diff --git a/tests/components/test_group.py b/tests/components/test_group.py index 8526be9768d..5c23d6ca0cd 100644 --- a/tests/components/test_group.py +++ b/tests/components/test_group.py @@ -226,6 +226,7 @@ class TestComponentsGroup(unittest.TestCase): 'view': True, }, 'test_group': 'hello.world,sensor.happy', + 'empty_group': {'name': 'Empty Group', 'entities': None}, } })