diff --git a/README.md b/README.md
index 4bee310..c7f7da0 100644
--- a/README.md
+++ b/README.md
@@ -1,3 +1,6 @@
+remote control devices via infra-red using a timer and web requests.
+
+
```
sudo apt install git python3-pip lirc
```
@@ -22,6 +25,7 @@ pip3 install -r requirements.txt
```
sudo cp ir-remote-timer.service /lib/systemd/system/ir-remote-timer.service
sudo systemctl daemon-reload
+sudo systemctl enable ir-remote-timer.service
```
diff --git a/ir-remote-timer.py b/ir-remote-timer.py
index c679d3e..c4cfe37 100644
--- a/ir-remote-timer.py
+++ b/ir-remote-timer.py
@@ -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 = ' %s ' % statustext
+ if timer == True:
+ statustext = "Timer ist an"
+ if timer == False:
+ statustext = "Timer ist aus"
+ html = '%s' % 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()