Skip to content

Commit

Permalink
Merge pull request #140 from petretiandrea/fix/l530-color-buggy
Browse files Browse the repository at this point in the history
Fix l530 color buggy
  • Loading branch information
petretiandrea authored Feb 12, 2022
2 parents 25a9274 + 861c4d5 commit 1d49e9d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
2 changes: 1 addition & 1 deletion custom_components/tapo/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
SUPPORTED_DEVICE_AS_SWITCH = ["p100", "p105", "p110"]
SUPPORTED_DEVICE_AS_SWITCH_POWER_MONITOR = ["p110"]
SUPPORTED_DEVICE_AS_LIGHT = {
"l900": SUPPORT_BRIGHTNESS | SUPPORT_COLOR_TEMP | SUPPORT_COLOR,
"l900": SUPPORT_BRIGHTNESS | SUPPORT_COLOR,
"l530": SUPPORT_BRIGHTNESS | SUPPORT_COLOR_TEMP | SUPPORT_COLOR,
"l510": SUPPORT_BRIGHTNESS,
}
Expand Down
8 changes: 7 additions & 1 deletion custom_components/tapo/light.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ def hs_color(self):
@property
def color_temp(self):
color_temp = self._tapo_coordinator.data.color_temp
if color_temp:
if color_temp and color_temp > 0:
return kelvin_to_mired(color_temp)

@property
Expand Down Expand Up @@ -146,6 +146,12 @@ async def _change_color_temp(self, color_temp):

async def _change_color(self, hs_color):
_LOGGER.info(f"Mapped colors: {hs_color}")
# L530 device need to set color_temp to 0 before set hue and saturation.
# When color_temp > 0 the device will ignore any hue and saturation value
if self.supported_features & SUPPORT_COLOR_TEMP:
await self._execute_with_fallback(
lambda: self._tapo_coordinator.api.set_color_temperature(0)
)
await self._execute_with_fallback(
lambda: self._tapo_coordinator.api.set_hue_saturation(
hs_color[0], hs_color[1]
Expand Down

0 comments on commit 1d49e9d

Please sign in to comment.