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.
This commit is contained in:
phispi 2019-11-01 21:23:23 +01:00 committed by Pascal Vizeli
parent 44879b323e
commit f8d779e840

View file

@ -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)
if not self.device.supports_brightness:
return None
return self.device.current_brightness
@property
def hs_color(self):