diff --git a/homeassistant/components/homematic/const.py b/homeassistant/components/homematic/const.py index cd2d528044a9..188ec1e2445f 100644 --- a/homeassistant/components/homematic/const.py +++ b/homeassistant/components/homematic/const.py @@ -63,6 +63,7 @@ HM_DEVICE_TYPES = { "IPDimmer", "ColorEffectLight", "IPKeySwitchLevel", + "ColdWarmDimmer", ], DISCOVER_SENSORS: [ "SwitchPowermeter", diff --git a/homeassistant/components/homematic/light.py b/homeassistant/components/homematic/light.py index 52b2f9a79968..6e6ccb78371c 100644 --- a/homeassistant/components/homematic/light.py +++ b/homeassistant/components/homematic/light.py @@ -3,11 +3,13 @@ import logging from homeassistant.components.light import ( ATTR_BRIGHTNESS, + ATTR_COLOR_TEMP, ATTR_EFFECT, ATTR_HS_COLOR, ATTR_TRANSITION, SUPPORT_BRIGHTNESS, SUPPORT_COLOR, + SUPPORT_COLOR_TEMP, SUPPORT_EFFECT, Light, ) @@ -60,6 +62,8 @@ class HMLight(HMDevice, Light): features |= SUPPORT_COLOR if "PROGRAM" in self._hmdevice.WRITENODE: features |= SUPPORT_EFFECT + if hasattr(self._hmdevice, "get_color_temp"): + features |= SUPPORT_COLOR_TEMP return features @property @@ -70,6 +74,14 @@ class HMLight(HMDevice, Light): hue, sat = self._hmdevice.get_hs_color(self._channel) return hue * 360.0, sat * 100.0 + @property + def color_temp(self): + """Return the color temp in mireds [int].""" + if not self.supported_features & SUPPORT_COLOR_TEMP: + return None + hm_color_temp = self._hmdevice.get_color_temp(self._channel) + return self.max_mireds - (self.max_mireds - self.min_mireds) * hm_color_temp + @property def effect_list(self): """Return the list of supported effects.""" @@ -92,7 +104,11 @@ class HMLight(HMDevice, Light): if ATTR_BRIGHTNESS in kwargs and self._state == "LEVEL": percent_bright = float(kwargs[ATTR_BRIGHTNESS]) / 255 self._hmdevice.set_level(percent_bright, self._channel) - elif ATTR_HS_COLOR not in kwargs and ATTR_EFFECT not in kwargs: + elif ( + ATTR_HS_COLOR not in kwargs + and ATTR_COLOR_TEMP not in kwargs + and ATTR_EFFECT not in kwargs + ): self._hmdevice.on(self._channel) if ATTR_HS_COLOR in kwargs: @@ -101,6 +117,11 @@ class HMLight(HMDevice, Light): saturation=kwargs[ATTR_HS_COLOR][1] / 100.0, channel=self._channel, ) + if ATTR_COLOR_TEMP in kwargs: + hm_temp = (self.max_mireds - kwargs[ATTR_COLOR_TEMP]) / ( + self.max_mireds - self.min_mireds + ) + self._hmdevice.set_color_temp(hm_temp) if ATTR_EFFECT in kwargs: self._hmdevice.set_effect(kwargs[ATTR_EFFECT])