Fix tplink bug changing color temp on bulbs with light effects (#121696)

This commit is contained in:
Steven B 2024-07-11 16:10:47 +01:00 committed by GitHub
parent c40a9ac4b5
commit 2148cfc899
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 5 additions and 5 deletions

View File

@ -392,11 +392,11 @@ class TPLinkLightEffectEntity(TPLinkLightEntity):
kwargs[ATTR_EFFECT], brightness=brightness, transition=transition kwargs[ATTR_EFFECT], brightness=brightness, transition=transition
) )
elif ATTR_COLOR_TEMP_KELVIN in kwargs: elif ATTR_COLOR_TEMP_KELVIN in kwargs:
if self.effect: if self.effect and self.effect != EFFECT_OFF:
# If there is an effect in progress # If there is an effect in progress
# we have to clear the effect # we have to clear the effect
# before we can set a color temp # before we can set a color temp
await self._light_module.set_hsv(0, 0, brightness) await self._effect_module.set_effect(LightEffect.LIGHT_EFFECTS_OFF)
await self._async_set_color_temp( await self._async_set_color_temp(
kwargs[ATTR_COLOR_TEMP_KELVIN], brightness, transition kwargs[ATTR_COLOR_TEMP_KELVIN], brightness, transition
) )

View File

@ -533,16 +533,16 @@ async def test_smart_strip_effects(hass: HomeAssistant) -> None:
assert state.attributes[ATTR_EFFECT_LIST] == ["Off", "Effect1", "Effect2"] assert state.attributes[ATTR_EFFECT_LIST] == ["Off", "Effect1", "Effect2"]
# Ensure setting color temp when an effect # Ensure setting color temp when an effect
# is in progress calls set_hsv to clear the effect # is in progress calls set_effect to clear the effect
await hass.services.async_call( await hass.services.async_call(
LIGHT_DOMAIN, LIGHT_DOMAIN,
"turn_on", "turn_on",
{ATTR_ENTITY_ID: entity_id, ATTR_COLOR_TEMP_KELVIN: 4000}, {ATTR_ENTITY_ID: entity_id, ATTR_COLOR_TEMP_KELVIN: 4000},
blocking=True, blocking=True,
) )
light.set_hsv.assert_called_once_with(0, 0, None) light_effect.set_effect.assert_called_once_with(LightEffect.LIGHT_EFFECTS_OFF)
light.set_color_temp.assert_called_once_with(4000, brightness=None, transition=None) light.set_color_temp.assert_called_once_with(4000, brightness=None, transition=None)
light.set_hsv.reset_mock() light_effect.set_effect.reset_mock()
light.set_color_temp.reset_mock() light.set_color_temp.reset_mock()
await hass.services.async_call( await hass.services.async_call(