Make all entity_ids lowercase (#1786)
This commit is contained in:
parent
6d65b0bbd7
commit
4f834ba3f1
2 changed files with 4 additions and 6 deletions
|
@ -47,6 +47,7 @@ def ensure_list(value):
|
||||||
|
|
||||||
def entity_id(value):
|
def entity_id(value):
|
||||||
"""Validate Entity ID."""
|
"""Validate Entity ID."""
|
||||||
|
value = string(value).lower()
|
||||||
if valid_entity_id(value):
|
if valid_entity_id(value):
|
||||||
return value
|
return value
|
||||||
raise vol.Invalid('Entity ID {} does not match format <domain>.<object_id>'
|
raise vol.Invalid('Entity ID {} does not match format <domain>.<object_id>'
|
||||||
|
@ -58,10 +59,7 @@ def entity_ids(value):
|
||||||
if isinstance(value, str):
|
if isinstance(value, str):
|
||||||
value = [ent_id.strip() for ent_id in value.split(',')]
|
value = [ent_id.strip() for ent_id in value.split(',')]
|
||||||
|
|
||||||
for ent_id in value:
|
return [entity_id(ent_id) for ent_id in value]
|
||||||
entity_id(ent_id)
|
|
||||||
|
|
||||||
return value
|
|
||||||
|
|
||||||
|
|
||||||
def icon(value):
|
def icon(value):
|
||||||
|
|
|
@ -70,7 +70,7 @@ def test_entity_id():
|
||||||
with pytest.raises(vol.MultipleInvalid):
|
with pytest.raises(vol.MultipleInvalid):
|
||||||
schema('invalid_entity')
|
schema('invalid_entity')
|
||||||
|
|
||||||
schema('sensor.light')
|
assert 'sensor.light' == schema('sensor.LIGHT')
|
||||||
|
|
||||||
|
|
||||||
def test_entity_ids():
|
def test_entity_ids():
|
||||||
|
@ -94,7 +94,7 @@ def test_entity_ids():
|
||||||
):
|
):
|
||||||
schema(value)
|
schema(value)
|
||||||
|
|
||||||
assert schema('sensor.light, light.kitchen ') == [
|
assert schema('sensor.LIGHT, light.kitchen ') == [
|
||||||
'sensor.light', 'light.kitchen'
|
'sensor.light', 'light.kitchen'
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue