implement wh colorwheel

This commit is contained in:
Johannes
2022-05-28 22:15:06 +02:00
parent e7ab9f5265
commit 4c8decc934
2 changed files with 4 additions and 3 deletions

View File

@@ -258,7 +258,7 @@ class LuiController(object):
if button_type == "colorWheel": if button_type == "colorWheel":
self._ha_api.log(value) self._ha_api.log(value)
value = value.split('|') value = value.split('|')
color = pos_to_color(int(value[0]), int(value[1])) color = pos_to_color(int(value[0]), int(value[1]), int(value[2]))
self._ha_api.log(color) self._ha_api.log(color)
self._ha_api.get_entity(entity_id).call_service("turn_on", rgb_color=color) self._ha_api.get_entity(entity_id).call_service("turn_on", rgb_color=color)

View File

@@ -11,8 +11,9 @@ def hsv2rgb(h, s, v):
hsv = colorsys.hsv_to_rgb(h,s,v) hsv = colorsys.hsv_to_rgb(h,s,v)
return tuple(round(i * 255) for i in hsv) return tuple(round(i * 255) for i in hsv)
def pos_to_color(x, y): def pos_to_color(x, y, wh):
r = 160/2 #r = 160/2
r = wh/2
x = round((x - r) / r * 100) / 100 x = round((x - r) / r * 100) / 100
y = round((r - y) / r * 100) / 100 y = round((r - y) / r * 100) / 100