Skip to content

Instantly share code, notes, and snippets.

@HeadHodge
Last active August 12, 2021 16:29
Show Gist options
  • Save HeadHodge/3919e495f8b2e17db64666087b07529b to your computer and use it in GitHub Desktop.
Save HeadHodge/3919e495f8b2e17db64666087b07529b to your computer and use it in GitHub Desktop.
How I use Hassio as a Universal Ir Remote

How I use Hassio as a Universal Ir Remote

OVERVIEW:

Hello, 😀

I've been using Hassio for over a year now and am generally happy with it. I use it to control fireplaces, shades, lights, etc., but mainly use it to control my entertainment systems.

For my Ir blaster, I currently use a Broadcom's RM Mini3

For a fun project I wanted to use a PI-4b and make it a media-bridge to control mainly my entertainment devices via Wifi, Bluetooth, and Ir. Very much like a Harmony Hub, but without the Harmony Hub. Because the Broadcom is a standalone device, I need to find an Ir blaster that works with the PI-4b

Raspberry PI-4b:

The PI-4b already comes with Wifi and bluetooth capability, but no Ir feature is provided. After looking around I found the irDroid, a usb dongle Ir transceiver:

The irDroid claims to be compatible with linux based lirc and windows WinLirc. Although it works with WinLirc, it does not with lirc. After some research, it turns out that lirc is deprecated in the newer versions of the linx kernel and is replaced by the linux core ir device support. It turns out to be simple to use. Just plug in the irDroid into a usb port on the PI-4b and use the ir-ctl and ir-keyTables commands to receive and send Ir commands with the Ir dongle.

Now that my Ir device is working, I need a way to control it with Hassio. To do this, I wrote some simple python code that runs on the linux box that the usb dongle is plugged into. It connects to the dongle via the linux ir-ctl system command. Then I use pythons Web Sockets to connect to Hassio's websocket API and use it to subscribe to a custom Scripts service event, named 'publish_note', that I configured on Hassio in the cofiguration yaml file. An example of sending the custom event looks like:

hassio

In the example, I click on the call service button which in turn generates the publish_note event. Since my little python code is connected to Hassio and subscribed to the 'publish_note' event, my code is notified and receives the event via the web sockets connection.

My code takes the events controlWord, in this exanple it's 'Ok', and looks it up in a table to get the equivalent Ir data needed to blast Ir to my Ir devices with the ir-ctl 'send' command option. My Ir eqipment receives the Ir blast and is fooled into thinking you just pressed the 'Ok' key on a keyboard or a remote control.

Repeat sending new Hassio events as needed with various controlWords to control your Ir based devices. I believe the irDroid only supports devices using the Ir 38k Hz frequebcy.

Overall it works great. It's speedy and stable. I'm really liking the interface with Hassio using subscribed custom events. Because web sockets is used, my media-bridge is loosely coupled to the Hassio Hub, I never have to reboot the Hassio Hub if I'm having problems with or wanting to upgrade my new little bridge.

That's it for now. Regards!

more details: https://github.com/HeadHodge/smartHome-Projects-Main/blob/main/smartRemotes/README.md

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment