Lifx.py 文件源码

python
阅读 20 收藏 0 点赞 0 评论 0

项目:tellstick-server-plugins 作者: telldus 项目源码 文件源码
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()
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号