|
@@ -1,34 +1,57 @@ |
|
|
from py_irsend import irsend |
|
|
from py_irsend import irsend |
|
|
|
|
|
|
|
|
|
|
|
from datetime import datetime |
|
|
import schedule |
|
|
import schedule |
|
|
import time |
|
|
import time |
|
|
|
|
|
|
|
|
|
|
|
# http server |
|
|
|
|
|
from twisted.web import server, resource |
|
|
|
|
|
from twisted.internet import reactor |
|
|
|
|
|
|
|
|
irsend.list_remotes() |
|
|
|
|
|
|
|
|
|
|
|
def turnAllProjectorsOn(): |
|
|
|
|
|
print("turn all projectors on ...") |
|
|
|
|
|
irsend.send_once('logitech_z906', ['POWER']) |
|
|
|
|
|
irsend.send_once('logitech_z906', ['POWER']) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def turnAllProjectorsOff(): |
|
|
|
|
|
print("turn all projectors off ...") |
|
|
|
|
|
irsend.send_once('logitech_z906', ['POWER']) |
|
|
|
|
|
irsend.send_once('logitech_z906', ['POWER']) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#print(irsend.list_remotes()) |
|
|
|
|
|
|
|
|
schedule.every().day.at("21:00").do(turnAllProjectorsOn) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def turnAllProjectorsOn(): |
|
|
|
|
|
print('UTC', datetime.now().time(), "turn all projectors on ...") |
|
|
|
|
|
irsend.send_once('panasonic_resa', ['KEY_POWER']) |
|
|
|
|
|
irsend.send_once('benq_resa', ['KEY_POWER']) |
|
|
|
|
|
|
|
|
schedule.every().day.at("06:00").do(turnAllProjectorsOff) |
|
|
|
|
|
|
|
|
def turnAllProjectorsOff(): |
|
|
|
|
|
print('UTC', datetime.now().time(), "turn all projectors off ...") |
|
|
|
|
|
irsend.send_once('panasonic_resa', ['KEY_POWER']) |
|
|
|
|
|
irsend.send_once('benq_resa', ['KEY_POWER']) |
|
|
|
|
|
time.sleep(2) |
|
|
|
|
|
irsend.send_once('panasonic_resa', ['KEY_POWER']) |
|
|
|
|
|
irsend.send_once('benq_resa', ['KEY_POWER']) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# HTTP Server |
|
|
|
|
|
class Simple(resource.Resource): |
|
|
|
|
|
isLeaf = True |
|
|
|
|
|
def render_GET(self, request): |
|
|
|
|
|
statustext = "" |
|
|
|
|
|
if request.prepath == "on": |
|
|
|
|
|
statustext = "turn all projectors on ..." |
|
|
|
|
|
turnAllProjectorsOn() |
|
|
|
|
|
if request.prepath == "off": |
|
|
|
|
|
statustext = "turn all projectors off ..." |
|
|
|
|
|
turnAllProjectorsOff() |
|
|
|
|
|
else: |
|
|
|
|
|
statustext = "" |
|
|
|
|
|
|
|
|
|
|
|
html = '<b>%s</b>' % statustext |
|
|
|
|
|
return html.encode('utf-8') |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Time definitions in UTC (Vienna is UTC+2) |
|
|
|
|
|
schedule.every().day.at("21:00").do(turnAllProjectorsOn) # 23:00 |
|
|
|
|
|
schedule.every().day.at("01:00").do(turnAllProjectorsOff) # 03:00 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
while True: |
|
|
while True: |
|
|
schedule.run_pending() |
|
|
schedule.run_pending() |
|
|
time.sleep(1) |
|
|
time.sleep(1) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Webserver |
|
|
|
|
|
reactor.iterate() |