mirror of
https://github.com/home-assistant/core.git
synced 2025-07-25 14:17:45 +00:00
Migrate unifiled light to color_mode (#69523)
This commit is contained in:
parent
72429a6c04
commit
ee71dcca6c
@ -8,8 +8,8 @@ import voluptuous as vol
|
|||||||
|
|
||||||
from homeassistant.components.light import (
|
from homeassistant.components.light import (
|
||||||
ATTR_BRIGHTNESS,
|
ATTR_BRIGHTNESS,
|
||||||
|
COLOR_MODE_BRIGHTNESS,
|
||||||
PLATFORM_SCHEMA,
|
PLATFORM_SCHEMA,
|
||||||
SUPPORT_BRIGHTNESS,
|
|
||||||
LightEntity,
|
LightEntity,
|
||||||
)
|
)
|
||||||
from homeassistant.const import CONF_HOST, CONF_PASSWORD, CONF_PORT, CONF_USERNAME
|
from homeassistant.const import CONF_HOST, CONF_PASSWORD, CONF_PORT, CONF_USERNAME
|
||||||
@ -59,6 +59,9 @@ def setup_platform(
|
|||||||
class UnifiLedLight(LightEntity):
|
class UnifiLedLight(LightEntity):
|
||||||
"""Representation of an unifiled Light."""
|
"""Representation of an unifiled Light."""
|
||||||
|
|
||||||
|
_attr_color_mode = COLOR_MODE_BRIGHTNESS
|
||||||
|
_attr_supported_color_modes = {COLOR_MODE_BRIGHTNESS}
|
||||||
|
|
||||||
def __init__(self, light, api):
|
def __init__(self, light, api):
|
||||||
"""Init Unifi LED Light."""
|
"""Init Unifi LED Light."""
|
||||||
|
|
||||||
@ -69,7 +72,6 @@ class UnifiLedLight(LightEntity):
|
|||||||
self._state = light["status"]["output"]
|
self._state = light["status"]["output"]
|
||||||
self._available = light["isOnline"]
|
self._available = light["isOnline"]
|
||||||
self._brightness = self._api.convertfrom100to255(light["status"]["led"])
|
self._brightness = self._api.convertfrom100to255(light["status"]["led"])
|
||||||
self._features = SUPPORT_BRIGHTNESS
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def name(self):
|
def name(self):
|
||||||
@ -96,11 +98,6 @@ class UnifiLedLight(LightEntity):
|
|||||||
"""Return true if light is on."""
|
"""Return true if light is on."""
|
||||||
return self._state
|
return self._state
|
||||||
|
|
||||||
@property
|
|
||||||
def supported_features(self):
|
|
||||||
"""Return the supported features of this light."""
|
|
||||||
return self._features
|
|
||||||
|
|
||||||
def turn_on(self, **kwargs):
|
def turn_on(self, **kwargs):
|
||||||
"""Instruct the light to turn on."""
|
"""Instruct the light to turn on."""
|
||||||
self._api.setdevicebrightness(
|
self._api.setdevicebrightness(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user