deCONZ - Don't send off signals to light if already off (#36357)

This commit is contained in:
Robert Svensson 2020-06-02 00:20:52 +02:00 committed by GitHub
parent 1883b1d2a2
commit a6e9a312a3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 23 additions and 0 deletions

View file

@ -186,6 +186,9 @@ class DeconzLight(DeconzDevice, LightEntity):
async def async_turn_off(self, **kwargs): async def async_turn_off(self, **kwargs):
"""Turn off light.""" """Turn off light."""
if not self._device.state:
return
data = {"on": False} data = {"on": False}
if ATTR_TRANSITION in kwargs: if ATTR_TRANSITION in kwargs:

View file

@ -189,6 +189,26 @@ async def test_lights_and_groups(hass):
json={"xy": (0.411, 0.351), "alert": "lselect", "effect": "none"}, 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: with patch.object(rgb_light_device, "_request", return_value=True) as set_callback:
await hass.services.async_call( await hass.services.async_call(
light.DOMAIN, light.DOMAIN,