def set_light_color(self, light, color): color_converter = Converter() if type(light) is phue.Light: light.on = True if type(color) is list: light.xy = color else: try: light.xy = color_converter.hexToCIE1931(color) except socket.timeout: pass light.brightness = 254 elif type(light) is WirelessLights: light.on() if type(color) is list: # limitless can't handle this light.white() elif type(color) is int: light.setColorInt(color) else: light.setColorHSL(self.convert_color(color)) light.setBrightness(100)
import sys import os from qhue import Bridge from rgb_cie import Converter f = open("hue_id.txt", "r") hue_id = f.readlines()[-1].rstrip() f.close() b = Bridge(hue_id, "elbLovRPUcHaqss904iEJMH9LZrRwsvFeOKSfvOP") lights = b.lights converter = Converter() b.lights(1, 'state', on=True, xy=converter.hexToCIE1931(sys.argv[-4])) b.lights(2, 'state', on=True, xy=converter.hexToCIE1931(sys.argv[-3])) b.lights(3, 'state', on=True, xy=converter.hexToCIE1931(sys.argv[-2])) b.lights(4, 'state', on=True, xy=converter.hexToCIE1931(sys.argv[-1]))