mirror of
https://github.com/home-assistant/core.git
synced 2025-07-19 19:27:45 +00:00
Migrate crownstone light to color_mode (#69081)
This commit is contained in:
parent
8cf6ac281e
commit
7f1b90a51c
@ -11,7 +11,8 @@ from crownstone_uart import CrownstoneUart
|
|||||||
|
|
||||||
from homeassistant.components.light import (
|
from homeassistant.components.light import (
|
||||||
ATTR_BRIGHTNESS,
|
ATTR_BRIGHTNESS,
|
||||||
SUPPORT_BRIGHTNESS,
|
COLOR_MODE_BRIGHTNESS,
|
||||||
|
COLOR_MODE_ONOFF,
|
||||||
LightEntity,
|
LightEntity,
|
||||||
)
|
)
|
||||||
from homeassistant.config_entries import ConfigEntry
|
from homeassistant.config_entries import ConfigEntry
|
||||||
@ -98,11 +99,16 @@ class CrownstoneEntity(CrownstoneBaseEntity, LightEntity):
|
|||||||
return crownstone_state_to_hass(self.device.state) > 0
|
return crownstone_state_to_hass(self.device.state) > 0
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def supported_features(self) -> int:
|
def color_mode(self) -> str:
|
||||||
"""Return the supported features of this Crownstone."""
|
"""Return the color mode of the light."""
|
||||||
if self.device.abilities.get(DIMMING_ABILITY).is_enabled:
|
if self.device.abilities.get(DIMMING_ABILITY).is_enabled:
|
||||||
return SUPPORT_BRIGHTNESS
|
return COLOR_MODE_BRIGHTNESS
|
||||||
return 0
|
return COLOR_MODE_ONOFF
|
||||||
|
|
||||||
|
@property
|
||||||
|
def supported_color_modes(self) -> set[str] | None:
|
||||||
|
"""Flag supported color modes."""
|
||||||
|
return {self.color_mode}
|
||||||
|
|
||||||
async def async_added_to_hass(self) -> None:
|
async def async_added_to_hass(self) -> None:
|
||||||
"""Set up a listener when this entity is added to HA."""
|
"""Set up a listener when this entity is added to HA."""
|
||||||
|
Loading…
x
Reference in New Issue
Block a user