Migrate niko_home_control light to color_mode (#70914)

* Migrate niko_home_control light to color_mode

* Remove useless brightness related code
This commit is contained in:
Erik Montnemery 2022-04-28 13:45:18 +02:00 committed by GitHub
parent cdafbbe10f
commit 603c7c8980
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -8,7 +8,7 @@ import nikohomecontrol
import voluptuous as vol import voluptuous as vol
# Import the device class from the component that you want to support # Import the device class from the component that you want to support
from homeassistant.components.light import ATTR_BRIGHTNESS, PLATFORM_SCHEMA, LightEntity from homeassistant.components.light import PLATFORM_SCHEMA, ColorMode, LightEntity
from homeassistant.const import CONF_HOST from homeassistant.const import CONF_HOST
from homeassistant.core import HomeAssistant from homeassistant.core import HomeAssistant
from homeassistant.exceptions import PlatformNotReady from homeassistant.exceptions import PlatformNotReady
@ -51,6 +51,9 @@ async def async_setup_platform(
class NikoHomeControlLight(LightEntity): class NikoHomeControlLight(LightEntity):
"""Representation of an Niko Light.""" """Representation of an Niko Light."""
_attr_color_mode = ColorMode.ONOFF
_attr_supported_color_modes = {ColorMode.ONOFF}
def __init__(self, light, data): def __init__(self, light, data):
"""Set up the Niko Home Control light platform.""" """Set up the Niko Home Control light platform."""
self._data = data self._data = data
@ -58,7 +61,6 @@ class NikoHomeControlLight(LightEntity):
self._unique_id = f"light-{light.id}" self._unique_id = f"light-{light.id}"
self._name = light.name self._name = light.name
self._state = light.is_on self._state = light.is_on
self._brightness = None
@property @property
def unique_id(self): def unique_id(self):
@ -70,11 +72,6 @@ class NikoHomeControlLight(LightEntity):
"""Return the display name of this light.""" """Return the display name of this light."""
return self._name return self._name
@property
def brightness(self):
"""Return the brightness of the light."""
return self._brightness
@property @property
def is_on(self): def is_on(self):
"""Return true if light is on.""" """Return true if light is on."""
@ -82,7 +79,6 @@ class NikoHomeControlLight(LightEntity):
def turn_on(self, **kwargs): def turn_on(self, **kwargs):
"""Instruct the light to turn on.""" """Instruct the light to turn on."""
self._light.brightness = kwargs.get(ATTR_BRIGHTNESS, 255)
_LOGGER.debug("Turn on: %s", self.name) _LOGGER.debug("Turn on: %s", self.name)
self._light.turn_on() self._light.turn_on()