This follows up on the Feature Requests thread “Support for more universal remote controls”.
I am able to control and automate my unsmart IR devices through Home Assistant:
The toggle “Regarder TV”, which stands for “Watch TV”, for instance, is turning ON my TV, my DAC and HiFi amp.
“Eteindre TV” turns off everything.
I also have a web interface that I use to turn my smartphone (or any smart device) into a universal remote.
Tutorial
Hardware parts
-
Raspberry Pi and its accessories. Needs to be connected to your network. It can be the one your are running HASS on (my case) or another one or several ones.
-
IR emitter on the Pi’s GPIO
* Easy/Lazy solution (I went for this one): purchase an IR extension board for the Pi ([http://www.ebay.fr/itm/IR-infrared-remote-Shield-V1-0-expansion-Transceivers-Module-for-Raspberry-pi-B-/291205297766](http://www.ebay.fr/itm/IR-infrared-remote-Shield-V1-0-expansion-Transceivers-Module-for-Raspberry-pi-B-/291205297766) or [http://www.aliexpress.com/item/Original-Raspberry-Pi-Accessories-RPI-Infrared-Remote-control-IR-Receiver-and-Transiver-2-in-1-Module/32243792691.html](http://www.aliexpress.com/item/Original-Raspberry-Pi-Accessories-RPI-Infrared-Remote-control-IR-Receiver-and-Transiver-2-in-1-Module/32243792691.html), for example) * DIY solution: there are a bunch of tutorials online ([http://alexba.in/blog/2013/06/08/open-source-universal-remote-parts-and-pictures/](http://alexba.in/blog/2013/06/08/open-source-universal-remote-parts-and-pictures/)) and it is not so difficult. If you want to customize your hardware setup, this is probably the best solution.
In any case, carefully note the GPIO on which your emitter and receiver are wired as you’ll need those values later.
Software
Raspberry Pi side
For the record, all credits should go to Alex Bain for his Open Source Universal Remote as I mainly followed his tutorials for this part. I’ll be putting a lot of links directly to his website. Hope that’s fine.
You have to install LIRC (Linux Infrared Remote Control) on your Raspberry Pi.
sudo apt-get install lirc
Then, you have three files to upgrade:
Edit /boot/config.txt
by adding:
#Added for lirc_rpi
dtoverlay=lirc-rpi,gpio_in_pin=18,gpio_out_pin=17
Replace 18 and 17 by the adequate values for your setup.
Reboot your Pi.
Edit /etc/modules
by adding:
lirc_dev
lirc_rp
Change /etc/lirc/hardware.conf
to:
#/etc/lirc/hardware.conf
Arguments which will be used when launching lircd
LIRCD_ARGS=“–uinput”
#Don’t start lircmd even if there seems to be a good config file
#START_LIRCMD=false
#Don’t start irexec, even if a good config file seems to exist.
#START_IREXEC=false
#Try to load appropriate kernel modules
LOAD_MODULES=true
Run “lircd --driver=help” for a list of supported drivers.
DRIVER=“default”
usually /dev/lirc0 is the correct setting for systems using udev
DEVICE=“/dev/lirc0”
MODULES=“lirc_rpi”
Default configuration files for your hardware if any
LIRCD_CONF=“”
LIRCMD_CONF=“”
Restart lircd:
sudo /etc/init.d/lirc stop
sudo /etc/init.d/lirc start
Lirc is installed!
You then have to test your receiver and emitter, and create configuration files for each of your remotes.
I suggest that you follow directly Alex Bain explanations there:
http://alexba.in/blog/2013/01/06/setting-up-lirc-on-the-raspberrypi/, starting from “Testing the IR receiver” section.
You’ll have to be patient as this can take a while.
Once your remotes are configured and you can control your IR devices through command lines, move on to the web part.
Intsall NodeJS
: http://alexba.in/blog/2013/01/15/installing-nodejs-on-your-raspberrypi/
Install lirc_web
: https://github.com/alexbain/lirc_web/blob/master/README.md
The web interface is accessible at: http://IP_OF_YOUR_PI:3000/
What is awesome with lirc_web
is that it supports macros
which allow you to sned IR commands to several appliances in sequence with a delay that you can define.
Home Assistant side
Since lirc_web
provides RESTful API and there is a HASS RESTful Switch component, this part was quite straightforward
I have included only the commands that I am using from HASS, either for the control panel or for automations:
- Macros:
- platform: rest resource: http://IP_OF_YOUR_PI:3000/macros/Regarder%20TV name: "Regarder TV" - platform: rest resource: http://IP_OF_YOUR_PI:3000/macros/Eteindre%20TV name: "Eteindre TV" - platform: rest resource: http://IP_OF_YOUR_PI:3000/macros/Ecouter%20Musique%20NAS name: "Ecouter Musique NAS"
- Basic keys:
- platform: rest resource: http://IP_OF_YOUR_PI:3000/remotes/SamsungTV/KEY_PAUSE name: "TV Pause" - platform: rest resource: http://IP_OF_YOUR_PI:3000/remotes/SamsungTV/KEY_PLAY name: "TV Play" - platform: rest resource: http://IP_OF_YOUR_PI:3000/remotes/Harman-Kardon_HK3490/KEY_MUTE name: "Mute Amp"