diff --git a/homeassistant/components/iglo/light.py b/homeassistant/components/iglo/light.py index 71dd34af032..f839ff8ca61 100644 --- a/homeassistant/components/iglo/light.py +++ b/homeassistant/components/iglo/light.py @@ -4,6 +4,7 @@ from __future__ import annotations import math from iglo import Lamp +from iglo.lamp import MODE_WHITE import voluptuous as vol from homeassistant.components.light import ( @@ -11,10 +12,9 @@ from homeassistant.components.light import ( ATTR_COLOR_TEMP, ATTR_EFFECT, ATTR_HS_COLOR, + COLOR_MODE_COLOR_TEMP, + COLOR_MODE_HS, PLATFORM_SCHEMA, - SUPPORT_BRIGHTNESS, - SUPPORT_COLOR, - SUPPORT_COLOR_TEMP, SUPPORT_EFFECT, LightEntity, ) @@ -53,6 +53,9 @@ def setup_platform( class IGloLamp(LightEntity): """Representation of an iGlo light.""" + _attr_supported_color_modes = {COLOR_MODE_COLOR_TEMP, COLOR_MODE_HS} + _attr_supported_features = SUPPORT_EFFECT + def __init__(self, name, host, port): """Initialize the light.""" @@ -69,6 +72,15 @@ class IGloLamp(LightEntity): """Return the brightness of this light between 0..255.""" return int((self._lamp.state()["brightness"] / 200.0) * 255) + @property + def color_mode(self) -> str | None: + """Return the color mode of the light.""" + if self._lamp.state()["mode"] == MODE_WHITE: + return COLOR_MODE_COLOR_TEMP + # The iglo library reports MODE_WHITE when an effect is active, this is not + # supported by Home Assistant, just report COLOR_MODE_HS + return COLOR_MODE_HS + @property def color_temp(self): """Return the color temperature.""" @@ -103,11 +115,6 @@ class IGloLamp(LightEntity): """Return the list of supported effects.""" return self._lamp.effect_list() - @property - def supported_features(self): - """Flag supported features.""" - return SUPPORT_BRIGHTNESS | SUPPORT_COLOR_TEMP | SUPPORT_COLOR | SUPPORT_EFFECT - @property def is_on(self): """Return true if light is on."""