From f8d779e84032416c72ea016829670f5f54747d7c Mon Sep 17 00:00:00 2001 From: phispi Date: Fri, 1 Nov 2019 21:23:23 +0100 Subject: [PATCH] Prevent TypeError when KNX RGB(W) light value contains None (#28358) * Prevent TypeError when KNX RGB(W) light value contains None. * Pylint doesn't like 'w' as variable name, therefore using 'white' instead. * Simplified code as suggested by pvizeli. --- homeassistant/components/knx/light.py | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/homeassistant/components/knx/light.py b/homeassistant/components/knx/light.py index 81bf4ad3c83..c7292309461 100644 --- a/homeassistant/components/knx/light.py +++ b/homeassistant/components/knx/light.py @@ -180,13 +180,9 @@ class KNXLight(Light): @property def brightness(self): """Return the brightness of this light between 0..255.""" - if self.device.supports_brightness: - return self.device.current_brightness - if ( - self.device.supports_color or self.device.supports_rgbw - ) and self.device.current_color: - return max(self.device.current_color) - return None + if not self.device.supports_brightness: + return None + return self.device.current_brightness @property def hs_color(self):