diff --git a/homeassistant/components/light/__init__.py b/homeassistant/components/light/__init__.py index fdef5e61a76..f406366dc86 100644 --- a/homeassistant/components/light/__init__.py +++ b/homeassistant/components/light/__init__.py @@ -232,7 +232,7 @@ async def async_setup(hass, config): async def async_handle_toggle_service(light, call): """Handle toggling a light.""" 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) else: await async_handle_light_on_service(light, call) diff --git a/tests/components/light/test_init.py b/tests/components/light/test_init.py index afc125e6423..72674a984fd 100644 --- a/tests/components/light/test_init.py +++ b/tests/components/light/test_init.py @@ -336,6 +336,21 @@ async def test_services(hass, mock_light_profiles): 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 await hass.services.async_call( light.DOMAIN, SERVICE_TURN_ON, {ATTR_ENTITY_ID: ENTITY_MATCH_ALL}, blocking=True