Using a Physical Remote Control With HA

I have a TV, HDMI splitter, and soundbar in my basement that do not have smart capabilities. Right now I have an old universal remote with some macros programmed to control the various pieces but sometimes they don’t quite work right and my youngest child struggles to get the remote to do what he wants.

I’d like to simplify things without spending a ton of money on a fancy remote (it’s not our primary TV area). I have a Broadlink RM Mini lying around and figured that Home Assistant might be my answer. I am able to map the commands and use HA to control the various devices which is great. However, I’d like to still have a physical remote to kick off the scripts (using an app 100% of the time isn’t ideal for my wife and kids) and I haven’t had much luck there.

As I understand it the Broadlink is one way only and can’t receive IR commands from a remote. I also read up on IR Receivers like Flirc but I believe that requires the HA server to be in the room (HA runs on Docker on my NAS) so that’s out. I looked at Zigbee remotes but those all seem to be specific to lights.

Has anyone found a way to use an existing IR remote to control devices through Home Assistant? I’m guessing I’m out of luck but hoping someone found a creative solution.

DIY?

ESPHome has an IR receiver component that works with HA.

I did this

What I did is use a RF remote (e.g. https://www.amazon.fr/gp/product/B019B9GYPA/ref=ppx_yo_dt_b_search_asin_title?ie=UTF8&psc=1), which comes with an USB dongle, basically emulating a keyboard.

You can get the keypresses events via the “keyboard_remote” integration

A tad troublesome to configure, but no hardware required.

1 Like

Thank you everyone for the suggestions. This gives me a few things to try. I’ll hopefully have time to look into this more over the next few weeks and see if I can make one of these work.

Old thread, but sparsely discussed topic. I’m down the path of mapping a bluetooth remote, and I can see the Events come thru for some buttons, but a lot of the ‘multimedia’ buttons, such as play/pause, next/back, vol up/down do not show up. My suspicion is these are more system-level ‘keyboard’ buttons, and they’re not getting passed to HA. Great example is, the BT remote I’m testing has a power button (pretty typical of what you’d expect on any TV remote) — that button out-of-the-box powers down my RasPi HA box! not ideal. Anyone else dealt with this?

Be careful that those remotes typically have multiple devices.
Example of mine

$ ll /dev/input/by-id/
[...]
lrwxrwxrwx 1 root root   9 déc 31 10:42 usb-1912_2.4G_Composite_Devic-event-if01 -> ../event8
lrwxrwxrwx 1 root root   9 déc 31 10:42 usb-1912_2.4G_Composite_Devic-event-kbd -> ../event6
lrwxrwxrwx 1 root root   9 déc 31 10:42 usb-1912_2.4G_Composite_Devic-if01-event-mouse -> ../event7
lrwxrwxrwx 1 root root   9 déc 31 10:42 usb-1912_2.4G_Composite_Devic-if01-mouse -> ../mouse1

Yep. Typically, those button are intercepted by the system, and handled like if you had pressed an ACPI button on the system case. It’s only an issue with the power button, afaik, though.
I actually disabled sleep on my system to workaround this (I cannot actually remember how I did it, but that was through systemd on my Ubuntu system).

Thanks @koying for the nudge in the right direction! I was able to solve both of these (and use the power button!). Here’s what I did:

Media Buttons:
To “see” all the other missing buttons, you are absolutely right, it shows up as multiple devices. I just mapped all of the /dev/input/by-id/ devices that were relevent to the BT remote, and sure enough, I see those events firing and can capture them.

Power Button:

  • Disable the default ACPI mapping of the power button: Full details are here, but here’s the gist of it in case that link ever dies
    • Edit /etc/systemd/logind.conf and uncomment #HandlePowerKey=poweroff and change it from poweroff to ignore. I did this on the SuspendKey and HibernateKey just to be safe. Probably not needed.
    • Restart logind service: sudo systemctl restart systemd-logind
    • Now the button doesnt power off the system. Good start :slight_smile:
  • Install acpid so we can see the button event: sudo apt-get install acpid
  • Run sudo acpi_listen and press the power button. we’ll see the button/power PBTN acpi event.
  • redirect the acpi event to call a bash script
    • create a file in /etc/acpi/events named button_power (no file extension)
    • Put this in the file:
event=power (PBTN)
action=/etc/acpi/powerbtn.sh

Restart acpid now: sudo service acpid restart
Now create that bash script one dir level down: sudo nano /etc/acpi/powerbtn.sh
And make it executable: sudo chmod +x /etc/acpi/powerbtn.sh

Here’s where we could probably improve this solution: I wasn’t sure if/how I could send an Event into HA directly from the script. So I chose to have the contents of this script report the button push into MQTT, so I can read it from there. A bit of a round-about way of doing this, but it works. Improvement would be a way to send this straight to HA’s Events.

In any event, here’s my powerbtn.sh for reference:

#!/bin/sh

HOST="IP or hostname"
TOPIC="homeassistant/remote/powerbutton"
MESSAGE="1"
USERNAME="username"
PASSWORD="password"

mosquitto_pub -h "${HOST}" -p 1883 -t "${TOPIC}" -m "${MESSAGE}" -u "${USERNAME}" -P "${PASSWORD}"

(also need to have mosquitto-clients installed if you don’t already)

This process works for me, and I do indeed get the 1 payload on my MQTT broker at homeassistant/remote/powerbutton topic. From here it’s trivial to action on this in HA.

1 Like

Mmm… I didn’t do any of the above beyond disabling the handling of the suspend button in systemd.
Once that is done, I could trap the event like any button, in one of the “event” devices. At least I could do it that way in my case.

I’ve bought the exact same airmouse/keyboard/universal remote thingamajic that koying linked to in June '22.
I have captured all the “keyboard” keycodes such as A-Z and 0-9. Let me know if there’s interest and I’d be happy to share them.

I found out the hard way though that most of the “universal remote” keys such als Vol+/Vol- or FFWD/RWD are not beeing captured that way. Neither are they transmitted via IR. Apparently, IR only covers the four color keys on the keyboard. So I guess the “multimedia keys” are system keys as outlined in jbishop129’s post. I have yet to figure out how to make them useable in HA. If that’s even possible at all.