Use color picker white point.
This commit is contained in:
@@ -325,24 +325,28 @@ class LocaltuyaLight(LocalTuyaEntity, LightEntity):
|
|||||||
if brightness is None:
|
if brightness is None:
|
||||||
brightness = self._brightness
|
brightness = self._brightness
|
||||||
hs = kwargs[ATTR_HS_COLOR]
|
hs = kwargs[ATTR_HS_COLOR]
|
||||||
if self.__is_color_rgb_encoded():
|
if hs[1] == 0 and self.has_config(CONF_BRIGHTNESS):
|
||||||
rgb = color_util.color_hsv_to_RGB(
|
states[self._config.get(CONF_BRIGHTNESS)] = brightness
|
||||||
hs[0], hs[1], int(brightness * 100 / self._upper_brightness)
|
states[self._config.get(CONF_COLOR_MODE)] = MODE_WHITE
|
||||||
)
|
|
||||||
color = "{:02x}{:02x}{:02x}{:04x}{:02x}{:02x}".format(
|
|
||||||
round(rgb[0]),
|
|
||||||
round(rgb[1]),
|
|
||||||
round(rgb[2]),
|
|
||||||
round(hs[0]),
|
|
||||||
round(hs[1] * 255 / 100),
|
|
||||||
brightness,
|
|
||||||
)
|
|
||||||
else:
|
else:
|
||||||
color = "{:04x}{:04x}{:04x}".format(
|
if self.__is_color_rgb_encoded():
|
||||||
round(hs[0]), round(hs[1] * 10.0), brightness
|
rgb = color_util.color_hsv_to_RGB(
|
||||||
)
|
hs[0], hs[1], int(brightness * 100 / self._upper_brightness)
|
||||||
states[self._config.get(CONF_COLOR)] = color
|
)
|
||||||
states[self._config.get(CONF_COLOR_MODE)] = MODE_COLOR
|
color = "{:02x}{:02x}{:02x}{:04x}{:02x}{:02x}".format(
|
||||||
|
round(rgb[0]),
|
||||||
|
round(rgb[1]),
|
||||||
|
round(rgb[2]),
|
||||||
|
round(hs[0]),
|
||||||
|
round(hs[1] * 255 / 100),
|
||||||
|
brightness,
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
color = "{:04x}{:04x}{:04x}".format(
|
||||||
|
round(hs[0]), round(hs[1] * 10.0), brightness
|
||||||
|
)
|
||||||
|
states[self._config.get(CONF_COLOR)] = color
|
||||||
|
states[self._config.get(CONF_COLOR_MODE)] = MODE_COLOR
|
||||||
|
|
||||||
if ATTR_COLOR_TEMP in kwargs and (features & SUPPORT_COLOR_TEMP):
|
if ATTR_COLOR_TEMP in kwargs and (features & SUPPORT_COLOR_TEMP):
|
||||||
if brightness is None:
|
if brightness is None:
|
||||||
@@ -366,10 +370,10 @@ class LocaltuyaLight(LocalTuyaEntity, LightEntity):
|
|||||||
self._state = self.dps(self._dp_id)
|
self._state = self.dps(self._dp_id)
|
||||||
supported = self.supported_features
|
supported = self.supported_features
|
||||||
self._effect = None
|
self._effect = None
|
||||||
if supported & SUPPORT_BRIGHTNESS:
|
if supported & SUPPORT_BRIGHTNESS and self.has_config(CONF_BRIGHTNESS):
|
||||||
self._brightness = self.dps_conf(CONF_BRIGHTNESS)
|
self._brightness = self.dps_conf(CONF_BRIGHTNESS)
|
||||||
|
|
||||||
if supported & SUPPORT_COLOR:
|
if supported & SUPPORT_COLOR and self.has_config(CONF_COLOR):
|
||||||
color = self.dps_conf(CONF_COLOR)
|
color = self.dps_conf(CONF_COLOR)
|
||||||
if color is not None and not self.is_white_mode:
|
if color is not None and not self.is_white_mode:
|
||||||
if self.__is_color_rgb_encoded():
|
if self.__is_color_rgb_encoded():
|
||||||
|
Reference in New Issue
Block a user