mirror of
https://github.com/home-assistant/core.git
synced 2025-07-15 09:17:10 +00:00
Prefer effect over other light settings for tplink (#85642)
This commit is contained in:
parent
c54500cb1f
commit
5335dfbc67
@ -337,7 +337,12 @@ class TPLinkSmartLightStrip(TPLinkSmartBulb):
|
|||||||
async def async_turn_on(self, **kwargs: Any) -> None:
|
async def async_turn_on(self, **kwargs: Any) -> None:
|
||||||
"""Turn the light on."""
|
"""Turn the light on."""
|
||||||
brightness, transition = self._async_extract_brightness_transition(**kwargs)
|
brightness, transition = self._async_extract_brightness_transition(**kwargs)
|
||||||
if ATTR_COLOR_TEMP in kwargs:
|
if ATTR_EFFECT in kwargs:
|
||||||
|
await self.device.set_effect(kwargs[ATTR_EFFECT])
|
||||||
|
# We need to set the brightness separately until upstream allows defining it for set_effect.
|
||||||
|
if brightness is not None:
|
||||||
|
await self._async_turn_on_with_brightness(brightness, transition)
|
||||||
|
elif ATTR_COLOR_TEMP in kwargs:
|
||||||
if self.effect:
|
if self.effect:
|
||||||
# If there is an effect in progress
|
# If there is an effect in progress
|
||||||
# we have to set an HSV value to clear the effect
|
# we have to set an HSV value to clear the effect
|
||||||
@ -348,8 +353,6 @@ class TPLinkSmartLightStrip(TPLinkSmartBulb):
|
|||||||
)
|
)
|
||||||
elif ATTR_HS_COLOR in kwargs:
|
elif ATTR_HS_COLOR in kwargs:
|
||||||
await self._async_set_hsv(kwargs[ATTR_HS_COLOR], brightness, transition)
|
await self._async_set_hsv(kwargs[ATTR_HS_COLOR], brightness, transition)
|
||||||
elif ATTR_EFFECT in kwargs:
|
|
||||||
await self.device.set_effect(kwargs[ATTR_EFFECT])
|
|
||||||
else:
|
else:
|
||||||
await self._async_turn_on_with_brightness(brightness, transition)
|
await self._async_turn_on_with_brightness(brightness, transition)
|
||||||
|
|
||||||
|
@ -434,6 +434,19 @@ async def test_smart_strip_effects(hass: HomeAssistant) -> None:
|
|||||||
strip.set_effect.assert_called_once_with("Effect2")
|
strip.set_effect.assert_called_once_with("Effect2")
|
||||||
strip.set_effect.reset_mock()
|
strip.set_effect.reset_mock()
|
||||||
|
|
||||||
|
# Setting an effect with brightness calls set_brightness implicitly
|
||||||
|
await hass.services.async_call(
|
||||||
|
LIGHT_DOMAIN,
|
||||||
|
"turn_on",
|
||||||
|
{ATTR_ENTITY_ID: entity_id, ATTR_EFFECT: "Effect2", ATTR_BRIGHTNESS: 255},
|
||||||
|
blocking=True,
|
||||||
|
)
|
||||||
|
strip.set_effect.assert_called_once_with("Effect2")
|
||||||
|
strip.set_effect.reset_mock()
|
||||||
|
|
||||||
|
strip.set_brightness.assert_called_with(100, transition=None)
|
||||||
|
strip.set_brightness.reset_mock()
|
||||||
|
|
||||||
strip.effect = {"name": "Effect1", "enable": 0, "custom": 0}
|
strip.effect = {"name": "Effect1", "enable": 0, "custom": 0}
|
||||||
async_fire_time_changed(hass, dt_util.utcnow() + timedelta(seconds=10))
|
async_fire_time_changed(hass, dt_util.utcnow() + timedelta(seconds=10))
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user