mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 21:27:38 +00:00
Migrate control4 light to color_mode (#69079)
This commit is contained in:
parent
fd6cedeeb8
commit
8ee9695e3b
@ -11,7 +11,8 @@ from pyControl4.light import C4Light
|
|||||||
from homeassistant.components.light import (
|
from homeassistant.components.light import (
|
||||||
ATTR_BRIGHTNESS,
|
ATTR_BRIGHTNESS,
|
||||||
ATTR_TRANSITION,
|
ATTR_TRANSITION,
|
||||||
SUPPORT_BRIGHTNESS,
|
COLOR_MODE_BRIGHTNESS,
|
||||||
|
COLOR_MODE_ONOFF,
|
||||||
SUPPORT_TRANSITION,
|
SUPPORT_TRANSITION,
|
||||||
LightEntity,
|
LightEntity,
|
||||||
)
|
)
|
||||||
@ -164,6 +165,12 @@ class Control4Light(Control4Entity, LightEntity):
|
|||||||
device_id,
|
device_id,
|
||||||
)
|
)
|
||||||
self._is_dimmer = is_dimmer
|
self._is_dimmer = is_dimmer
|
||||||
|
if is_dimmer:
|
||||||
|
self._attr_color_mode = COLOR_MODE_BRIGHTNESS
|
||||||
|
self._attr_supported_color_modes = {COLOR_MODE_BRIGHTNESS}
|
||||||
|
else:
|
||||||
|
self._attr_color_mode = COLOR_MODE_ONOFF
|
||||||
|
self._attr_supported_color_modes = {COLOR_MODE_ONOFF}
|
||||||
|
|
||||||
def create_api_object(self):
|
def create_api_object(self):
|
||||||
"""Create a pyControl4 device object.
|
"""Create a pyControl4 device object.
|
||||||
@ -188,7 +195,7 @@ class Control4Light(Control4Entity, LightEntity):
|
|||||||
def supported_features(self) -> int:
|
def supported_features(self) -> int:
|
||||||
"""Flag supported features."""
|
"""Flag supported features."""
|
||||||
if self._is_dimmer:
|
if self._is_dimmer:
|
||||||
return SUPPORT_BRIGHTNESS | SUPPORT_TRANSITION
|
return SUPPORT_TRANSITION
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
async def async_turn_on(self, **kwargs) -> None:
|
async def async_turn_on(self, **kwargs) -> None:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user