Skip to content

Commit

Permalink
yeelight: implement min_mireds and max_mireds, fixes #9509 (#9763)
Browse files Browse the repository at this point in the history
* yeelight: implement min_mireds and max_mireds, fixes #9509

thanks to @amelchio for pointing this out!

* remove typing infos
  • Loading branch information
rytilahti authored and balloob committed Oct 9, 2017
1 parent 2a2ee81 commit c00647a
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions homeassistant/components/light/yeelight.py
Expand Up @@ -54,6 +54,10 @@
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!"
Expand Down Expand Up @@ -191,6 +195,20 @@ def brightness(self) -> int:
"""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)
Expand Down

0 comments on commit c00647a

Please sign in to comment.