Skip to content
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
25 changes: 13 additions & 12 deletions homeassistant/components/nanoleaf/light.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,8 @@
ATTR_EFFECT,
ATTR_HS_COLOR,
ATTR_TRANSITION,
SUPPORT_BRIGHTNESS,
SUPPORT_COLOR,
SUPPORT_COLOR_TEMP,
COLOR_MODE_COLOR_TEMP,
COLOR_MODE_HS,
SUPPORT_EFFECT,
SUPPORT_TRANSITION,
LightEntity,
Expand Down Expand Up @@ -47,6 +46,9 @@ async def async_setup_entry(
class NanoleafLight(NanoleafEntity, LightEntity):
"""Representation of a Nanoleaf Light."""

_attr_supported_color_modes = {COLOR_MODE_COLOR_TEMP, COLOR_MODE_HS}
_attr_supported_features = SUPPORT_EFFECT | SUPPORT_TRANSITION

def __init__(self, nanoleaf: Nanoleaf, coordinator: DataUpdateCoordinator) -> None:
"""Initialize the Nanoleaf light."""
super().__init__(nanoleaf, coordinator)
Expand Down Expand Up @@ -97,15 +99,14 @@ def hs_color(self) -> tuple[int, int]:
return self._nanoleaf.hue, self._nanoleaf.saturation

@property
def supported_features(self) -> int:
"""Flag supported features."""
return (
SUPPORT_BRIGHTNESS
| SUPPORT_COLOR_TEMP
| SUPPORT_EFFECT
| SUPPORT_COLOR
| SUPPORT_TRANSITION
)
def color_mode(self) -> str | None:
"""Return the color mode of the light."""
# According to API docs, color mode is "ct", "effect" or "hs"
# https://forum.nanoleaf.me/docs/openapi#_4qgqrz96f44d
if self._nanoleaf.color_mode == "ct":
return COLOR_MODE_COLOR_TEMP
# Home Assistant does not have an "effect" color mode, just report hs
return COLOR_MODE_HS

async def async_turn_on(self, **kwargs: Any) -> None:
"""Instruct the light to turn on."""
Expand Down