diff --git a/custom_components/dirigera_platform/light.py b/custom_components/dirigera_platform/light.py index 82e38a6..2c67239 100644 --- a/custom_components/dirigera_platform/light.py +++ b/custom_components/dirigera_platform/light.py @@ -65,6 +65,7 @@ def set_state(self): can_receive = self._json_data.capabilities.can_receive logger.debug("Got can_receive in state") logger.debug(can_receive) + self._color_mode = ColorMode.UNKNOWN for cap in can_receive: if cap == "lightLevel": color_modes.append(ColorMode.BRIGHTNESS) @@ -74,11 +75,20 @@ def set_state(self): color_modes.append(ColorMode.HS) if len(color_modes) == 0: - self._supported_color_modes = ColorMode.UNKNOWN + logger.debug("Color modes array is zero, setting to UNKNOWN") + self._supported_color_modes = [ColorMode.UNKNOWN] else: self._supported_color_modes = color_modes + if ColorMode.HS in self._supported_color_modes: + self._color_mode = ColorMode.HS + elif ColorMode.COLOR_TEMP in self._supported_color_modes: + self._color_mode = ColorMode.COLOR_TEMP + elif ColorMode.BRIGHTNESS in self._supported_color_modes: + self._color_mode = ColorMode.BRIGHTNESS + logger.debug("supported color mode set to ") logger.debug(self._supported_color_modes) + logger.debug(self._color_mode) @property def unique_id(self): @@ -136,7 +146,7 @@ def supported_color_modes(self): @property def color_mode(self): - return self._supported_color_modes + return self._color_mode def update(self): try: diff --git a/custom_components/dirigera_platform/mocks/ikea_bulb_mock.py b/custom_components/dirigera_platform/mocks/ikea_bulb_mock.py index f8a563f..5383ff0 100644 --- a/custom_components/dirigera_platform/mocks/ikea_bulb_mock.py +++ b/custom_components/dirigera_platform/mocks/ikea_bulb_mock.py @@ -31,6 +31,18 @@ def __init__(self) -> None: ColorMode.COLOR_TEMP, ColorMode.HS, ] + + if len(self._supported_color_modes) == 0: + logger.debug("Color modes array is zero, setting to UNKNOWN") + self._supported_color_modes = [ColorMode.UNKNOWN] + else: + if ColorMode.HS in self._supported_color_modes: + self._color_mode = ColorMode.HS + elif ColorMode.COLOR_TEMP in self._supported_color_modes: + self._color_mode = ColorMode.COLOR_TEMP + elif ColorMode.BRIGHTNESS in self._supported_color_modesor_modes: + self._color_mode = ColorMode.BRIGHTNESS + self._color_temp = 3000 self._min_color_temp = 2202 self._max_color_temp = 4000 @@ -86,8 +98,14 @@ def is_on(self): @property def supported_color_modes(self): + logger.debug("returning supported colors") return self._supported_color_modes + @property + def color_mode(self): + logger.debug("Returning color mode") + return self._color_mode + def update(self): logger.debug("mock update for {}...".format(self._name)) pass