mirror of
https://github.com/home-assistant/core.git
synced 2025-07-12 15:57:06 +00:00
Fix scene validator (#40140)
This commit is contained in:
parent
f1169120ae
commit
c62a6cd779
@ -35,15 +35,15 @@ def _convert_states(states):
|
|||||||
"""Convert state definitions to State objects."""
|
"""Convert state definitions to State objects."""
|
||||||
result = {}
|
result = {}
|
||||||
|
|
||||||
for entity_id in states:
|
for entity_id, info in states.items():
|
||||||
entity_id = cv.entity_id(entity_id)
|
entity_id = cv.entity_id(entity_id)
|
||||||
|
|
||||||
if isinstance(states[entity_id], dict):
|
if isinstance(info, dict):
|
||||||
entity_attrs = states[entity_id].copy()
|
entity_attrs = info.copy()
|
||||||
state = entity_attrs.pop(ATTR_STATE, None)
|
state = entity_attrs.pop(ATTR_STATE, None)
|
||||||
attributes = entity_attrs
|
attributes = entity_attrs
|
||||||
else:
|
else:
|
||||||
state = states[entity_id]
|
state = info
|
||||||
attributes = {}
|
attributes = {}
|
||||||
|
|
||||||
# YAML translates 'on' to a boolean
|
# YAML translates 'on' to a boolean
|
||||||
|
@ -320,3 +320,12 @@ async def test_config(hass):
|
|||||||
no_icon = hass.states.get("scene.scene_no_icon")
|
no_icon = hass.states.get("scene.scene_no_icon")
|
||||||
assert no_icon is not None
|
assert no_icon is not None
|
||||||
assert "icon" not in no_icon.attributes
|
assert "icon" not in no_icon.attributes
|
||||||
|
|
||||||
|
|
||||||
|
def test_validator():
|
||||||
|
"""Test validators."""
|
||||||
|
parsed = ha_scene.STATES_SCHEMA({"light.Test": {"state": "on"}})
|
||||||
|
assert len(parsed) == 1
|
||||||
|
assert "light.test" in parsed
|
||||||
|
assert parsed["light.test"].entity_id == "light.test"
|
||||||
|
assert parsed["light.test"].state == "on"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user