deCONZ - Don't send off signals to light if already off (#36357)
This commit is contained in:
parent
1883b1d2a2
commit
a6e9a312a3
2 changed files with 23 additions and 0 deletions
|
@ -186,6 +186,9 @@ class DeconzLight(DeconzDevice, LightEntity):
|
|||
|
||||
async def async_turn_off(self, **kwargs):
|
||||
"""Turn off light."""
|
||||
if not self._device.state:
|
||||
return
|
||||
|
||||
data = {"on": False}
|
||||
|
||||
if ATTR_TRANSITION in kwargs:
|
||||
|
|
|
@ -189,6 +189,26 @@ async def test_lights_and_groups(hass):
|
|||
json={"xy": (0.411, 0.351), "alert": "lselect", "effect": "none"},
|
||||
)
|
||||
|
||||
with patch.object(rgb_light_device, "_request", return_value=True) as set_callback:
|
||||
await hass.services.async_call(
|
||||
light.DOMAIN,
|
||||
light.SERVICE_TURN_OFF,
|
||||
{"entity_id": "light.rgb_light", "transition": 5, "flash": "short"},
|
||||
blocking=True,
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
assert not set_callback.called
|
||||
|
||||
state_changed_event = {
|
||||
"t": "event",
|
||||
"e": "changed",
|
||||
"r": "lights",
|
||||
"id": "1",
|
||||
"state": {"on": True},
|
||||
}
|
||||
gateway.api.event_handler(state_changed_event)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
with patch.object(rgb_light_device, "_request", return_value=True) as set_callback:
|
||||
await hass.services.async_call(
|
||||
light.DOMAIN,
|
||||
|
|
Loading…
Add table
Reference in a new issue