Beispiel #1
0
#!/usr/bin/env python3

import lifx

addr = b'\00\00\00\00\00\00'

lifx.set_power(lifx.BCAST, False)

Beispiel #2
0
#!/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 lifx

# first step is to always ensure all bulbs are on (we do not switch them off, we just set brightness to 0 if we do not want any light)
lifx.set_power(lifx.BCAST, True)



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)
    
Beispiel #4
0
def turn_off_all():
	for addr in BulbListSelected:
		#BulbListSelected[addr].set_power(0)
		lifx.set_power(addr, 0)
	lifx.pause(0.2)
Beispiel #5
0
def set_power(addr, power):
	lifx.set_power(addr, power)
	lifx.pause(0.2)
	return 1
Beispiel #6
0
#!/usr/bin/env python3

import lifx

addr = b'\00\00\00\00\00\00'

lifx.set_power(addr, False)

Beispiel #7
0
def light_power(power_state=False):
    lifx.set_power(BROADCAST_ADDR, power_state)