diff --git a/custom_components/localtuya/light.py b/custom_components/localtuya/light.py index 8818060b8..f64496930 100644 --- a/custom_components/localtuya/light.py +++ b/custom_components/localtuya/light.py @@ -11,6 +11,7 @@ from homeassistant.components.light import ( ATTR_BRIGHTNESS, ATTR_COLOR_TEMP, + ATTR_WHITE, ATTR_EFFECT, ATTR_HS_COLOR, DOMAIN, @@ -298,10 +299,15 @@ def supported_color_modes(self) -> set[ColorMode] | set[str] | None: if self.has_config(CONF_COLOR_TEMP): color_modes.add(ColorMode.COLOR_TEMP) + elif self.has_config(CONF_BRIGHTNESS): + color_modes.add(ColorMode.WHITE) if self.has_config(CONF_COLOR): color_modes.add(ColorMode.HS) - if not color_modes and self.has_config(CONF_BRIGHTNESS): + if self.has_config(CONF_COLOR): + color_modes.add(ColorMode.HS) + + if color_modes == {ColorMode.WHITE}: return {ColorMode.BRIGHTNESS} if not color_modes: @@ -350,7 +356,9 @@ def color_mode(self) -> ColorMode: if self.is_color_mode: return ColorMode.HS if self.is_white_mode: - return ColorMode.COLOR_TEMP + if self.has_config(CONF_COLOR_TEMP): + return ColorMode.COLOR_TEMP + return ColorMode.WHITE if self._brightness: return ColorMode.BRIGHTNESS @@ -481,6 +489,12 @@ async def async_turn_on(self, **kwargs): states[self._config.get(CONF_BRIGHTNESS)] = brightness states[self._config.get(CONF_COLOR_TEMP)] = color_temp + if ATTR_WHITE in kwargs and ColorMode.WHITE in color_modes: + if brightness is None: + brightness = self._brightness + states[self._config.get(CONF_COLOR_MODE)] = self._modes.white + states[self._config.get(CONF_BRIGHTNESS)] = brightness + await self._device.set_dps(states) async def async_turn_off(self, **kwargs): diff --git a/custom_components/localtuya/manifest.json b/custom_components/localtuya/manifest.json index 092cc596f..03cbb0f16 100644 --- a/custom_components/localtuya/manifest.json +++ b/custom_components/localtuya/manifest.json @@ -9,5 +9,5 @@ "iot_class": "local_push", "issue_tracker": "https://github.com/xZetsubou/hass-localtuya/issues", "requirements": [], - "version": "2024.12.1" + "version": "2025.1.1" }