def flow(flow, *args): B.turn_on() print('flowing', flow) try: method = getattr(flows, flow) flow = method(*args) except AttributeError as e: print(e) exit(1) B.start_flow(flow)
#!/usr/bin/env python3 from time import sleep from bulb_ip import B B.turn_on() for i in (range(0, 101)): try: B.set_brightness(i) print('good ', i) except BulbException as e: print('error', i, e) sleep(5)
#!/usr/bin/env python3 from yeelight import RGBTransition, Flow from bulb_ip import B from state import get_state color = int(get_state(props=['rgb'])['rgb']) b = color & 0xff color >>= 8 g = color & 0xff color >>= 8 r = color & 0xff pink = RGBTransition(0xff, 0x16, 0x94, 500, 100) pink = RGBTransition(0xff, 0x00, 0xff, 500, 100) current = RGBTransition(r, g, b, 500, 100) transitions = [pink if i % 2 == 0 else current for i in range(9)] flow = Flow(count=1, transitions=transitions) B.start_flow(flow)
group = parser.add_mutually_exclusive_group() group.add_argument("flow", nargs='*', help="the flow method", default="random_loop") group.add_argument("-s", "--stop", help="stop flowing", action="store_true") group.add_argument("-l", "--list", help="list all flows", action="store_true") group.add_argument("-d", "--description", help="show the description of a flow", type=str) args = parser.parse_args() if args.list: print(list_flows()) elif args.stop: B.stop_flow() elif args.description: print(show_description(args.description)) else: if type(args.flow) == list: flow_name, args = (args.flow[0], list(map(int, args.flow[1:]))) else: flow_name, args = (args.flow, []) flow(flow_name, *args)
#!/usr/bin/env python3 from time import sleep from sys import argv from bulb_ip import B sleep(float(argv[1])) for i in reversed(range(0, 101, 2)): try: B.set_brightness(i) print('good ', i) except BulbException as e: print('error', i, e) sleep(5) while True: try: B.turn_off() break except: pass
#!/usr/bin/env python3 from bulb_ip import B if __name__ == '__main__': state = B.get_properties(requested_properties=['power'])["power"] if state == "on": B.turn_off() else: B.turn_on()
#!/usr/bin/env python3 from bulb_ip import B from sys import argv if len(argv) > 1: temp = 3400 brig = 77 else: temp = 4700 brig = 100 B.turn_on() B.set_hsv(0, 0) B.set_brightness(brig) B.set_color_temp(temp)
#!/usr/bin/env python3 from yeelight import Bulb, BulbException, Flow, RGBTransition from time import sleep from random import uniform from bulb_ip import B from sys import argv B.turn_on() if len(argv) > 1: flow = Flow(count=0, transitions= [RGBTransition(255, 0, 255, duration=1000)]) B.start_flow(flow) sleep(400) else: while True: c = int(uniform(1, 0xffffff)) color = hex(c).replace('0x','').rjust(6,'0') r = color[0:2] g = color[2:4] b = color[4:6] try: B.set_rgb(int(r, 16), int(g, 16), int(b, 16)) print('good ', r, g, b) except BulbException as e: print('error', r, g, b, e) sleep(2)
def get_state(props=[ 'power', 'bright', 'ct', 'rgb', 'hue', 'sat', 'flowing', 'delayoff', 'flow_params' 'music_on' ]): return B.get_properties(requested_properties=props)