From b1626f00917d1041d138dd8d495d1702c964d15d Mon Sep 17 00:00:00 2001
From: Michael Cicogna <44257895+miccico@users.noreply.github.com>
Date: Fri, 19 Mar 2021 12:36:03 +0100
Subject: [PATCH] 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
---
 homeassistant/components/homematic/light.py | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/homeassistant/components/homematic/light.py b/homeassistant/components/homematic/light.py
index 11731e2ae5f..036034bf801 100644
--- a/homeassistant/components/homematic/light.py
+++ b/homeassistant/components/homematic/light.py
@@ -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):