From c00647ace06848cbc3788a25087f051db6b60033 Mon Sep 17 00:00:00 2001 From: Teemu R Date: Mon, 9 Oct 2017 06:05:49 +0200 Subject: [PATCH] yeelight: implement min_mireds and max_mireds, fixes #9509 (#9763) * yeelight: implement min_mireds and max_mireds, fixes #9509 thanks to @amelchio for pointing this out! * remove typing infos --- homeassistant/components/light/yeelight.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/homeassistant/components/light/yeelight.py b/homeassistant/components/light/yeelight.py index 96d51984568..4c472a0a78f 100644 --- a/homeassistant/components/light/yeelight.py +++ b/homeassistant/components/light/yeelight.py @@ -54,6 +54,10 @@ SUPPORT_YEELIGHT_RGB = (SUPPORT_YEELIGHT | SUPPORT_EFFECT | SUPPORT_COLOR_TEMP) +YEELIGHT_MIN_KELVIN = YEELIGHT_MAX_KELVIN = 2700 +YEELIGHT_RGB_MIN_KELVIN = 1700 +YEELIGHT_RGB_MAX_KELVIN = 6500 + EFFECT_DISCO = "Disco" EFFECT_TEMP = "Slow Temp" EFFECT_STROBE = "Strobe epilepsy!" @@ -191,6 +195,20 @@ class YeelightLight(Light): """Return the brightness of this light between 1..255.""" return self._brightness + @property + def min_mireds(self): + """Return minimum supported color temperature.""" + if self.supported_features & SUPPORT_COLOR_TEMP: + return kelvin_to_mired(YEELIGHT_RGB_MAX_KELVIN) + return kelvin_to_mired(YEELIGHT_MAX_KELVIN) + + @property + def max_mireds(self): + """Return maximum supported color temperature.""" + if self.supported_features & SUPPORT_COLOR_TEMP: + return kelvin_to_mired(YEELIGHT_RGB_MIN_KELVIN) + return kelvin_to_mired(YEELIGHT_MIN_KELVIN) + def _get_rgb_from_properties(self): rgb = self._properties.get('rgb', None) color_mode = self._properties.get('color_mode', None)