|
|
@@ -8,6 +8,9 @@ from twisted.web import server, resource |
|
|
|
from twisted.internet import reactor |
|
|
|
|
|
|
|
|
|
|
|
timer = True; |
|
|
|
|
|
|
|
|
|
|
|
#print(irsend.list_remotes()) |
|
|
|
|
|
|
|
|
|
|
@@ -18,18 +21,22 @@ def turnAllProjectorsOn(): |
|
|
|
|
|
|
|
def turnAllProjectorsOff(): |
|
|
|
print('UTC', datetime.now().time(), "turn all projectors off ...") |
|
|
|
irsend.send_once('panasonic_resa', ['KEY_POWER']) |
|
|
|
irsend.send_once('panasonic_resa', ['KEY_POWER2']) |
|
|
|
irsend.send_once('benq_resa', ['KEY_POWER']) |
|
|
|
time.sleep(2) |
|
|
|
irsend.send_once('panasonic_resa', ['KEY_POWER']) |
|
|
|
irsend.send_once('panasonic_resa', ['KEY_POWER2']) |
|
|
|
irsend.send_once('benq_resa', ['KEY_POWER']) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# HTTP Server |
|
|
|
class Simple(resource.Resource): |
|
|
|
isLeaf = True |
|
|
|
|
|
|
|
def render_GET(self, request): |
|
|
|
print(request) |
|
|
|
global timer |
|
|
|
print(request.uri) |
|
|
|
statustext = "" |
|
|
|
if request.uri == b"/on": |
|
|
|
statustext = "turn all projectors on ..." |
|
|
@@ -37,10 +44,19 @@ class Simple(resource.Resource): |
|
|
|
if request.uri == b"/off": |
|
|
|
statustext = "turn all projectors off ..." |
|
|
|
turnAllProjectorsOff() |
|
|
|
|
|
|
|
if request.uri == b"/timer-on": |
|
|
|
timer = True |
|
|
|
|
|
|
|
if request.uri == b"/timer-off": |
|
|
|
timer = False |
|
|
|
|
|
|
|
else: |
|
|
|
statustext = "" |
|
|
|
|
|
|
|
html = '<b> %s </b>' % statustext |
|
|
|
if timer == True: |
|
|
|
statustext = "Timer ist an" |
|
|
|
if timer == False: |
|
|
|
statustext = "Timer ist aus" |
|
|
|
html = '<b>%s</b>' % statustext |
|
|
|
return html.encode('utf-8') |
|
|
|
|
|
|
|
site = server.Site(Simple()) |
|
|
@@ -50,12 +66,13 @@ reactor.startRunning(False) |
|
|
|
|
|
|
|
|
|
|
|
# Time definitions in UTC (Vienna is UTC+2) |
|
|
|
schedule.every().day.at("21:00").do(turnAllProjectorsOn) # 23:00 |
|
|
|
schedule.every().day.at("19:00").do(turnAllProjectorsOn) # 21:00 |
|
|
|
schedule.every().day.at("01:00").do(turnAllProjectorsOff) # 03:00 |
|
|
|
|
|
|
|
|
|
|
|
while True: |
|
|
|
schedule.run_pending() |
|
|
|
if timer == True: |
|
|
|
schedule.run_pending() |
|
|
|
time.sleep(1) |
|
|
|
# Webserver |
|
|
|
reactor.iterate() |