mirror of
https://github.com/home-assistant/core.git
synced 2025-12-27 14:31:13 +00:00
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:
@@ -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