Don’t get off the couch! Control your TV and Stereo with Home Assistant using the Broadlink IR Bridge

HA Forum for Broadlink Manager

Download Broadlink Manager

HA Docs for Broadlink IR Switches

Welcome back to the World of Home Automation.  If you are a human with electricity, you probably have one of these.  This is the Broadlink RM Pro. And this, is his little brother, the Broadlink RM mini.  In the next few minutes I’ll show you how to use these to control your TV’s, Stereos, projectors or whatever else, with your phone, or with your smart home hub, like for example, oh I don’t know… maybe… Home Assistant!

 

The Pro is able to send and receive both InfraRed and 433mhz (RF) signals and sells for ~$35 dollars.  The Mini on the other hand only communicates with IR devices, not RF, and sells for $15-20. If you want to see how a proper Englishman sets up and uses these RM devices check out Paul Hibbert.  My purpose for using these devices is to control my TV’s and such with Home Assistant, so that’s what Ima show you how to do. I use the Sonoff RF bridge for my RF devices, but I’ll show you how to use the Broadlink Pro for RF.  Sort of…

 

To get started with either of these devices you will need to download the app for android or iphone, cuz that’s how you’re going to get it to connect to your network.

BTW, if you look at reviews for this product, they are pretty bad, but most of those negative reviews are because of the app.  Good news is we’re only going to use the app to connect the RM devices to our Network. After that you can delete it if you want. You’ll never have to open it again.  

For the Setup, open the app, you see I already have the RM Pro connected so let’s connect the Mini. Click the ‘plus’, then add device. It says you should be able to scan the Barcode or the QR code.  I didn’t see a QR code, maybe I threw it away already with the box. I tried scanning the barcode but that didn’t seem to work. Since the barcode didn’t work just select Universal Remote, then Mini, then put in your home Wifi Info.  Once that’s complete you’re going to need to find the IP address and the MAC address of your new Broadlink bridge. I got mine from my router, and while I’m there I reserved that IP address for that device. If you don’t do that then your router may re-assign a new IP address to the broadlink device when the router restarts.  Since that IP is going into your HA configuration, if the IP address changes it’ll screw things up. So I’d say reserving it is pretty much a requirement. Every router is different, so I can’t tell you exactly how to do that with yours. I’m sure you can figure it out. That’s what google is for.

 

Now we have our hub setup, it’s time to start gathering our IR remote codes. Grab all your remote controls and put them in a big pile. There are a couple ways to get the codes from your IR remotes.

I think the best way is using this awesome little program called Broadlink Manager.  Made by this guy. You can read more about it in the HA forums here:

https://community.home-assistant.io/t/broadlink-manager-nicer-way-to-learn-and-send-ir-rf-commands/58770

And you can download it here.

https://sourceforge.net/projects/broadlink-manager/

It’s a .exe file, so it only works on Windows.  Install it, then click “scan”. It should find your Broadlink device.  If it doesn’t you could try adding it manually, but if scan doesn’t work you may have some other problem.  If you didn’t use your router to get the IP and MAC address, you can get them here. Once you’ve got your device connected you can start learning your IR codes.  Get your remotes and your IR Hub, click learn new code, then IR code, then press the button you want to copy. The code won’t show up until you let go. Just hold it a couple seconds then let go.  You should get a bunch of text on the screen and a pop up window for you to name it. It’ll save all the codes with names and you can even test them out right here in Broadlink Manager. The one you need for Home Assistant is the Base64 code.

Now you repeat that process for every button on the remote that you want to emulate.  Usually that’ll be power, volume, and maybe input. But it can be any button. I don’t know about doing a series of buttons, like if you wanted to hit two numbers for a specific channel.  Maybe someone smarter than me can tell us how to do that. You could create a virtual remote on your HA UI and have a screen button for each real button on your remote. That’d be a lot of work, but you could do it.

For my purposes I grabbed codes for a Projector, a Surround Sound Receiver, a TV, and even some LEDs that came with an IR remote control.  I hit save every once in a while, but as far as I could tell it was saving after each learned command. Every code you learn is kept in this file.  You can open it with your favorite code editor (I’m using VS Code on my Win10 machine) to copy the codes later.

 

Next we need to include our new Broadlink hubs in our HA Configuration file.  You add it with these lines, you don’t have to put the “type” but I did in mine, just cuz:

 

switch:
 – platform: broadlink
   host: your.IRhub.IP.address
   mac: ‘your:IR:hub:mac:address’

 

After you have that, check the config then restart HA.  When it comes back up you can go to the services tab and search for ‘broadlink’.  There should be 2 new services. One to set it in “learn” mode and one to “send” a code.  It uses the IP address at the end of the service to distinguish which Broadlink device the service is going to use.  That’s important if you have more than one.

If you don’t have windows, or if you just don’t want to use the Broadlink Manager, this is how you learn your IR remote codes with Home Assistant. On the Services page, select the “learn” service, and click Call Service.  When you see the message in the corner say the service was called, point your remote at the hub and push the button you want to learn. Again, I just held it for a few seconds to be sure it got sent. After that go to the Overview page and you should see a new notification box.  You can’t copy the code from that box, it just lets you know it worked, and will let you dismiss it in a minute. Now go to the States page and search for “broadlink”. You’ll have a sensor entry that’ll contain the code for the button you just pressed. Home Assistant won’t save these codes, so you’ll have to copy and paste them right away into your config file, or another text document to save them.  Once you hit the ‘dismiss’ button on that notification that code will disappear. I used this method to learn a bunch of codes before I found the Broadlink Manager. IMHO the Manager is much better, but it’s good to know how to do it this way too. Especially if you’re anti-windows. Wait, I’m anti-windows…

 

Next step is to start creating switches and automations to make use of all these codes we’ve collected. The first way to do this is to make switches in your Broadlink entry in the config file. Make a new subheading called “switches”, then you create a name for your switch.  This can be anything you want but it has to be in the entity_id format. That is all lowercase and underscore instead of spaces. I guess that’s called a slug. I have no idea why. Next you give it a friendly name, this is what will show up in your UI. Then you put command_on and the code for “on”, and command_off and the code for “off”.  And you must have a command_on and a command_off. Here’s where we run into one of the inconveniences with these Hubs and HA. This format, with command on/off, works fine if you have a remote with an on button, and an off button. But some only have a power button, and that button just toggles the power. What I did for those was to use the same code for on and off.  In the HA UI it looks like it shows the state, but it really doesn’t. If you only use HA to control the TV, then it’s likely the state will match. Meaning when it shows “on” in HA, the TV will actually be ‘on’. But HA isn’t really getting any information about the actual state of the TV. So if you turn it on with HA, but then off with the remote, or with the button on the TV, or if it goes off because of a sleep timer or a poltergeist, it will still look like it is on in HA.  Getting accurate information about the state of the TV isn’t the purpose of this video. If I wanted to to that I might use something like a plug with power sensing and from the current reading I could determine if the TV was on or not. But that’s a topic for another day. I wish there was a single button to press that just sends one command or calls one service. Again, all you guys out there that know more about this than I do can tell me if something like that exists.

I thought this format worked well for volume control though.  Click the ‘on’ it goes up, click the ‘on’ again it goes up more. And of course click ‘off’ and it goes down.

 

Besides creating a switch in the Broadlink component entry you can just use the send-a-code service with the code as the “packet”.  For my Surround Sound receiver, and for my DeskLEDs I created an input_select list, like this:

 

input_select:

 projector_input:

   name: Projector Input

   options:

     – “Roku” #VCR

     – “Cable” #CBL

     – “DVD” #Game

     – “extra” #BD

 

Then I created automations that called the send-a-code service whenever one of those options is selected.  With this I get a menu in the UI and when I select on of those option it sends the right code and magic happens! The automation looks like this.

         

 – alias: Select Projector Input Roku

   trigger:

     – platform: state

       entity_id: input_select.projector_input

       to: “Roku”

   action:

     – service: switch.broadlink_send_packet_192_168_1_66

       data:

         packet: “JgAoAgABJpQTEhM2ExITEhM2FBETNhM3FDYTERQ2FDUUERQ2FD”  

 

 – alias: Select Projector Input Cable

   trigger:

     – platform: state

       entity_id: input_select.projector_input

       to: “Cable”

   action:

     – service: switch.broadlink_send_packet_192_168_1_66

       data:

         packet: “JgDgAQABJpMTEhM3EhITEhM3EhITNxM2EzcTEhM”  

 

 – alias: Select Projector Input DVD

   trigger:

     – platform: state

       entity_id: input_select.projector_input

       to: “DVD”

   action:

     – service: switch.broadlink_send_packet_192_168_1_66

       data:

         packet: “JgDYAgABJJYRExI4ERQRExI4ERQROBE5ETgSExE5ET”  

 

 – alias: Select Projector Input extra

   trigger:

     – platform: state

       entity_id: input_select.projector_input

       to: “extra”

   action:

     – service: switch.broadlink_send_packet_192_168_1_66

       data:

         packet: “JgCYAgABJpMTEhM2FBETEhM2FBETNxM2ExITEhM2EzcTEhM2E”

 

Just to show you another way to do it, I made an input boolean for the power button on my surround sound receiver.  It’s a few simple lines in the config file. Then this is the automation that sends the code when I click that input boolean.

input_boolean:

 receiver:

   name: Projector Sound

   icon: mdi:surround-sound

 

#automations.yaml

alias: Projector Receiver Toggle

 trigger:

   – platform: state

     entity_id: input_boolean.receiver

 action:

   – service: switch.broadlink_send_packet_192_168_1_66

     data:

     packet: “uhwieosdihfdjsvsn4rhesurbwedfsdf”

 

When you change the config file, check it and restart HA before you make the additions to the automations.yaml file.  I’ve had trouble if my automations are looking for entities that I haven’t put into my config yet.

 

Demo time!

 

This has been great for controlling IR enabled devices.  It’s pretty reliable and not too hard to set up. Now, the Pro is supposed to be able to be used with RF (433mhz) devices as well.  Reading forum posts it seems a lot of people have trouble getting it to work with RF, and unfortunately, when I tried it, I ran into the same problems.  Using the Learn Code service from HA and pressing a button on an RF remote, or activating an RF door sensor gave me nothing. I tried it using Broadlink Manager, but that didn’t work either.  Some folks have had success getting the RF devices attached using the e-control broadlink app on android.

I used the following method

Android device required
   1. Install Broadlink e-control app from Play store
   2. Learn your remotes as per normal instructions using e-control.
   3. Tap the burger settings and tap ‘Share’. Tap ‘Share to other phones in WLAN. Tap Cancel.
   4. Install RM Plugin Lite from Play Store
   5. Tap on Device List to import Broadlink device config that was previously shared.
   6. Enable HTTP bridge
   7. Navigate to http://androidipaddress:9876/ 11
   8. Find Code List and click on the link.
   9. Find the code(s) you require.
   10. Use a Hex to base64 converter to encode your codes for HA (http://en.1mu.info/tools/hexbase64.html 21)

 

I use the Sonoff RF bridge for my RF needs.  I could see the appeal of having one device for both IR and RF.  There isn’t a financial benefit to using the pro over the mini+Sonoff Bridge.  The Sonoff bridge is about $15, the mini is about $15, and the Pro is about $30.  One thing to consider is with IR signals you need line-of-sight. So you’re Broadlink device needs to be close to whatever you want to control.  That’s not the case with RF. Your RF bridge can be pretty much anywhere. Mine is on the second floor at my desk and I’m getting signals from sensors in the garage.  If I could get the Pro to learn RF codes as easily as it learns IR codes I’d say it’s worthwhile getting it to serve both purposes. But since getting the RF codes is a bit of a pain, and the Sonoff Bridge with Tasmota is so easy and reliable, I’m going to say that my preference is to have the Broadlink Mini for IR and the Sonoff RF Bridge for RF.  I’m glad I have both the Pro and the Mini though, because again, with the requirement for Line of Sight, I need one in each room where I have IR devices to control. That’s just my opinion, you do what seems best for you.

 

I think that’s it.  The Broadlink IR/RF Bridge.  Very useful and effective for controlling your IR remote controlled devices.  

Similar Posts