import sys from Milight import Milight m = Milight() # ./wrapper.py GRP ON/OFF [-c CLR] [-b BRT] [-w] # GRP; 0:All 1-4:1-4 # CLR; 0-254 # BRT; 0-25 if len(sys.argv)<3: sys.exit("ERROR: too few args\n usage: ./wrapper.py GRP ON/OFF [-c CLR] [-b BRT]") group = int(sys.argv[1]) if sys.argv[2]=="ON": if len(sys.argv)<4: print "ON" m.grp_ctrl(group,True) elif len(sys.argv)<5: if sys.argv[3]=="-w": print "COL" m.white(group) elif len(sys.argv)<6: if sys.argv[3]=="-c": print "COL" m.color(group,int(sys.argv[4])) elif sys.argv[3]=="-b": print "BRT" m.brightness(group,int(sys.argv[4])) else: sys.exit("usage: ./wrapper.py GRP ON/OFF [-c CLR] [-b BRT]") else: sys.exit("ERROR: too many args\n usage: ./wrapper.py GRP ON/OFF [-c CLR] [-b BRT]") else: print "OFF",group
# to be run by a cronjob from Milight import Milight from time import sleep m = Milight() GROUP = 1 INTERVAL = 10 m.grp_ctrl(GROUP, True) # Lights on for group 1 m.brightness(GROUP, 1) # Lower brightness just in case m.color(GROUP, 144) # Set desired starting color # sunrise effect for i in range(25): # this offset should really be implented in the m object... m.brightness(GROUP, i+1) m.color(GROUP, 160-i) sleep(INTERVAL) m.white(GROUP) m.brightness(GROUP, 6) for i in range(21): m.brightness(GROUP, i+5) sleep(INTERVAL)