Extend knx brightness with rgb brightness if brightness addres… (#33152)
* Extend knx brightness with rgb brightness if brightness addresses are not supported * Fix explicit return value * Check for None * Remove not needed check * Disable false positive pylint warning Co-authored-by: Martin Hjelmare <marhje52@gmail.com>pull/34434/head
parent
5007a9e702
commit
2faa3af51f
|
@ -180,9 +180,13 @@ class KNXLight(Light):
|
|||
@property
|
||||
def brightness(self):
|
||||
"""Return the brightness of this light between 0..255."""
|
||||
if not self.device.supports_brightness:
|
||||
return None
|
||||
return self.device.current_brightness
|
||||
if self.device.supports_brightness:
|
||||
return self.device.current_brightness
|
||||
hsv_color = self._hsv_color
|
||||
if self.device.supports_color and hsv_color:
|
||||
# pylint: disable=unsubscriptable-object
|
||||
return round(hsv_color[-1] / 100 * 255)
|
||||
return None
|
||||
|
||||
@property
|
||||
def hs_color(self):
|
||||
|
@ -192,6 +196,14 @@ class KNXLight(Light):
|
|||
rgb, _ = self.device.current_color
|
||||
return color_util.color_RGB_to_hs(*rgb) if rgb else None
|
||||
|
||||
@property
|
||||
def _hsv_color(self):
|
||||
"""Return the HSV color value."""
|
||||
rgb = None
|
||||
if self.device.supports_rgbw or self.device.supports_color:
|
||||
rgb, _ = self.device.current_color
|
||||
return color_util.color_RGB_to_hsv(*rgb) if rgb else None
|
||||
|
||||
@property
|
||||
def white_value(self):
|
||||
"""Return the white value."""
|
||||
|
|
Loading…
Reference in New Issue