-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathluna.py
86 lines (85 loc) · 2.9 KB
/
luna.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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
from smartroom import Smartroom
luna = Smartroom()
while luna.text not in luna.configurations["DEFAULT_SLEEP_WORDS"]:
try:
luna.wait_for_wake_word(luna.configurations["DEFAULT_WAKE_WORD"])
print(luna.text)
if luna.response:
try:
luna.perform_naive_bayes_classification()
print(luna)
except:
luna.throw_parameter_exception()
else:
luna.perform_classification()
print(luna)
luna.perform_naive_bayes_classification()
print(luna)
response = luna.perform_request(luna.POST, "login", luna.credentials)
for parameter, (action, state) in luna.response.items():
luna.telegram = False if state == 0 else True
universal, lights, printer, tv = luna.configurations["PARAMETERS"]
if parameter in lights:
luna.perform_request(
luna.PUTS,
"datapoints/1",
luna.telegram,
dict(user=response.text)
)
luna.perform_request(
luna.PUTS,
"datapoints/2",
luna.telegram,
dict(user=response.text)
)
elif parameter in tv:
luna.perform_request(
luna.PUTS,
"datapoints/3",
luna.telegram,
dict(user=response.text)
)
elif parameter in printer:
luna.perform_request(
luna.PUTS,
"datapoints/4",
luna.telegram,
dict(user=response.text)
)
elif parameter in universal:
luna.perform_request(
luna.PUTS,
"datapoints/1",
luna.telegram,
dict(user=response.text)
)
luna.perform_request(
luna.PUTS,
"datapoints/2",
luna.telegram,
dict(user=response.text)
)
luna.perform_request(
luna.PUTS,
"datapoints/3",
luna.telegram,
dict(user=response.text)
)
luna.perform_request(
luna.PUTS,
"datapoints/4",
luna.telegram,
dict(user=response.text)
)
else:
raise NotImplementedError
except Smartroom.ParameterError as e:
print(e)
continue
except NotImplementedError:
continue
except:
print("Smartroom failed to understand the words")
continue
luna.state = luna.BACK
del luna