From e44c2a4016a12c992154b62ecfbed5a6013623e2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20H=C3=B8yer=20Iversen?= Date: Thu, 9 Jun 2016 05:55:08 +0200 Subject: [PATCH] Improve config validation for group (#2206) * Improve config validation if invalid entity for groups * Improve error message when entity id is invalid --- homeassistant/components/group.py | 2 +- homeassistant/helpers/config_validation.py | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/homeassistant/components/group.py b/homeassistant/components/group.py index c289cca42c5..6c63f2955f6 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.Optional(CONF_ENTITIES): vol.Any(None, cv.entity_ids), + vol.Optional(CONF_ENTITIES): vol.Any(cv.entity_ids, None), CONF_VIEW: bool, CONF_NAME: str, CONF_ICON: cv.icon, diff --git a/homeassistant/helpers/config_validation.py b/homeassistant/helpers/config_validation.py index 031ab5227dc..65a9fe9ebd8 100644 --- a/homeassistant/helpers/config_validation.py +++ b/homeassistant/helpers/config_validation.py @@ -73,12 +73,13 @@ def entity_id(value): value = string(value).lower() if valid_entity_id(value): return value - raise vol.Invalid('Entity ID {} does not match format .' - .format(value)) + raise vol.Invalid('Entity ID {} is an invalid entity id'.format(value)) def entity_ids(value): """Validate Entity IDs.""" + if value is None: + raise vol.Invalid('Entity IDs can not be None') if isinstance(value, str): value = [ent_id.strip() for ent_id in value.split(',')]