forked from Hadjimina/JasperModules
-
Notifications
You must be signed in to change notification settings - Fork 0
/
hue.py
executable file
·50 lines (34 loc) · 1005 Bytes
/
hue.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
# -*- coding: utf-8-*-
import random
import re
from datetime import datetime, time
from phue import Bridge
WORDS = ["TURN", "LIGHTS", "ON","OFF"]
def handle(text, mic, profile):
bridgeip = profile['bridgeip']
b = Bridge(bridgeip)
b.connect()
lights = b.lights
global message
message = ""
if "on" in text.lower():
for l in lights:
l.on = True
l.brightness = 254
message = "All Lights have been turned on"
elif "off" in text.lower():
for l in lights:
l.on = False
message = "All Lights have been turned off."
now = datetime.now()
now_time = now.time()
if now_time >= time(21,30) and now_time <= time(02,00):
message += "Good Night"
mic.say(message)
def isValid(text):
"""
Returns True if the input is related to the meaning of life.
Arguments:
text -- user-input, typically transcribed speech
"""
return bool(re.search(r'\b(turn (all|the) lights)\b', text, re.IGNORECASE))