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