Skip to content

Commit

Permalink
fix(light): Adjust brightness for encoded RGB bulbs #504
Browse files Browse the repository at this point in the history
  • Loading branch information
xZetsubou authored Jan 22, 2025
1 parent 6f61fd0 commit 28f8712
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions custom_components/localtuya/light.py
Original file line number Diff line number Diff line change
Expand Up @@ -528,7 +528,7 @@ def __from_color_common(self, color):
hue = int(color[6:10], 16)
sat = int(color[10:12], 16)
value = int(color[12:14], 16)
self._hs = [hue, sat]
self._hs = [hue, (sat * 100 / 255)]
self._brightness = value
else:
self.__from_color_v2(color)
Expand Down Expand Up @@ -564,10 +564,10 @@ async def async_turn_on(self, **kwargs):
or self.has_config(CONF_BRIGHTNESS)
or self.has_config(CONF_COLOR)
):

brightness = map_value_by_percent(
int(kwargs[ATTR_BRIGHTNESS]), 255, self._upper_brightness
)
brightness = max(brightness, self._lower_brightness)

if self.is_color_mode and self._hs is not None:
states[self._config.get(CONF_COLOR)] = self.__to_color(
Expand Down

0 comments on commit 28f8712

Please sign in to comment.