Migrate hive light to color_mode (#69259)
This commit is contained in:
parent
1c1b792fb7
commit
ef9cd66320
1 changed files with 26 additions and 12 deletions
|
@ -1,13 +1,16 @@
|
||||||
"""Support for Hive light devices."""
|
"""Support for Hive light devices."""
|
||||||
|
from __future__ import annotations
|
||||||
|
|
||||||
from datetime import timedelta
|
from datetime import timedelta
|
||||||
|
|
||||||
from homeassistant.components.light import (
|
from homeassistant.components.light import (
|
||||||
ATTR_BRIGHTNESS,
|
ATTR_BRIGHTNESS,
|
||||||
ATTR_COLOR_TEMP,
|
ATTR_COLOR_TEMP,
|
||||||
ATTR_HS_COLOR,
|
ATTR_HS_COLOR,
|
||||||
SUPPORT_BRIGHTNESS,
|
COLOR_MODE_BRIGHTNESS,
|
||||||
SUPPORT_COLOR,
|
COLOR_MODE_COLOR_TEMP,
|
||||||
SUPPORT_COLOR_TEMP,
|
COLOR_MODE_HS,
|
||||||
|
COLOR_MODE_ONOFF,
|
||||||
LightEntity,
|
LightEntity,
|
||||||
)
|
)
|
||||||
from homeassistant.config_entries import ConfigEntry
|
from homeassistant.config_entries import ConfigEntry
|
||||||
|
@ -138,17 +141,28 @@ class HiveDeviceLight(HiveEntity, LightEntity):
|
||||||
await self.hive.light.turnOff(self.device)
|
await self.hive.light.turnOff(self.device)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def supported_features(self):
|
def color_mode(self) -> str:
|
||||||
"""Flag supported features."""
|
"""Return the color mode of the light."""
|
||||||
supported_features = None
|
|
||||||
if self.device["hiveType"] == "warmwhitelight":
|
if self.device["hiveType"] == "warmwhitelight":
|
||||||
supported_features = SUPPORT_BRIGHTNESS
|
return COLOR_MODE_BRIGHTNESS
|
||||||
elif self.device["hiveType"] == "tuneablelight":
|
if self.device["hiveType"] == "tuneablelight":
|
||||||
supported_features = SUPPORT_BRIGHTNESS | SUPPORT_COLOR_TEMP
|
return COLOR_MODE_COLOR_TEMP
|
||||||
elif self.device["hiveType"] == "colourtuneablelight":
|
if self.device["hiveType"] == "colourtuneablelight":
|
||||||
supported_features = SUPPORT_BRIGHTNESS | SUPPORT_COLOR_TEMP | SUPPORT_COLOR
|
if self.device["status"]["mode"] == "COLOUR":
|
||||||
|
return COLOR_MODE_HS
|
||||||
|
return COLOR_MODE_COLOR_TEMP
|
||||||
|
return COLOR_MODE_ONOFF
|
||||||
|
|
||||||
return supported_features
|
@property
|
||||||
|
def supported_color_modes(self) -> set[str] | None:
|
||||||
|
"""Flag supported color modes."""
|
||||||
|
if self.device["hiveType"] == "warmwhitelight":
|
||||||
|
return {COLOR_MODE_BRIGHTNESS}
|
||||||
|
if self.device["hiveType"] == "tuneablelight":
|
||||||
|
return {COLOR_MODE_COLOR_TEMP}
|
||||||
|
if self.device["hiveType"] == "colourtuneablelight":
|
||||||
|
return {COLOR_MODE_COLOR_TEMP, COLOR_MODE_HS}
|
||||||
|
return {COLOR_MODE_ONOFF}
|
||||||
|
|
||||||
async def async_update(self):
|
async def async_update(self):
|
||||||
"""Update all Node data from Hive."""
|
"""Update all Node data from Hive."""
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue