Skip to content
Snippets Groups Projects
Commit 5f9d6e4c authored by jkerdreu's avatar jkerdreu
Browse files

Fix brightness on hsv once again. This produce swings in home-assistant UI.



git-svn-id: https://redmine.imt-atlantique.fr/svn/xaal/code/Python/branches/0.7@2958 b32b6428-25c9-4566-ad07-03861ab6144f
parent 4b9af2f7
No related branches found
No related tags found
No related merge requests found
......@@ -186,10 +186,10 @@ class RGBW(YeelightDev):
target = round((duration / 1000.0), 1)
# we schedule some get_properties at the end of the flow to update the current color
# As time drift, don't expect to have it working for a 1 hour flow.
if duration > 1000:
self.dev.engine.add_timer(self.get_properties, target, 1)
self.dev.engine.add_timer(self.get_properties, target+0.5, 1)
@spawn
def set_white_temperature(self, _white_temperature):
val = int(_white_temperature)
......@@ -227,11 +227,11 @@ class RGBW(YeelightDev):
bright = props.get('current_brightness', None)
rgb = props.get('rgb', None)
if bright and not rgb:
if bright:
attrs['brightness'] = int(bright)
hsv = list(attrs['hsv'])
hsv[2] = round(int(bright)/100.0, 2)
attrs['hsv'] = hsv
#hsv = list(attrs['hsv'])
#hsv[2] = round(int(bright)/100.0, 2)
#attrs['hsv'] = hsv
# Yeelight Python API provide both rgb and hsv values
# we parse both, even if we don't' issue set_hsv
# sat ?
......@@ -247,6 +247,7 @@ class RGBW(YeelightDev):
# hsv[0] = int(hue)
# attrs['hsv']=hsv
if rgb:
rgb = int(rgb)
r = (rgb >> 16) / 255
......@@ -255,6 +256,7 @@ class RGBW(YeelightDev):
hsv = colorsys.rgb_to_hsv(r, g, b)
h = round(hsv[0] * 360)
s = round(hsv[1], 2)
v = round(hsv[2], 2)
s = hsv[1]
v = hsv[2]
attrs['hsv'] = [h, s, v]
#attrs['brightness'] = int(hsv[2] * 100)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment