def all_colour(hue, saturation, brightness): lights = lifx.get_lights() # hue, saturation, brightness, kelvin, fade_time) # [ 0x0000, 0x0000, 0xffff, 6500, 10000 ] paramsTest = [hue, saturation, brightness, 3500, 50] print(paramsTest) lifx.set_color(*([BROADCAST_ADDR] + paramsTest))
def run(self): sys.stderr.write('party thread launched') #print( "C:self.threadPartyRun: "+str(self.threadPartyRun)) #print( "C:killThreads: "+str(killThreads)) while( (not killThreads) and (self.threadPartyRun) ): #Loop #print( "C:loooop ") for addr in BulbListSelected: #Loop through all bulbs hue = random.randint(1, 65534) #Randomize hue brightness = (random.randint(0, 1)) * 65534 #Randomize brightness #set_color(self, hue, saturation, brightness, kelvin, fade_time): #BulbListSelected[addr].set_color( hue, 65535, brightness, 3500, 400) lifx.set_color(addr, hue, 65535, brightness, 3500, 400) usleep(100) #sleep during 100ms lifx.pause(0.01)
def light_set_colour(light_addr, hue, saturation, brightness): hue = int(hue) saturation = int(saturation) brightness = int(brightness) # pre-scale hue, TODO integrate into checks.. hue = hue / 360 * 100 if hue > 100 or saturation > 100 or brightness > 100 \ or hue < 0 or saturation < 0 or brightness < 0: raise Exception("Only accepting percentages between 0 and 100") scaling_coef = 65535/100 cnvt = lambda val: int(val * scaling_coef) # set colour params = map(cnvt, [hue, saturation, brightness]) paramsTest = list(params) + [3500, 50] print(paramsTest) lifx.set_color(light_addr, *paramsTest)
#!/usr/bin/env python3 import sys from binascii import unhexlify from struct import unpack import lifx def fromhex(datum): return unhexlify(bytes(datum, encoding='utf-8')) def intfromhex(datum): return unpack('>H',fromhex(datum))[0] lights = lifx.get_lights() for L in sys.stdin: L = L.strip('\n') (addr, hue, saturation, brightness, kelvin) = L.split(' ') lifx.set_power(addr, True) lifx.set_color(addr, intfromhex(hue), intfromhex(saturation), intfromhex(brightness), int(kelvin), 10000)
#!/usr/bin/env python3 import sys from binascii import unhexlify from struct import unpack import lifx def fromhex(datum): return unhexlify(bytes(datum, encoding='utf-8')) def intfromhex(datum): return unpack('>H', fromhex(datum))[0] lights = lifx.get_lights() for L in sys.stdin: L = L.strip('\n') (addr, hue, saturation, brightness, kelvin) = L.split(' ') lifx.set_power(addr, True) lifx.set_color(addr, intfromhex(hue), intfromhex(saturation), intfromhex(brightness), int(kelvin), 10000)
def set_color(): for addr in BulbListSelected: #BulbListSelected[addr].set_color( BulbListSelected[addr].hue, BulbListSelected[addr].saturation, BulbListSelected[addr].brightness, BulbListSelected[addr].kelvin, 300) lifx.set_color(addr, BulbListSelected[addr].hue, BulbListSelected[addr].saturation, BulbListSelected[addr].brightness, BulbListSelected[addr].kelvin, 500) lifx.pause(0.01) #0.2