Improve precision of Hue color state (#14113)
This commit is contained in:
1 parent
9d1f9fe204
commit
0b350993b5
2 files changed
+7
-30
No files matched your search
@@ -242,26 +242,16 @@ class HueLight(Light):
|
||||
@property
|
||||
def hs_color(self):
|
||||
"""Return the hs color value."""
|
||||
# pylint: disable=redefined-outer-name
|
||||
mode = self._color_mode
|
||||
|
||||
if mode not in ('hs', 'xy'):
|
||||
return
|
||||
|
||||
source = self.light.action if self.is_group else self.light.state
|
||||
|
||||
hue = source.get('hue')
|
||||
sat = source.get('sat')
|
||||
if mode == 'xy' and 'xy' in source:
|
||||
return color.color_xy_to_hs(*source['xy'])
|
||||
|
||||
# Sometimes the state will not include valid hue/sat values.
|
||||
# Reported as issue 13434
|
||||
if hue is not None and sat is not None:
|
||||
return hue / 65535 * 360, sat / 255 * 100
|
||||
if mode == 'hs' and 'hue' in source and 'sat' in source:
|
||||
return source['hue'] / 65535 * 360, source['sat'] / 255 * 100
|
||||
|
||||
if 'xy' not in source:
|
||||
return None
|
||||
|
||||
return color.color_xy_to_hs(*source['xy'])
|
||||
return None
|
||||
|
||||
@property
|
||||
def color_temp(self):
|
||||
|
||||
Reference in new issue
Block a user