mirror of
https://github.com/home-assistant/core.git
synced 2025-07-25 22:27:07 +00:00
Migrate iglo lights to use Kelvin (#132796)
This commit is contained in:
parent
82692f9a8f
commit
b0b3f04a05
@ -2,7 +2,6 @@
|
|||||||
|
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
import math
|
|
||||||
from typing import Any
|
from typing import Any
|
||||||
|
|
||||||
from iglo import Lamp
|
from iglo import Lamp
|
||||||
@ -11,7 +10,7 @@ import voluptuous as vol
|
|||||||
|
|
||||||
from homeassistant.components.light import (
|
from homeassistant.components.light import (
|
||||||
ATTR_BRIGHTNESS,
|
ATTR_BRIGHTNESS,
|
||||||
ATTR_COLOR_TEMP,
|
ATTR_COLOR_TEMP_KELVIN,
|
||||||
ATTR_EFFECT,
|
ATTR_EFFECT,
|
||||||
ATTR_HS_COLOR,
|
ATTR_HS_COLOR,
|
||||||
PLATFORM_SCHEMA as LIGHT_PLATFORM_SCHEMA,
|
PLATFORM_SCHEMA as LIGHT_PLATFORM_SCHEMA,
|
||||||
@ -83,23 +82,19 @@ class IGloLamp(LightEntity):
|
|||||||
return ColorMode.HS
|
return ColorMode.HS
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def color_temp(self):
|
def color_temp_kelvin(self) -> int | None:
|
||||||
"""Return the color temperature."""
|
"""Return the color temperature value in Kelvin."""
|
||||||
return color_util.color_temperature_kelvin_to_mired(self._lamp.state()["white"])
|
return self._lamp.state()["white"]
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def min_mireds(self) -> int:
|
def max_color_temp_kelvin(self) -> int:
|
||||||
"""Return the coldest color_temp that this light supports."""
|
"""Return the coldest color_temp_kelvin that this light supports."""
|
||||||
return math.ceil(
|
return self._lamp.max_kelvin
|
||||||
color_util.color_temperature_kelvin_to_mired(self._lamp.max_kelvin)
|
|
||||||
)
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def max_mireds(self) -> int:
|
def min_color_temp_kelvin(self) -> int:
|
||||||
"""Return the warmest color_temp that this light supports."""
|
"""Return the warmest color_temp_kelvin that this light supports."""
|
||||||
return math.ceil(
|
return self._lamp.min_kelvin
|
||||||
color_util.color_temperature_kelvin_to_mired(self._lamp.min_kelvin)
|
|
||||||
)
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def hs_color(self):
|
def hs_color(self):
|
||||||
@ -135,11 +130,8 @@ class IGloLamp(LightEntity):
|
|||||||
self._lamp.rgb(*rgb)
|
self._lamp.rgb(*rgb)
|
||||||
return
|
return
|
||||||
|
|
||||||
if ATTR_COLOR_TEMP in kwargs:
|
if ATTR_COLOR_TEMP_KELVIN in kwargs:
|
||||||
kelvin = int(
|
self._lamp.white(kwargs[ATTR_COLOR_TEMP_KELVIN])
|
||||||
color_util.color_temperature_mired_to_kelvin(kwargs[ATTR_COLOR_TEMP])
|
|
||||||
)
|
|
||||||
self._lamp.white(kelvin)
|
|
||||||
return
|
return
|
||||||
|
|
||||||
if ATTR_EFFECT in kwargs:
|
if ATTR_EFFECT in kwargs:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user