def _command(self, action, value, success, failure, **kwargs):
if action == Device.TURNON:
self.light.brightness = 1
self.light.power = True
elif action == Device.TURNOFF:
self.light.power = False
elif action == Device.DIM:
self.light.brightness = value/255.0
self.light.power = True
elif action == Device.RGBW:
r = (value >> 24) & 0xFF
g = (value >> 16) & 0xFF
b = (value >> 8) & 0xFF
(h, s, l) = colorsys.rgb_to_hsv(r/255.0, g/255.0, b/255.0)
self.light.color = lifx.color.modify_color(self.light.color, hue=h*360.0, saturation=s)
self.light.power = True
else:
failure(0)
return
success()
评论列表
文章目录