Migrate niko_home_control light to color_mode (#70914)
* Migrate niko_home_control light to color_mode * Remove useless brightness related codepull/71004/head
parent
cdafbbe10f
commit
603c7c8980
|
@ -8,7 +8,7 @@ import nikohomecontrol
|
|||
import voluptuous as vol
|
||||
|
||||
# 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.core import HomeAssistant
|
||||
from homeassistant.exceptions import PlatformNotReady
|
||||
|
@ -51,6 +51,9 @@ async def async_setup_platform(
|
|||
class NikoHomeControlLight(LightEntity):
|
||||
"""Representation of an Niko Light."""
|
||||
|
||||
_attr_color_mode = ColorMode.ONOFF
|
||||
_attr_supported_color_modes = {ColorMode.ONOFF}
|
||||
|
||||
def __init__(self, light, data):
|
||||
"""Set up the Niko Home Control light platform."""
|
||||
self._data = data
|
||||
|
@ -58,7 +61,6 @@ class NikoHomeControlLight(LightEntity):
|
|||
self._unique_id = f"light-{light.id}"
|
||||
self._name = light.name
|
||||
self._state = light.is_on
|
||||
self._brightness = None
|
||||
|
||||
@property
|
||||
def unique_id(self):
|
||||
|
@ -70,11 +72,6 @@ class NikoHomeControlLight(LightEntity):
|
|||
"""Return the display name of this light."""
|
||||
return self._name
|
||||
|
||||
@property
|
||||
def brightness(self):
|
||||
"""Return the brightness of the light."""
|
||||
return self._brightness
|
||||
|
||||
@property
|
||||
def is_on(self):
|
||||
"""Return true if light is on."""
|
||||
|
@ -82,7 +79,6 @@ class NikoHomeControlLight(LightEntity):
|
|||
|
||||
def turn_on(self, **kwargs):
|
||||
"""Instruct the light to turn on."""
|
||||
self._light.brightness = kwargs.get(ATTR_BRIGHTNESS, 255)
|
||||
_LOGGER.debug("Turn on: %s", self.name)
|
||||
self._light.turn_on()
|
||||
|
||||
|
|
Loading…
Reference in New Issue