From 70aa58913daee2f3973437bdd2de1a5f51e3e8f5 Mon Sep 17 00:00:00 2001 From: Ariel Ebersberger <31776703+justanotherariel@users.noreply.github.com> Date: Thu, 26 Mar 2026 19:52:37 +0100 Subject: [PATCH] Modernize demo/switch to async (#166619) --- homeassistant/components/demo/switch.py | 10 +++++----- tests/components/switch/test_light.py | 2 ++ tests/components/switch_as_x/test_cover.py | 12 ++++++++++++ tests/components/switch_as_x/test_fan.py | 12 ++++++++++++ tests/components/switch_as_x/test_light.py | 10 ++++++++++ tests/components/switch_as_x/test_lock.py | 10 ++++++++++ tests/components/switch_as_x/test_siren.py | 12 ++++++++++++ tests/components/switch_as_x/test_valve.py | 12 ++++++++++++ 8 files changed, 75 insertions(+), 5 deletions(-) diff --git a/homeassistant/components/demo/switch.py b/homeassistant/components/demo/switch.py index dd288f285af..214f64e8a49 100644 --- a/homeassistant/components/demo/switch.py +++ b/homeassistant/components/demo/switch.py @@ -61,12 +61,12 @@ class DemoSwitch(SwitchEntity): name=device_name, ) - def turn_on(self, **kwargs: Any) -> None: + async def async_turn_on(self, **kwargs: Any) -> None: """Turn the switch on.""" self._attr_is_on = True - self.schedule_update_ha_state() + self.async_write_ha_state() - def turn_off(self, **kwargs: Any) -> None: - """Turn the device off.""" + async def async_turn_off(self, **kwargs: Any) -> None: + """Turn the switch off.""" self._attr_is_on = False - self.schedule_update_ha_state() + self.async_write_ha_state() diff --git a/tests/components/switch/test_light.py b/tests/components/switch/test_light.py index e7681575ce4..4387151ce34 100644 --- a/tests/components/switch/test_light.py +++ b/tests/components/switch/test_light.py @@ -62,11 +62,13 @@ async def test_light_service_calls(hass: HomeAssistant) -> None: assert hass.states.get("light.light_switch").state == "on" await common.async_toggle(hass, "light.light_switch") + await hass.async_block_till_done() assert hass.states.get("switch.decorative_lights").state == "off" assert hass.states.get("light.light_switch").state == "off" await common.async_turn_on(hass, "light.light_switch") + await hass.async_block_till_done() assert hass.states.get("switch.decorative_lights").state == "on" assert hass.states.get("light.light_switch").state == "on" diff --git a/tests/components/switch_as_x/test_cover.py b/tests/components/switch_as_x/test_cover.py index acb382a635a..5808489a1a9 100644 --- a/tests/components/switch_as_x/test_cover.py +++ b/tests/components/switch_as_x/test_cover.py @@ -77,6 +77,7 @@ async def test_service_calls(hass: HomeAssistant) -> None: {CONF_ENTITY_ID: "cover.decorative_lights"}, blocking=True, ) + await hass.async_block_till_done() assert hass.states.get("switch.decorative_lights").state == STATE_OFF assert hass.states.get("cover.decorative_lights").state == CoverState.CLOSED @@ -87,6 +88,7 @@ async def test_service_calls(hass: HomeAssistant) -> None: {CONF_ENTITY_ID: "cover.decorative_lights"}, blocking=True, ) + await hass.async_block_till_done() assert hass.states.get("switch.decorative_lights").state == STATE_ON assert hass.states.get("cover.decorative_lights").state == CoverState.OPEN @@ -97,6 +99,7 @@ async def test_service_calls(hass: HomeAssistant) -> None: {CONF_ENTITY_ID: "cover.decorative_lights"}, blocking=True, ) + await hass.async_block_till_done() assert hass.states.get("switch.decorative_lights").state == STATE_OFF assert hass.states.get("cover.decorative_lights").state == CoverState.CLOSED @@ -107,6 +110,7 @@ async def test_service_calls(hass: HomeAssistant) -> None: {CONF_ENTITY_ID: "switch.decorative_lights"}, blocking=True, ) + await hass.async_block_till_done() assert hass.states.get("switch.decorative_lights").state == STATE_ON assert hass.states.get("cover.decorative_lights").state == CoverState.OPEN @@ -117,6 +121,7 @@ async def test_service_calls(hass: HomeAssistant) -> None: {CONF_ENTITY_ID: "switch.decorative_lights"}, blocking=True, ) + await hass.async_block_till_done() assert hass.states.get("switch.decorative_lights").state == STATE_OFF assert hass.states.get("cover.decorative_lights").state == CoverState.CLOSED @@ -127,6 +132,7 @@ async def test_service_calls(hass: HomeAssistant) -> None: {CONF_ENTITY_ID: "switch.decorative_lights"}, blocking=True, ) + await hass.async_block_till_done() assert hass.states.get("switch.decorative_lights").state == STATE_ON assert hass.states.get("cover.decorative_lights").state == CoverState.OPEN @@ -160,6 +166,7 @@ async def test_service_calls_inverted(hass: HomeAssistant) -> None: {CONF_ENTITY_ID: "cover.decorative_lights"}, blocking=True, ) + await hass.async_block_till_done() assert hass.states.get("switch.decorative_lights").state == STATE_OFF assert hass.states.get("cover.decorative_lights").state == CoverState.OPEN @@ -170,6 +177,7 @@ async def test_service_calls_inverted(hass: HomeAssistant) -> None: {CONF_ENTITY_ID: "cover.decorative_lights"}, blocking=True, ) + await hass.async_block_till_done() assert hass.states.get("switch.decorative_lights").state == STATE_OFF assert hass.states.get("cover.decorative_lights").state == CoverState.OPEN @@ -180,6 +188,7 @@ async def test_service_calls_inverted(hass: HomeAssistant) -> None: {CONF_ENTITY_ID: "cover.decorative_lights"}, blocking=True, ) + await hass.async_block_till_done() assert hass.states.get("switch.decorative_lights").state == STATE_ON assert hass.states.get("cover.decorative_lights").state == CoverState.CLOSED @@ -190,6 +199,7 @@ async def test_service_calls_inverted(hass: HomeAssistant) -> None: {CONF_ENTITY_ID: "switch.decorative_lights"}, blocking=True, ) + await hass.async_block_till_done() assert hass.states.get("switch.decorative_lights").state == STATE_ON assert hass.states.get("cover.decorative_lights").state == CoverState.CLOSED @@ -200,6 +210,7 @@ async def test_service_calls_inverted(hass: HomeAssistant) -> None: {CONF_ENTITY_ID: "switch.decorative_lights"}, blocking=True, ) + await hass.async_block_till_done() assert hass.states.get("switch.decorative_lights").state == STATE_OFF assert hass.states.get("cover.decorative_lights").state == CoverState.OPEN @@ -210,6 +221,7 @@ async def test_service_calls_inverted(hass: HomeAssistant) -> None: {CONF_ENTITY_ID: "switch.decorative_lights"}, blocking=True, ) + await hass.async_block_till_done() assert hass.states.get("switch.decorative_lights").state == STATE_ON assert hass.states.get("cover.decorative_lights").state == CoverState.CLOSED diff --git a/tests/components/switch_as_x/test_fan.py b/tests/components/switch_as_x/test_fan.py index a33490dab45..1b872f3dc22 100644 --- a/tests/components/switch_as_x/test_fan.py +++ b/tests/components/switch_as_x/test_fan.py @@ -75,6 +75,7 @@ async def test_service_calls(hass: HomeAssistant) -> None: {CONF_ENTITY_ID: "fan.decorative_lights"}, blocking=True, ) + await hass.async_block_till_done() assert hass.states.get("switch.decorative_lights").state == STATE_OFF assert hass.states.get("fan.decorative_lights").state == STATE_OFF @@ -85,6 +86,7 @@ async def test_service_calls(hass: HomeAssistant) -> None: {CONF_ENTITY_ID: "fan.decorative_lights"}, blocking=True, ) + await hass.async_block_till_done() assert hass.states.get("switch.decorative_lights").state == STATE_ON assert hass.states.get("fan.decorative_lights").state == STATE_ON @@ -95,6 +97,7 @@ async def test_service_calls(hass: HomeAssistant) -> None: {CONF_ENTITY_ID: "fan.decorative_lights"}, blocking=True, ) + await hass.async_block_till_done() assert hass.states.get("switch.decorative_lights").state == STATE_OFF assert hass.states.get("fan.decorative_lights").state == STATE_OFF @@ -105,6 +108,7 @@ async def test_service_calls(hass: HomeAssistant) -> None: {CONF_ENTITY_ID: "switch.decorative_lights"}, blocking=True, ) + await hass.async_block_till_done() assert hass.states.get("switch.decorative_lights").state == STATE_ON assert hass.states.get("fan.decorative_lights").state == STATE_ON @@ -115,6 +119,7 @@ async def test_service_calls(hass: HomeAssistant) -> None: {CONF_ENTITY_ID: "switch.decorative_lights"}, blocking=True, ) + await hass.async_block_till_done() assert hass.states.get("switch.decorative_lights").state == STATE_OFF assert hass.states.get("fan.decorative_lights").state == STATE_OFF @@ -125,6 +130,7 @@ async def test_service_calls(hass: HomeAssistant) -> None: {CONF_ENTITY_ID: "switch.decorative_lights"}, blocking=True, ) + await hass.async_block_till_done() assert hass.states.get("switch.decorative_lights").state == STATE_ON assert hass.states.get("fan.decorative_lights").state == STATE_ON @@ -158,6 +164,7 @@ async def test_service_calls_inverted(hass: HomeAssistant) -> None: {CONF_ENTITY_ID: "fan.decorative_lights"}, blocking=True, ) + await hass.async_block_till_done() assert hass.states.get("switch.decorative_lights").state == STATE_OFF assert hass.states.get("fan.decorative_lights").state == STATE_OFF @@ -168,6 +175,7 @@ async def test_service_calls_inverted(hass: HomeAssistant) -> None: {CONF_ENTITY_ID: "fan.decorative_lights"}, blocking=True, ) + await hass.async_block_till_done() assert hass.states.get("switch.decorative_lights").state == STATE_ON assert hass.states.get("fan.decorative_lights").state == STATE_ON @@ -178,6 +186,7 @@ async def test_service_calls_inverted(hass: HomeAssistant) -> None: {CONF_ENTITY_ID: "fan.decorative_lights"}, blocking=True, ) + await hass.async_block_till_done() assert hass.states.get("switch.decorative_lights").state == STATE_OFF assert hass.states.get("fan.decorative_lights").state == STATE_OFF @@ -188,6 +197,7 @@ async def test_service_calls_inverted(hass: HomeAssistant) -> None: {CONF_ENTITY_ID: "switch.decorative_lights"}, blocking=True, ) + await hass.async_block_till_done() assert hass.states.get("switch.decorative_lights").state == STATE_ON assert hass.states.get("fan.decorative_lights").state == STATE_ON @@ -198,6 +208,7 @@ async def test_service_calls_inverted(hass: HomeAssistant) -> None: {CONF_ENTITY_ID: "switch.decorative_lights"}, blocking=True, ) + await hass.async_block_till_done() assert hass.states.get("switch.decorative_lights").state == STATE_OFF assert hass.states.get("fan.decorative_lights").state == STATE_OFF @@ -208,6 +219,7 @@ async def test_service_calls_inverted(hass: HomeAssistant) -> None: {CONF_ENTITY_ID: "switch.decorative_lights"}, blocking=True, ) + await hass.async_block_till_done() assert hass.states.get("switch.decorative_lights").state == STATE_ON assert hass.states.get("fan.decorative_lights").state == STATE_ON diff --git a/tests/components/switch_as_x/test_light.py b/tests/components/switch_as_x/test_light.py index 5f724a2d7e7..ba752bd0840 100644 --- a/tests/components/switch_as_x/test_light.py +++ b/tests/components/switch_as_x/test_light.py @@ -92,6 +92,7 @@ async def test_light_service_calls(hass: HomeAssistant) -> None: {CONF_ENTITY_ID: "light.decorative_lights"}, blocking=True, ) + await hass.async_block_till_done() assert hass.states.get("switch.decorative_lights").state == STATE_OFF assert hass.states.get("light.decorative_lights").state == STATE_OFF @@ -102,6 +103,7 @@ async def test_light_service_calls(hass: HomeAssistant) -> None: {CONF_ENTITY_ID: "light.decorative_lights"}, blocking=True, ) + await hass.async_block_till_done() assert hass.states.get("switch.decorative_lights").state == STATE_ON assert hass.states.get("light.decorative_lights").state == STATE_ON @@ -116,6 +118,7 @@ async def test_light_service_calls(hass: HomeAssistant) -> None: {CONF_ENTITY_ID: "light.decorative_lights"}, blocking=True, ) + await hass.async_block_till_done() assert hass.states.get("switch.decorative_lights").state == STATE_OFF assert hass.states.get("light.decorative_lights").state == STATE_OFF @@ -149,6 +152,7 @@ async def test_switch_service_calls(hass: HomeAssistant) -> None: {CONF_ENTITY_ID: "switch.decorative_lights"}, blocking=True, ) + await hass.async_block_till_done() assert hass.states.get("switch.decorative_lights").state == STATE_OFF assert hass.states.get("light.decorative_lights").state == STATE_OFF @@ -159,6 +163,7 @@ async def test_switch_service_calls(hass: HomeAssistant) -> None: {CONF_ENTITY_ID: "switch.decorative_lights"}, blocking=True, ) + await hass.async_block_till_done() assert hass.states.get("switch.decorative_lights").state == STATE_ON assert hass.states.get("light.decorative_lights").state == STATE_ON @@ -192,6 +197,7 @@ async def test_light_service_calls_inverted(hass: HomeAssistant) -> None: {CONF_ENTITY_ID: "light.decorative_lights"}, blocking=True, ) + await hass.async_block_till_done() assert hass.states.get("switch.decorative_lights").state == STATE_OFF assert hass.states.get("light.decorative_lights").state == STATE_OFF @@ -202,6 +208,7 @@ async def test_light_service_calls_inverted(hass: HomeAssistant) -> None: {CONF_ENTITY_ID: "light.decorative_lights"}, blocking=True, ) + await hass.async_block_till_done() assert hass.states.get("switch.decorative_lights").state == STATE_ON assert hass.states.get("light.decorative_lights").state == STATE_ON @@ -216,6 +223,7 @@ async def test_light_service_calls_inverted(hass: HomeAssistant) -> None: {CONF_ENTITY_ID: "light.decorative_lights"}, blocking=True, ) + await hass.async_block_till_done() assert hass.states.get("switch.decorative_lights").state == STATE_OFF assert hass.states.get("light.decorative_lights").state == STATE_OFF @@ -249,6 +257,7 @@ async def test_switch_service_calls_inverted(hass: HomeAssistant) -> None: {CONF_ENTITY_ID: "switch.decorative_lights"}, blocking=True, ) + await hass.async_block_till_done() assert hass.states.get("switch.decorative_lights").state == STATE_OFF assert hass.states.get("light.decorative_lights").state == STATE_OFF @@ -259,6 +268,7 @@ async def test_switch_service_calls_inverted(hass: HomeAssistant) -> None: {CONF_ENTITY_ID: "switch.decorative_lights"}, blocking=True, ) + await hass.async_block_till_done() assert hass.states.get("switch.decorative_lights").state == STATE_ON assert hass.states.get("light.decorative_lights").state == STATE_ON diff --git a/tests/components/switch_as_x/test_lock.py b/tests/components/switch_as_x/test_lock.py index c2a0806778d..0f500c79f93 100644 --- a/tests/components/switch_as_x/test_lock.py +++ b/tests/components/switch_as_x/test_lock.py @@ -76,6 +76,7 @@ async def test_service_calls(hass: HomeAssistant) -> None: {CONF_ENTITY_ID: "lock.decorative_lights"}, blocking=True, ) + await hass.async_block_till_done() assert hass.states.get("switch.decorative_lights").state == STATE_OFF assert hass.states.get("lock.decorative_lights").state == LockState.LOCKED @@ -86,6 +87,7 @@ async def test_service_calls(hass: HomeAssistant) -> None: {CONF_ENTITY_ID: "lock.decorative_lights"}, blocking=True, ) + await hass.async_block_till_done() assert hass.states.get("switch.decorative_lights").state == STATE_ON assert hass.states.get("lock.decorative_lights").state == LockState.UNLOCKED @@ -96,6 +98,7 @@ async def test_service_calls(hass: HomeAssistant) -> None: {CONF_ENTITY_ID: "switch.decorative_lights"}, blocking=True, ) + await hass.async_block_till_done() assert hass.states.get("switch.decorative_lights").state == STATE_OFF assert hass.states.get("lock.decorative_lights").state == LockState.LOCKED @@ -106,6 +109,7 @@ async def test_service_calls(hass: HomeAssistant) -> None: {CONF_ENTITY_ID: "switch.decorative_lights"}, blocking=True, ) + await hass.async_block_till_done() assert hass.states.get("switch.decorative_lights").state == STATE_ON assert hass.states.get("lock.decorative_lights").state == LockState.UNLOCKED @@ -116,6 +120,7 @@ async def test_service_calls(hass: HomeAssistant) -> None: {CONF_ENTITY_ID: "switch.decorative_lights"}, blocking=True, ) + await hass.async_block_till_done() assert hass.states.get("switch.decorative_lights").state == STATE_OFF assert hass.states.get("lock.decorative_lights").state == LockState.LOCKED @@ -149,6 +154,7 @@ async def test_service_calls_inverted(hass: HomeAssistant) -> None: {CONF_ENTITY_ID: "lock.decorative_lights"}, blocking=True, ) + await hass.async_block_till_done() assert hass.states.get("switch.decorative_lights").state == STATE_ON assert hass.states.get("lock.decorative_lights").state == LockState.LOCKED @@ -159,6 +165,7 @@ async def test_service_calls_inverted(hass: HomeAssistant) -> None: {CONF_ENTITY_ID: "lock.decorative_lights"}, blocking=True, ) + await hass.async_block_till_done() assert hass.states.get("switch.decorative_lights").state == STATE_OFF assert hass.states.get("lock.decorative_lights").state == LockState.UNLOCKED @@ -169,6 +176,7 @@ async def test_service_calls_inverted(hass: HomeAssistant) -> None: {CONF_ENTITY_ID: "switch.decorative_lights"}, blocking=True, ) + await hass.async_block_till_done() assert hass.states.get("switch.decorative_lights").state == STATE_OFF assert hass.states.get("lock.decorative_lights").state == LockState.UNLOCKED @@ -179,6 +187,7 @@ async def test_service_calls_inverted(hass: HomeAssistant) -> None: {CONF_ENTITY_ID: "switch.decorative_lights"}, blocking=True, ) + await hass.async_block_till_done() assert hass.states.get("switch.decorative_lights").state == STATE_ON assert hass.states.get("lock.decorative_lights").state == LockState.LOCKED @@ -189,6 +198,7 @@ async def test_service_calls_inverted(hass: HomeAssistant) -> None: {CONF_ENTITY_ID: "switch.decorative_lights"}, blocking=True, ) + await hass.async_block_till_done() assert hass.states.get("switch.decorative_lights").state == STATE_OFF assert hass.states.get("lock.decorative_lights").state == LockState.UNLOCKED diff --git a/tests/components/switch_as_x/test_siren.py b/tests/components/switch_as_x/test_siren.py index 83daa862830..0b66f07cf60 100644 --- a/tests/components/switch_as_x/test_siren.py +++ b/tests/components/switch_as_x/test_siren.py @@ -75,6 +75,7 @@ async def test_service_calls(hass: HomeAssistant) -> None: {CONF_ENTITY_ID: "siren.decorative_lights"}, blocking=True, ) + await hass.async_block_till_done() assert hass.states.get("switch.decorative_lights").state == STATE_OFF assert hass.states.get("siren.decorative_lights").state == STATE_OFF @@ -85,6 +86,7 @@ async def test_service_calls(hass: HomeAssistant) -> None: {CONF_ENTITY_ID: "siren.decorative_lights"}, blocking=True, ) + await hass.async_block_till_done() assert hass.states.get("switch.decorative_lights").state == STATE_ON assert hass.states.get("siren.decorative_lights").state == STATE_ON @@ -95,6 +97,7 @@ async def test_service_calls(hass: HomeAssistant) -> None: {CONF_ENTITY_ID: "siren.decorative_lights"}, blocking=True, ) + await hass.async_block_till_done() assert hass.states.get("switch.decorative_lights").state == STATE_OFF assert hass.states.get("siren.decorative_lights").state == STATE_OFF @@ -105,6 +108,7 @@ async def test_service_calls(hass: HomeAssistant) -> None: {CONF_ENTITY_ID: "switch.decorative_lights"}, blocking=True, ) + await hass.async_block_till_done() assert hass.states.get("switch.decorative_lights").state == STATE_ON assert hass.states.get("siren.decorative_lights").state == STATE_ON @@ -115,6 +119,7 @@ async def test_service_calls(hass: HomeAssistant) -> None: {CONF_ENTITY_ID: "switch.decorative_lights"}, blocking=True, ) + await hass.async_block_till_done() assert hass.states.get("switch.decorative_lights").state == STATE_OFF assert hass.states.get("siren.decorative_lights").state == STATE_OFF @@ -125,6 +130,7 @@ async def test_service_calls(hass: HomeAssistant) -> None: {CONF_ENTITY_ID: "switch.decorative_lights"}, blocking=True, ) + await hass.async_block_till_done() assert hass.states.get("switch.decorative_lights").state == STATE_ON assert hass.states.get("siren.decorative_lights").state == STATE_ON @@ -158,6 +164,7 @@ async def test_service_calls_inverted(hass: HomeAssistant) -> None: {CONF_ENTITY_ID: "siren.decorative_lights"}, blocking=True, ) + await hass.async_block_till_done() assert hass.states.get("switch.decorative_lights").state == STATE_OFF assert hass.states.get("siren.decorative_lights").state == STATE_OFF @@ -168,6 +175,7 @@ async def test_service_calls_inverted(hass: HomeAssistant) -> None: {CONF_ENTITY_ID: "siren.decorative_lights"}, blocking=True, ) + await hass.async_block_till_done() assert hass.states.get("switch.decorative_lights").state == STATE_ON assert hass.states.get("siren.decorative_lights").state == STATE_ON @@ -178,6 +186,7 @@ async def test_service_calls_inverted(hass: HomeAssistant) -> None: {CONF_ENTITY_ID: "siren.decorative_lights"}, blocking=True, ) + await hass.async_block_till_done() assert hass.states.get("switch.decorative_lights").state == STATE_OFF assert hass.states.get("siren.decorative_lights").state == STATE_OFF @@ -188,6 +197,7 @@ async def test_service_calls_inverted(hass: HomeAssistant) -> None: {CONF_ENTITY_ID: "switch.decorative_lights"}, blocking=True, ) + await hass.async_block_till_done() assert hass.states.get("switch.decorative_lights").state == STATE_ON assert hass.states.get("siren.decorative_lights").state == STATE_ON @@ -198,6 +208,7 @@ async def test_service_calls_inverted(hass: HomeAssistant) -> None: {CONF_ENTITY_ID: "switch.decorative_lights"}, blocking=True, ) + await hass.async_block_till_done() assert hass.states.get("switch.decorative_lights").state == STATE_OFF assert hass.states.get("siren.decorative_lights").state == STATE_OFF @@ -208,6 +219,7 @@ async def test_service_calls_inverted(hass: HomeAssistant) -> None: {CONF_ENTITY_ID: "switch.decorative_lights"}, blocking=True, ) + await hass.async_block_till_done() assert hass.states.get("switch.decorative_lights").state == STATE_ON assert hass.states.get("siren.decorative_lights").state == STATE_ON diff --git a/tests/components/switch_as_x/test_valve.py b/tests/components/switch_as_x/test_valve.py index 6f6ef719ae1..30ce9fc5bd0 100644 --- a/tests/components/switch_as_x/test_valve.py +++ b/tests/components/switch_as_x/test_valve.py @@ -77,6 +77,7 @@ async def test_service_calls(hass: HomeAssistant) -> None: {CONF_ENTITY_ID: "valve.decorative_lights"}, blocking=True, ) + await hass.async_block_till_done() assert hass.states.get("switch.decorative_lights").state == STATE_OFF assert hass.states.get("valve.decorative_lights").state == ValveState.CLOSED @@ -87,6 +88,7 @@ async def test_service_calls(hass: HomeAssistant) -> None: {CONF_ENTITY_ID: "valve.decorative_lights"}, blocking=True, ) + await hass.async_block_till_done() assert hass.states.get("switch.decorative_lights").state == STATE_ON assert hass.states.get("valve.decorative_lights").state == ValveState.OPEN @@ -97,6 +99,7 @@ async def test_service_calls(hass: HomeAssistant) -> None: {CONF_ENTITY_ID: "valve.decorative_lights"}, blocking=True, ) + await hass.async_block_till_done() assert hass.states.get("switch.decorative_lights").state == STATE_OFF assert hass.states.get("valve.decorative_lights").state == ValveState.CLOSED @@ -107,6 +110,7 @@ async def test_service_calls(hass: HomeAssistant) -> None: {CONF_ENTITY_ID: "switch.decorative_lights"}, blocking=True, ) + await hass.async_block_till_done() assert hass.states.get("switch.decorative_lights").state == STATE_ON assert hass.states.get("valve.decorative_lights").state == ValveState.OPEN @@ -117,6 +121,7 @@ async def test_service_calls(hass: HomeAssistant) -> None: {CONF_ENTITY_ID: "switch.decorative_lights"}, blocking=True, ) + await hass.async_block_till_done() assert hass.states.get("switch.decorative_lights").state == STATE_OFF assert hass.states.get("valve.decorative_lights").state == ValveState.CLOSED @@ -127,6 +132,7 @@ async def test_service_calls(hass: HomeAssistant) -> None: {CONF_ENTITY_ID: "switch.decorative_lights"}, blocking=True, ) + await hass.async_block_till_done() assert hass.states.get("switch.decorative_lights").state == STATE_ON assert hass.states.get("valve.decorative_lights").state == ValveState.OPEN @@ -160,6 +166,7 @@ async def test_service_calls_inverted(hass: HomeAssistant) -> None: {CONF_ENTITY_ID: "valve.decorative_lights"}, blocking=True, ) + await hass.async_block_till_done() assert hass.states.get("switch.decorative_lights").state == STATE_OFF assert hass.states.get("valve.decorative_lights").state == ValveState.OPEN @@ -170,6 +177,7 @@ async def test_service_calls_inverted(hass: HomeAssistant) -> None: {CONF_ENTITY_ID: "valve.decorative_lights"}, blocking=True, ) + await hass.async_block_till_done() assert hass.states.get("switch.decorative_lights").state == STATE_OFF assert hass.states.get("valve.decorative_lights").state == ValveState.OPEN @@ -180,6 +188,7 @@ async def test_service_calls_inverted(hass: HomeAssistant) -> None: {CONF_ENTITY_ID: "valve.decorative_lights"}, blocking=True, ) + await hass.async_block_till_done() assert hass.states.get("switch.decorative_lights").state == STATE_ON assert hass.states.get("valve.decorative_lights").state == ValveState.CLOSED @@ -190,6 +199,7 @@ async def test_service_calls_inverted(hass: HomeAssistant) -> None: {CONF_ENTITY_ID: "switch.decorative_lights"}, blocking=True, ) + await hass.async_block_till_done() assert hass.states.get("switch.decorative_lights").state == STATE_ON assert hass.states.get("valve.decorative_lights").state == ValveState.CLOSED @@ -200,6 +210,7 @@ async def test_service_calls_inverted(hass: HomeAssistant) -> None: {CONF_ENTITY_ID: "switch.decorative_lights"}, blocking=True, ) + await hass.async_block_till_done() assert hass.states.get("switch.decorative_lights").state == STATE_OFF assert hass.states.get("valve.decorative_lights").state == ValveState.OPEN @@ -210,6 +221,7 @@ async def test_service_calls_inverted(hass: HomeAssistant) -> None: {CONF_ENTITY_ID: "switch.decorative_lights"}, blocking=True, ) + await hass.async_block_till_done() assert hass.states.get("switch.decorative_lights").state == STATE_ON assert hass.states.get("valve.decorative_lights").state == ValveState.CLOSED