mirror of
https://github.com/home-assistant/core.git
synced 2025-07-22 20:57:21 +00:00
Fix parameters when toggling light (#44950)
This commit is contained in:
parent
b85efd343f
commit
2d9eb25142
@ -232,7 +232,7 @@ async def async_setup(hass, config):
|
|||||||
async def async_handle_toggle_service(light, call):
|
async def async_handle_toggle_service(light, call):
|
||||||
"""Handle toggling a light."""
|
"""Handle toggling a light."""
|
||||||
if light.is_on:
|
if light.is_on:
|
||||||
off_params = filter_turn_off_params(call.data)
|
off_params = filter_turn_off_params(call.data["params"])
|
||||||
await light.async_turn_off(**off_params)
|
await light.async_turn_off(**off_params)
|
||||||
else:
|
else:
|
||||||
await async_handle_light_on_service(light, call)
|
await async_handle_light_on_service(light, call)
|
||||||
|
@ -336,6 +336,21 @@ async def test_services(hass, mock_light_profiles):
|
|||||||
light.ATTR_TRANSITION: prof_t,
|
light.ATTR_TRANSITION: prof_t,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
await hass.services.async_call(
|
||||||
|
light.DOMAIN,
|
||||||
|
SERVICE_TOGGLE,
|
||||||
|
{
|
||||||
|
ATTR_ENTITY_ID: ent3.entity_id,
|
||||||
|
light.ATTR_TRANSITION: 4,
|
||||||
|
},
|
||||||
|
blocking=True,
|
||||||
|
)
|
||||||
|
|
||||||
|
_, data = ent3.last_call("turn_off")
|
||||||
|
assert data == {
|
||||||
|
light.ATTR_TRANSITION: 4,
|
||||||
|
}
|
||||||
|
|
||||||
# Test bad data
|
# Test bad data
|
||||||
await hass.services.async_call(
|
await hass.services.async_call(
|
||||||
light.DOMAIN, SERVICE_TURN_ON, {ATTR_ENTITY_ID: ENTITY_MATCH_ALL}, blocking=True
|
light.DOMAIN, SERVICE_TURN_ON, {ATTR_ENTITY_ID: ENTITY_MATCH_ALL}, blocking=True
|
||||||
|
Loading…
x
Reference in New Issue
Block a user