Fix state overwrite race condition where two platforms request the same entity_id (#42151)
* Fix state overwrite race condition where two platforms request the same entity id * fix test * create reservations instead * revert * cannot use __slots__ because we patch async_all
This commit is contained in:
1 parent
bb641c23a9
commit
df2ede6522
7 files changed
+119
-8
No files matched your search
@@ -1537,3 +1537,26 @@ async def test_hassjob_forbid_coroutine():
|
||||
|
||||
# To avoid warning about unawaited coro
|
||||
await coro
|
||||
|
||||
|
||||
async def test_reserving_states(hass):
|
||||
"""Test we can reserve a state in the state machine."""
|
||||
|
||||
hass.states.async_reserve("light.bedroom")
|
||||
assert hass.states.async_available("light.bedroom") is False
|
||||
hass.states.async_set("light.bedroom", "on")
|
||||
assert hass.states.async_available("light.bedroom") is False
|
||||
|
||||
with pytest.raises(ha.HomeAssistantError):
|
||||
hass.states.async_reserve("light.bedroom")
|
||||
|
||||
hass.states.async_remove("light.bedroom")
|
||||
assert hass.states.async_available("light.bedroom") is True
|
||||
hass.states.async_set("light.bedroom", "on")
|
||||
|
||||
with pytest.raises(ha.HomeAssistantError):
|
||||
hass.states.async_reserve("light.bedroom")
|
||||
|
||||
assert hass.states.async_available("light.bedroom") is False
|
||||
hass.states.async_remove("light.bedroom")
|
||||
assert hass.states.async_available("light.bedroom") is True
|
||||
Reference in new issue
Block a user