mirror of
https://github.com/home-assistant/core.git
synced 2025-07-09 22:37:11 +00:00
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>
This commit is contained in:
parent
5007a9e702
commit
2faa3af51f
@ -180,9 +180,13 @@ class KNXLight(Light):
|
|||||||
@property
|
@property
|
||||||
def brightness(self):
|
def brightness(self):
|
||||||
"""Return the brightness of this light between 0..255."""
|
"""Return the brightness of this light between 0..255."""
|
||||||
if not self.device.supports_brightness:
|
if self.device.supports_brightness:
|
||||||
return None
|
return self.device.current_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
|
@property
|
||||||
def hs_color(self):
|
def hs_color(self):
|
||||||
@ -192,6 +196,14 @@ class KNXLight(Light):
|
|||||||
rgb, _ = self.device.current_color
|
rgb, _ = self.device.current_color
|
||||||
return color_util.color_RGB_to_hs(*rgb) if rgb else None
|
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
|
@property
|
||||||
def white_value(self):
|
def white_value(self):
|
||||||
"""Return the white value."""
|
"""Return the white value."""
|
||||||
|
Loading…
x
Reference in New Issue
Block a user