Fibaro Light fixes (#18972)

* minor fixes to color scaling

* capped input to fibaro on setcolor
This commit is contained in:
pbalogh77 2018-12-04 11:38:21 +01:00 committed by Paulus Schoutsen
parent b65bffd849
commit 2a0c2d5247
2 changed files with 18 additions and 11 deletions

View file

@ -303,11 +303,14 @@ class FibaroDevice(Entity):
def call_set_color(self, red, green, blue, white):
"""Set the color of Fibaro device."""
color_str = "{},{},{},{}".format(int(red), int(green),
int(blue), int(white))
red = int(max(0, min(255, red)))
green = int(max(0, min(255, green)))
blue = int(max(0, min(255, blue)))
white = int(max(0, min(255, white)))
color_str = "{},{},{},{}".format(red, green, blue, white)
self.fibaro_device.properties.color = color_str
self.action("setColor", str(int(red)), str(int(green)),
str(int(blue)), str(int(white)))
self.action("setColor", str(red), str(green),
str(blue), str(white))
def action(self, cmd, *args):
"""Perform an action on the Fibaro HC."""