-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathfunctions.py
More file actions
63 lines (46 loc) · 1.42 KB
/
Copy pathfunctions.py
File metadata and controls
63 lines (46 loc) · 1.42 KB
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
60
61
62
63
import constants
# Turns the lights on or off.
def state(value, my_devices):
if "on" in value.lower() or "true" in value.lower():
for x in my_devices:
my_devices[x].writeAction(1, "01")
if "off" in value.lower() or "false" in value.lower():
for x in my_devices:
my_devices[x].writeAction(1, "00")
# Changes the brightness of the lights.
def brightness(value, my_devices):
value = hex(value)[2:]
if len(value) == 1:
value = "0" + value
try:
my_devices[constants.lights.light1].writeAction(2, value)
except:
print("Error. " + value + " did not work. Consult Jackson for help.")
# Changes the warmth of the light
def warmth(value, my_devices):
try:
my_devices[constants.lights.light1].writeAction(3, value)
except:
print("Error. " + value + " did not work. Consult Jackson for help.")
# Changes the color of the lights.
def color(value, my_devices):
if "#" in value:
value = value[1:]
colors = {
"red": "FF0000",
"orange": "FF7E00",
"yellow": "FFFF00",
"green": "00FF00",
"blue": "0000FF",
"purple": "FF00FF",
"white": "FFFFFF"
}
try:
if value in colors:
my_devices[constants.lights.light1].writeAction(4, colors[value])
else:
my_devices[constants.lights.light1].writeAction(4, value)
except:
print("Error. " + value + " did not work. Consult Jackson for help.")
def error():
print("Please enter a valid input!")