Allow any value when triggering on state attribute (#41261)
This commit is contained in:
1 parent
a6d50ba89b
commit
b524cc9c56
5 files changed
+131
-27
No files matched your search
@@ -422,7 +422,7 @@ async def test_state_attribute(hass):
|
||||
"condition": "state",
|
||||
"entity_id": "sensor.temperature",
|
||||
"attribute": "attribute1",
|
||||
"state": "200",
|
||||
"state": 200,
|
||||
},
|
||||
],
|
||||
},
|
||||
@@ -435,7 +435,7 @@ async def test_state_attribute(hass):
|
||||
assert test(hass)
|
||||
|
||||
hass.states.async_set("sensor.temperature", 100, {"attribute1": "200"})
|
||||
assert test(hass)
|
||||
assert not test(hass)
|
||||
|
||||
hass.states.async_set("sensor.temperature", 100, {"attribute1": 201})
|
||||
assert not test(hass)
|
||||
@@ -444,6 +444,31 @@ async def test_state_attribute(hass):
|
||||
assert not test(hass)
|
||||
|
||||
|
||||
async def test_state_attribute_boolean(hass):
|
||||
"""Test with boolean state attribute in condition."""
|
||||
test = await condition.async_from_config(
|
||||
hass,
|
||||
{
|
||||
"condition": "state",
|
||||
"entity_id": "sensor.temperature",
|
||||
"attribute": "happening",
|
||||
"state": False,
|
||||
},
|
||||
)
|
||||
|
||||
hass.states.async_set("sensor.temperature", 100, {"happening": 200})
|
||||
assert not test(hass)
|
||||
|
||||
hass.states.async_set("sensor.temperature", 100, {"happening": True})
|
||||
assert not test(hass)
|
||||
|
||||
hass.states.async_set("sensor.temperature", 100, {"no_happening": 201})
|
||||
assert not test(hass)
|
||||
|
||||
hass.states.async_set("sensor.temperature", 100, {"happening": False})
|
||||
assert test(hass)
|
||||
|
||||
|
||||
async def test_state_using_input_entities(hass):
|
||||
"""Test state conditions using input_* entities."""
|
||||
await async_setup_component(
|
||||
|
||||
Reference in new issue
Block a user