forked from ddxtanx/GoveeAPI
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathtool.py
59 lines (57 loc) · 2.13 KB
/
tool.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
from controller import *
import time
from math import floor
import argparse
import signal
from constants import *
"""
To parse device option passed to command line, enter in device names (bed, window, shelf, etc)
followed by an list consisting of their address. If you have a 'scene' like a bedroom consisting
of multiple devices, enter them all into the list.
Include 'all' as a list of all of your device addresses as well.
"""
name_addr_dict = {"led":"00:11:22:33:44:55"
}
ps = argparse.ArgumentParser(description="Govee Home Control Script")
device_choices = device_names.append("all")
ps.add_argument('--mode', default="set", type=str, choices=device_modes)
ps.add_argument('--device', default="led", type=str, choices=device_choices)
ps.add_argument('--brightness', type=int)
ps.add_argument('--color', nargs=3, type=int)
ps.add_argument('--period', type=float)
ps.add_argument('--music', type=str, choices=music_modes)
ps.add_argument('--scene',type=str,choices=scene_modes)
args = ps.parse_args()
chosen_devices = [name_addr_dict[args.device]]
if args.mode == "set":
device = "led" ## can remove if more than one device added for simplicity
if args.brightness is not None:
bright = args.brightness
for device in chosen_devices:
change_brightness(bright, device)
if args.color is not None and args.music is None:
colort = tuple(args.color)
for device in chosen_devices:
change_color(colort, device)
if args.music is not None:
music = args.music
colort=tuple(args.color)
for device in chosen_devices:
change_music(music, colort, device)
if args.scene is not None:
scene = args.scene
for device in chosen_devices:
change_scene(scene,device)
elif args.mode == "on":
for device in chosen_devices:
turn_on(device)
elif args.mode == "off":
for device in chosen_devices:
turn_off(device)
elif args.mode == "strobe":
latency = args.period
change_brightness_both(255)
while True:
for addr in chosen_devices:
change_color(gen_rand_color(), addr)
time.sleep(latency)