mirror of
https://github.com/home-assistant/core.git
synced 2025-07-27 07:07:28 +00:00
Fix limitlessled color temperature (#12971)
* Adjust limitlessled mired range * Do temperature conversion on a Kelvin scale
This commit is contained in:
parent
7f065e38a7
commit
19a529e917
@ -17,6 +17,7 @@ from homeassistant.components.light import (
|
|||||||
SUPPORT_BRIGHTNESS, SUPPORT_COLOR_TEMP, SUPPORT_EFFECT, SUPPORT_FLASH,
|
SUPPORT_BRIGHTNESS, SUPPORT_COLOR_TEMP, SUPPORT_EFFECT, SUPPORT_FLASH,
|
||||||
SUPPORT_RGB_COLOR, SUPPORT_TRANSITION, Light, PLATFORM_SCHEMA)
|
SUPPORT_RGB_COLOR, SUPPORT_TRANSITION, Light, PLATFORM_SCHEMA)
|
||||||
import homeassistant.helpers.config_validation as cv
|
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
|
from homeassistant.helpers.restore_state import async_get_last_state
|
||||||
|
|
||||||
REQUIREMENTS = ['limitlessled==1.1.0']
|
REQUIREMENTS = ['limitlessled==1.1.0']
|
||||||
@ -222,6 +223,16 @@ class LimitlessLEDGroup(Light):
|
|||||||
"""Return the brightness property."""
|
"""Return the brightness property."""
|
||||||
return self._brightness
|
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
|
@property
|
||||||
def color_temp(self):
|
def color_temp(self):
|
||||||
"""Return the temperature property."""
|
"""Return the temperature property."""
|
||||||
@ -310,8 +321,11 @@ class LimitlessLEDGroup(Light):
|
|||||||
|
|
||||||
def limitlessled_temperature(self):
|
def limitlessled_temperature(self):
|
||||||
"""Convert Home Assistant color temperature units to percentage."""
|
"""Convert Home Assistant color temperature units to percentage."""
|
||||||
width = self.max_mireds - self.min_mireds
|
max_kelvin = color_temperature_mired_to_kelvin(self.min_mireds)
|
||||||
temperature = 1 - (self._temperature - self.min_mireds) / width
|
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))
|
return max(0, min(1, temperature))
|
||||||
|
|
||||||
def limitlessled_brightness(self):
|
def limitlessled_brightness(self):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user