diff --git a/homeassistant/components/abode/light.py b/homeassistant/components/abode/light.py index f998e21510d..6d1123cd233 100644 --- a/homeassistant/components/abode/light.py +++ b/homeassistant/components/abode/light.py @@ -11,9 +11,10 @@ from homeassistant.components.light import ( ATTR_BRIGHTNESS, ATTR_COLOR_TEMP, ATTR_HS_COLOR, - SUPPORT_BRIGHTNESS, - SUPPORT_COLOR, - SUPPORT_COLOR_TEMP, + COLOR_MODE_BRIGHTNESS, + COLOR_MODE_COLOR_TEMP, + COLOR_MODE_HS, + COLOR_MODE_ONOFF, LightEntity, ) from homeassistant.config_entries import ConfigEntry @@ -101,11 +102,27 @@ class AbodeLight(AbodeDevice, LightEntity): _hs = self._device.color return _hs + @property + def color_mode(self) -> str | None: + """Return the color mode of the light.""" + if self._device.is_dimmable and self._device.is_color_capable: + if self.hs_color is not None: + return COLOR_MODE_HS + return COLOR_MODE_COLOR_TEMP + if self._device.is_dimmable: + return COLOR_MODE_BRIGHTNESS + return COLOR_MODE_ONOFF + + @property + def supported_color_modes(self) -> set[str] | None: + """Flag supported color modes.""" + if self._device.is_dimmable and self._device.is_color_capable: + return {COLOR_MODE_COLOR_TEMP, COLOR_MODE_HS} + if self._device.is_dimmable: + return {COLOR_MODE_BRIGHTNESS} + return {COLOR_MODE_ONOFF} + @property def supported_features(self) -> int: """Flag supported features.""" - if self._device.is_dimmable and self._device.is_color_capable: - return SUPPORT_BRIGHTNESS | SUPPORT_COLOR | SUPPORT_COLOR_TEMP - if self._device.is_dimmable: - return SUPPORT_BRIGHTNESS return 0 diff --git a/tests/components/abode/test_light.py b/tests/components/abode/test_light.py index d27a07227d0..3a1adc069e4 100644 --- a/tests/components/abode/test_light.py +++ b/tests/components/abode/test_light.py @@ -4,8 +4,12 @@ from unittest.mock import patch from homeassistant.components.abode import ATTR_DEVICE_ID from homeassistant.components.light import ( ATTR_BRIGHTNESS, + ATTR_COLOR_MODE, ATTR_COLOR_TEMP, ATTR_RGB_COLOR, + ATTR_SUPPORTED_COLOR_MODES, + COLOR_MODE_COLOR_TEMP, + COLOR_MODE_HS, DOMAIN as LIGHT_DOMAIN, ) from homeassistant.const import ( @@ -41,13 +45,18 @@ async def test_attributes(hass: HomeAssistant) -> None: assert state.state == STATE_ON assert state.attributes.get(ATTR_BRIGHTNESS) == 204 assert state.attributes.get(ATTR_RGB_COLOR) == (0, 63, 255) - assert state.attributes.get(ATTR_COLOR_TEMP) == 280 + assert state.attributes.get(ATTR_COLOR_TEMP) is None assert state.attributes.get(ATTR_DEVICE_ID) == "ZB:db5b1a" assert not state.attributes.get("battery_low") assert not state.attributes.get("no_response") assert state.attributes.get("device_type") == "RGB Dimmer" assert state.attributes.get(ATTR_FRIENDLY_NAME) == "Living Room Lamp" - assert state.attributes.get(ATTR_SUPPORTED_FEATURES) == 19 + assert state.attributes.get(ATTR_SUPPORTED_FEATURES) == 0 + assert state.attributes.get(ATTR_COLOR_MODE) == COLOR_MODE_HS + assert state.attributes.get(ATTR_SUPPORTED_COLOR_MODES) == [ + COLOR_MODE_COLOR_TEMP, + COLOR_MODE_HS, + ] async def test_switch_off(hass: HomeAssistant) -> None: