diff --git a/homeassistant/components/tplink/light.py b/homeassistant/components/tplink/light.py index 70a078928d9..87d30e4f76a 100644 --- a/homeassistant/components/tplink/light.py +++ b/homeassistant/components/tplink/light.py @@ -17,6 +17,7 @@ from homeassistant.components.light import ( ColorMode, LightEntity, LightEntityFeature, + filter_supported_color_modes, ) from homeassistant.config_entries import ConfigEntry from homeassistant.core import HomeAssistant, callback @@ -181,7 +182,7 @@ class TPLinkSmartBulb(CoordinatedTPLinkEntity, LightEntity): self._attr_unique_id = legacy_device_id(device) else: self._attr_unique_id = device.mac.replace(":", "").upper() - modes: set[ColorMode] = set() + modes: set[ColorMode] = {ColorMode.ONOFF} if device.is_variable_color_temp: modes.add(ColorMode.COLOR_TEMP) temp_range = device.valid_temperature_range @@ -191,9 +192,7 @@ class TPLinkSmartBulb(CoordinatedTPLinkEntity, LightEntity): modes.add(ColorMode.HS) if device.is_dimmable: modes.add(ColorMode.BRIGHTNESS) - if not modes: - modes.add(ColorMode.ONOFF) - self._attr_supported_color_modes = modes + self._attr_supported_color_modes = filter_supported_color_modes(modes) self._async_update_attrs() @callback diff --git a/tests/components/tplink/test_light.py b/tests/components/tplink/test_light.py index c541551a250..bd8a380daa1 100644 --- a/tests/components/tplink/test_light.py +++ b/tests/components/tplink/test_light.py @@ -86,7 +86,7 @@ async def test_color_light( attributes = state.attributes assert attributes[ATTR_BRIGHTNESS] == 128 assert attributes[ATTR_COLOR_MODE] == "hs" - assert attributes[ATTR_SUPPORTED_COLOR_MODES] == ["brightness", "color_temp", "hs"] + assert attributes[ATTR_SUPPORTED_COLOR_MODES] == ["color_temp", "hs"] assert attributes[ATTR_MIN_MIREDS] == 111 assert attributes[ATTR_MAX_MIREDS] == 250 assert attributes[ATTR_HS_COLOR] == (10, 30) @@ -163,7 +163,7 @@ async def test_color_light_no_temp(hass: HomeAssistant) -> None: attributes = state.attributes assert attributes[ATTR_BRIGHTNESS] == 128 assert attributes[ATTR_COLOR_MODE] == "hs" - assert attributes[ATTR_SUPPORTED_COLOR_MODES] == ["brightness", "hs"] + assert attributes[ATTR_SUPPORTED_COLOR_MODES] == ["hs"] assert attributes[ATTR_HS_COLOR] == (10, 30) assert attributes[ATTR_RGB_COLOR] == (255, 191, 178) assert attributes[ATTR_XY_COLOR] == (0.42, 0.336) @@ -225,13 +225,9 @@ async def test_color_temp_light( assert attributes[ATTR_BRIGHTNESS] == 128 assert attributes[ATTR_COLOR_MODE] == "color_temp" if bulb.is_color: - assert attributes[ATTR_SUPPORTED_COLOR_MODES] == [ - "brightness", - "color_temp", - "hs", - ] + assert attributes[ATTR_SUPPORTED_COLOR_MODES] == ["color_temp", "hs"] else: - assert attributes[ATTR_SUPPORTED_COLOR_MODES] == ["brightness", "color_temp"] + assert attributes[ATTR_SUPPORTED_COLOR_MODES] == ["color_temp"] assert attributes[ATTR_MIN_MIREDS] == 111 assert attributes[ATTR_MAX_MIREDS] == 250 assert attributes[ATTR_COLOR_TEMP_KELVIN] == 4000