Browse Source

v1

master
Andreas Demmelbauer 3 years ago
parent
commit
e14e282bec
3 changed files with 57 additions and 22 deletions
  1. +14
    -3
      README.md
  2. +42
    -19
      ir-remote-timer.py
  3. +1
    -0
      requirements.txt

+ 14
- 3
README.md View File

@@ -1,5 +1,5 @@
```
sudo apt install git python3-pip
sudo apt install git python3-pip lirc
```

### Clone this repo
@@ -26,7 +26,18 @@ sudo systemctl daemon-reload



### Setting up a random remote
Use `irrecord` to create a lirc Config file and copy the generated file in
### Setting up the infrared
Use `irrecord` to create a lirc Config file. You need an ir receiver for that.
`sudo irrecord -d /dev/lirc0`
and copy the generated file in
`/etc/lirc/lircd.conf.d/your-remotes-name.lircd.conf`

remove devinput
`mv /etc/lirc/lircd.conf.d/devinput.lircd.conf /etc/lirc/lircd.conf.d/devinput.lircd.conf.dist`

Add following lines to `/etc/modules`
```
lirc_dev
lirc_rpi gpio_out_pin=22
```
https://indibit.de/raspberry-pi-mit-lirc-infrarot-befehle-senden-irsend/

+ 42
- 19
ir-remote-timer.py View File

@@ -1,34 +1,57 @@
from py_irsend import irsend
from datetime import datetime
import schedule
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:
schedule.run_pending()
time.sleep(1)


# Webserver
reactor.iterate()

+ 1
- 0
requirements.txt View File

@@ -1,2 +1,3 @@
py_irsend
schedule
twisted

Loading…
Cancel
Save