mirror of
https://github.com/home-assistant/core.git
synced 2025-07-11 07:17:12 +00:00
Get min and max color temperature for Nanoleaf light from library (#56863)
This commit is contained in:
parent
538773a14a
commit
d41832de59
@ -1,6 +1,7 @@
|
|||||||
"""Support for Nanoleaf Lights."""
|
"""Support for Nanoleaf Lights."""
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
|
import math
|
||||||
from typing import Any
|
from typing import Any
|
||||||
|
|
||||||
from aionanoleaf import Nanoleaf, Unavailable
|
from aionanoleaf import Nanoleaf, Unavailable
|
||||||
@ -27,8 +28,8 @@ import homeassistant.helpers.config_validation as cv
|
|||||||
from homeassistant.helpers.entity import DeviceInfo
|
from homeassistant.helpers.entity import DeviceInfo
|
||||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||||
from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType
|
from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType
|
||||||
from homeassistant.util import color as color_util
|
|
||||||
from homeassistant.util.color import (
|
from homeassistant.util.color import (
|
||||||
|
color_temperature_kelvin_to_mired as kelvin_to_mired,
|
||||||
color_temperature_mired_to_kelvin as mired_to_kelvin,
|
color_temperature_mired_to_kelvin as mired_to_kelvin,
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -85,8 +86,10 @@ class NanoleafLight(LightEntity):
|
|||||||
model=self._nanoleaf.model,
|
model=self._nanoleaf.model,
|
||||||
sw_version=self._nanoleaf.firmware_version,
|
sw_version=self._nanoleaf.firmware_version,
|
||||||
)
|
)
|
||||||
self._attr_min_mireds = 154
|
self._attr_min_mireds = math.ceil(
|
||||||
self._attr_max_mireds = 833
|
1000000 / self._nanoleaf.color_temperature_max
|
||||||
|
)
|
||||||
|
self._attr_max_mireds = kelvin_to_mired(self._nanoleaf.color_temperature_min)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def brightness(self) -> int:
|
def brightness(self) -> int:
|
||||||
@ -96,9 +99,7 @@ class NanoleafLight(LightEntity):
|
|||||||
@property
|
@property
|
||||||
def color_temp(self) -> int:
|
def color_temp(self) -> int:
|
||||||
"""Return the current color temperature."""
|
"""Return the current color temperature."""
|
||||||
return color_util.color_temperature_kelvin_to_mired(
|
return kelvin_to_mired(self._nanoleaf.color_temperature)
|
||||||
self._nanoleaf.color_temperature
|
|
||||||
)
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def effect(self) -> str | None:
|
def effect(self) -> str | None:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user