Migrate homeworks light to color_mode (#69271)

This commit is contained in:
Erik Montnemery 2022-04-04 18:20:48 +02:00 committed by GitHub
parent 3416e9b621
commit 1c1b792fb7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -7,7 +7,7 @@ from pyhomeworks.pyhomeworks import HW_LIGHT_CHANGED
from homeassistant.components.light import ( from homeassistant.components.light import (
ATTR_BRIGHTNESS, ATTR_BRIGHTNESS,
SUPPORT_BRIGHTNESS, COLOR_MODE_BRIGHTNESS,
LightEntity, LightEntity,
) )
from homeassistant.const import CONF_NAME from homeassistant.const import CONF_NAME
@ -44,6 +44,9 @@ def setup_platform(
class HomeworksLight(HomeworksDevice, LightEntity): class HomeworksLight(HomeworksDevice, LightEntity):
"""Homeworks Light.""" """Homeworks Light."""
_attr_color_mode = COLOR_MODE_BRIGHTNESS
_attr_supported_color_modes = {COLOR_MODE_BRIGHTNESS}
def __init__(self, controller, addr, name, rate): def __init__(self, controller, addr, name, rate):
"""Create device with Addr, name, and rate.""" """Create device with Addr, name, and rate."""
super().__init__(controller, addr, name) super().__init__(controller, addr, name)
@ -60,11 +63,6 @@ class HomeworksLight(HomeworksDevice, LightEntity):
) )
self._controller.request_dimmer_level(self._addr) self._controller.request_dimmer_level(self._addr)
@property
def supported_features(self):
"""Supported features."""
return SUPPORT_BRIGHTNESS
def turn_on(self, **kwargs): def turn_on(self, **kwargs):
"""Turn on the light.""" """Turn on the light."""
if ATTR_BRIGHTNESS in kwargs: if ATTR_BRIGHTNESS in kwargs: