Fix Homematic transition function on light devices with multiple channels (#45725)
* Update light.py Fix Transition function on devices with multiple channels * Update light.py fix Flake8 Warning W293 blank line contains whitespace
This commit is contained in:
parent
993261e7f5
commit
b1626f0091
1 changed files with 7 additions and 2 deletions
|
@ -9,6 +9,7 @@ from homeassistant.components.light import (
|
|||
SUPPORT_COLOR,
|
||||
SUPPORT_COLOR_TEMP,
|
||||
SUPPORT_EFFECT,
|
||||
SUPPORT_TRANSITION,
|
||||
LightEntity,
|
||||
)
|
||||
|
||||
|
@ -53,7 +54,8 @@ class HMLight(HMDevice, LightEntity):
|
|||
@property
|
||||
def supported_features(self):
|
||||
"""Flag supported features."""
|
||||
features = SUPPORT_BRIGHTNESS
|
||||
features = SUPPORT_BRIGHTNESS | SUPPORT_TRANSITION
|
||||
|
||||
if "COLOR" in self._hmdevice.WRITENODE:
|
||||
features |= SUPPORT_COLOR
|
||||
if "PROGRAM" in self._hmdevice.WRITENODE:
|
||||
|
@ -95,7 +97,7 @@ class HMLight(HMDevice, LightEntity):
|
|||
def turn_on(self, **kwargs):
|
||||
"""Turn the light on and/or change color or color effect settings."""
|
||||
if ATTR_TRANSITION in kwargs:
|
||||
self._hmdevice.setValue("RAMP_TIME", kwargs[ATTR_TRANSITION])
|
||||
self._hmdevice.setValue("RAMP_TIME", kwargs[ATTR_TRANSITION], self._channel)
|
||||
|
||||
if ATTR_BRIGHTNESS in kwargs and self._state == "LEVEL":
|
||||
percent_bright = float(kwargs[ATTR_BRIGHTNESS]) / 255
|
||||
|
@ -123,6 +125,9 @@ class HMLight(HMDevice, LightEntity):
|
|||
|
||||
def turn_off(self, **kwargs):
|
||||
"""Turn the light off."""
|
||||
if ATTR_TRANSITION in kwargs:
|
||||
self._hmdevice.setValue("RAMP_TIME", kwargs[ATTR_TRANSITION], self._channel)
|
||||
|
||||
self._hmdevice.off(self._channel)
|
||||
|
||||
def _init_data_struct(self):
|
||||
|
|
Loading…
Add table
Reference in a new issue