Skip to content
Merged
Changes from 2 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
36 changes: 22 additions & 14 deletions homeassistant/components/lifx/light.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,11 @@
COLOR_GROUP,
DOMAIN,
LIGHT_TURN_ON_SCHEMA,
SUPPORT_BRIGHTNESS,
SUPPORT_COLOR,
SUPPORT_COLOR_TEMP,
SUPPORT_EFFECT,
SUPPORT_TRANSITION,
VALID_BRIGHTNESS,
VALID_BRIGHTNESS_PCT,
ColorMode,
LightEntity,
preprocess_turn_on_alternatives,
)
Expand Down Expand Up @@ -496,6 +494,8 @@ def convert_16_to_8(value):
class LIFXLight(LightEntity):
"""Representation of a LIFX light."""

_attr_supported_features = SUPPORT_TRANSITION | SUPPORT_EFFECT
Comment thread
emontnemery marked this conversation as resolved.
Outdated

def __init__(self, bulb, effects_conductor):
"""Initialize the light."""
self.bulb = bulb
Expand Down Expand Up @@ -567,15 +567,17 @@ def max_mireds(self):
return math.ceil(color_util.color_temperature_kelvin_to_mired(kelvin))

@property
def supported_features(self):
"""Flag supported features."""
support = SUPPORT_BRIGHTNESS | SUPPORT_TRANSITION | SUPPORT_EFFECT

def color_mode(self) -> str:
Comment thread
emontnemery marked this conversation as resolved.
Outdated
"""Return the color mode of the light."""
bulb_features = lifx_features(self.bulb)
if bulb_features["min_kelvin"] != bulb_features["max_kelvin"]:
support |= SUPPORT_COLOR_TEMP
return ColorMode.COLOR_TEMP
return ColorMode.BRIGHTNESS

return support
@property
def supported_color_modes(self) -> set[str] | None:
Comment thread
emontnemery marked this conversation as resolved.
Outdated
"""Flag supported color modes."""
return {self.color_mode}

@property
def brightness(self):
Expand Down Expand Up @@ -725,11 +727,17 @@ class LIFXColor(LIFXLight):
"""Representation of a color LIFX light."""

@property
def supported_features(self):
"""Flag supported features."""
support = super().supported_features
support |= SUPPORT_COLOR
return support
def color_mode(self) -> str:
Comment thread
emontnemery marked this conversation as resolved.
Outdated
"""Return the color mode of the light."""
sat = self.bulb.color[1]
if sat:
return ColorMode.HS
return ColorMode.COLOR_TEMP

@property
def supported_color_modes(self) -> set[str] | None:
Comment thread
emontnemery marked this conversation as resolved.
Outdated
"""Flag supported color modes."""
return {ColorMode.COLOR_TEMP, ColorMode.HS}

@property
def effect_list(self):
Expand Down