1
0
mirror of https://github.com/home-assistant/core.git synced 2026-04-02 00:20:30 +01:00

Modernize demo/switch to async (#166619)

This commit is contained in:
Ariel Ebersberger
2026-03-26 19:52:37 +01:00
committed by GitHub
parent cc363e4ebd
commit 70aa58913d
8 changed files with 75 additions and 5 deletions

View File

@@ -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()

View File

@@ -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"

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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