Migrate ihc light to color_mode (#69280)

pull/69291/head
Erik Montnemery 2022-04-04 18:28:30 +02:00 committed by GitHub
parent 25d9d14bd9
commit cb79126cd9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 8 additions and 8 deletions

View File

@ -5,7 +5,8 @@ from ihcsdk.ihccontroller import IHCController
from homeassistant.components.light import ( from homeassistant.components.light import (
ATTR_BRIGHTNESS, ATTR_BRIGHTNESS,
SUPPORT_BRIGHTNESS, COLOR_MODE_BRIGHTNESS,
COLOR_MODE_ONOFF,
LightEntity, LightEntity,
) )
from homeassistant.core import HomeAssistant from homeassistant.core import HomeAssistant
@ -78,6 +79,12 @@ class IhcLight(IHCDevice, LightEntity):
self._dimmable = dimmable self._dimmable = dimmable
self._state = False self._state = False
if self._dimmable:
self._attr_color_mode = COLOR_MODE_BRIGHTNESS
else:
self._attr_color_mode = COLOR_MODE_ONOFF
self._attr_supported_color_modes = {self._attr_color_mode}
@property @property
def brightness(self) -> int: def brightness(self) -> int:
"""Return the brightness of this light between 0..255.""" """Return the brightness of this light between 0..255."""
@ -88,13 +95,6 @@ class IhcLight(IHCDevice, LightEntity):
"""Return true if light is on.""" """Return true if light is on."""
return self._state return self._state
@property
def supported_features(self):
"""Flag supported features."""
if self._dimmable:
return SUPPORT_BRIGHTNESS
return 0
async def async_turn_on(self, **kwargs): async def async_turn_on(self, **kwargs):
"""Turn the light on.""" """Turn the light on."""
if ATTR_BRIGHTNESS in kwargs: if ATTR_BRIGHTNESS in kwargs: