mirror of
https://github.com/home-assistant/core.git
synced 2025-07-19 03:07:37 +00:00
Improve config validation for group (#2206)
* Improve config validation if invalid entity for groups * Improve error message when entity id is invalid
This commit is contained in:
parent
29ffa5c282
commit
e44c2a4016
@ -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,
|
||||
|
@ -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 <domain>.<object_id>'
|
||||
.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(',')]
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user