Migrate ihc light to color_mode (#69280)
parent
25d9d14bd9
commit
cb79126cd9
|
@ -5,7 +5,8 @@ from ihcsdk.ihccontroller import IHCController
|
|||
|
||||
from homeassistant.components.light import (
|
||||
ATTR_BRIGHTNESS,
|
||||
SUPPORT_BRIGHTNESS,
|
||||
COLOR_MODE_BRIGHTNESS,
|
||||
COLOR_MODE_ONOFF,
|
||||
LightEntity,
|
||||
)
|
||||
from homeassistant.core import HomeAssistant
|
||||
|
@ -78,6 +79,12 @@ class IhcLight(IHCDevice, LightEntity):
|
|||
self._dimmable = dimmable
|
||||
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
|
||||
def brightness(self) -> int:
|
||||
"""Return the brightness of this light between 0..255."""
|
||||
|
@ -88,13 +95,6 @@ class IhcLight(IHCDevice, LightEntity):
|
|||
"""Return true if light is on."""
|
||||
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):
|
||||
"""Turn the light on."""
|
||||
if ATTR_BRIGHTNESS in kwargs:
|
||||
|
|
Loading…
Reference in New Issue