8000 Fix limitlessled color temperature by amelchio · Pull Request #12971 · home-assistant/core · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Fix limitlessled color temperature #12971

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Mar 9, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 16 additions & 2 deletions homeassistant/components/light/limitlessled.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
SUPPORT_BRIGHTNESS, SUPPORT_COLOR_TEMP, SUPPORT_EFFECT, SUPPORT_FLASH,
SUPPORT_RGB_COLOR, SUPPORT_TRANSITION, Light, PLATFORM_SCHEMA)
import homeassistant.helpers.config_validation as cv
from homeassistant.util.color import color_temperature_mired_to_kelvin
from homeassistant.helpers.restore_state import async_get_last_state

REQUIREMENTS = ['limitlessled==1.1.0']
Expand Down Expand Up @@ -222,6 +223,16 @@ def brightness(self):
"""Return the brightness property."""
return self._brightness

@property
def min_mireds(self):
"""Return the coldest color_temp that this light supports."""
return 154

@property
def max_mireds(self):
"""Return the warmest color_temp that this light supports."""
return 370

@property
def color_temp(self):
"""Return the temperature property."""
Expand Down Expand Up @@ -310,8 +321,11 @@ def turn_on(self, transition_time, pipeline, **kwargs):

def limitlessled_temperature(self):
"""Convert Home Assistant color temperature units to percentage."""
width = self.max_mireds - self.min_mireds
temperature = 1 - (self._temperature - self.min_mireds) / width
max_kelvin = color_temperature_mired_to_kelvin(self.min_mireds)
min_kelvin = color_temperature_mired_to_kelvin(self.max_mireds)
width = max_kelvin - min_kelvin
kelvin = color_temperature_mired_to_kelvin(self._temperature)
temperature = (kelvin - min_kelvin) / width
return max(0, min(1, temperature))

def limitlessled_brightness(self):
Expand Down
0