Migrate unifiled light to color_mode (#69523)

This commit is contained in:
epenet 2022-04-07 09:15:20 +02:00 committed by GitHub
parent 72429a6c04
commit ee71dcca6c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -8,8 +8,8 @@ import voluptuous as vol
from homeassistant.components.light import (
ATTR_BRIGHTNESS,
COLOR_MODE_BRIGHTNESS,
PLATFORM_SCHEMA,
SUPPORT_BRIGHTNESS,
LightEntity,
)
from homeassistant.const import CONF_HOST, CONF_PASSWORD, CONF_PORT, CONF_USERNAME
@ -59,6 +59,9 @@ def setup_platform(
class UnifiLedLight(LightEntity):
"""Representation of an unifiled Light."""
_attr_color_mode = COLOR_MODE_BRIGHTNESS
_attr_supported_color_modes = {COLOR_MODE_BRIGHTNESS}
def __init__(self, light, api):
"""Init Unifi LED Light."""
@ -69,7 +72,6 @@ class UnifiLedLight(LightEntity):
self._state = light["status"]["output"]
self._available = light["isOnline"]
self._brightness = self._api.convertfrom100to255(light["status"]["led"])
self._features = SUPPORT_BRIGHTNESS
@property
def name(self):
@ -96,11 +98,6 @@ class UnifiLedLight(LightEntity):
"""Return true if light is on."""
return self._state
@property
def supported_features(self):
"""Return the supported features of this light."""
return self._features
def turn_on(self, **kwargs):
"""Instruct the light to turn on."""
self._api.setdevicebrightness(