Migrate rflink light to color_mode (#69532)

* Migrate rflink light to color_mode

* Add COLOR_MODE_ONOFF
This commit is contained in:
epenet 2022-04-07 09:39:22 +02:00 committed by GitHub
parent d5ab7e7525
commit 75b1760b29
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -8,8 +8,9 @@ import voluptuous as vol
from homeassistant.components.light import ( from homeassistant.components.light import (
ATTR_BRIGHTNESS, ATTR_BRIGHTNESS,
COLOR_MODE_BRIGHTNESS,
COLOR_MODE_ONOFF,
PLATFORM_SCHEMA, PLATFORM_SCHEMA,
SUPPORT_BRIGHTNESS,
LightEntity, LightEntity,
) )
from homeassistant.const import CONF_DEVICES, CONF_NAME, CONF_TYPE from homeassistant.const import CONF_DEVICES, CONF_NAME, CONF_TYPE
@ -177,6 +178,8 @@ class RflinkLight(SwitchableRflinkDevice, LightEntity):
class DimmableRflinkLight(SwitchableRflinkDevice, LightEntity): class DimmableRflinkLight(SwitchableRflinkDevice, LightEntity):
"""Rflink light device that support dimming.""" """Rflink light device that support dimming."""
_attr_color_mode = COLOR_MODE_BRIGHTNESS
_attr_supported_color_modes = {COLOR_MODE_BRIGHTNESS}
_brightness = 255 _brightness = 255
async def async_added_to_hass(self): async def async_added_to_hass(self):
@ -221,11 +224,6 @@ class DimmableRflinkLight(SwitchableRflinkDevice, LightEntity):
"""Return the brightness of this light between 0..255.""" """Return the brightness of this light between 0..255."""
return self._brightness return self._brightness
@property
def supported_features(self):
"""Flag supported features."""
return SUPPORT_BRIGHTNESS
class HybridRflinkLight(DimmableRflinkLight, LightEntity): class HybridRflinkLight(DimmableRflinkLight, LightEntity):
"""Rflink light device that sends out both dim and on/off commands. """Rflink light device that sends out both dim and on/off commands.
@ -260,6 +258,9 @@ class ToggleRflinkLight(SwitchableRflinkDevice, LightEntity):
and if the light is off and 'on' gets sent, the light will turn on. and if the light is off and 'on' gets sent, the light will turn on.
""" """
_attr_color_mode = COLOR_MODE_ONOFF
_attr_supported_color_modes = {COLOR_MODE_ONOFF}
def _handle_event(self, event): def _handle_event(self, event):
"""Adjust state if Rflink picks up a remote command for this device.""" """Adjust state if Rflink picks up a remote command for this device."""
self.cancel_queued_send_commands() self.cancel_queued_send_commands()