If you have been following my blog you may remember one of my earlier projects where I created an IR blaster with a Wemos D1 mini that I use to control my TV via Home Assistant. Today I am going to list the steps use an off the shelf IR blaster with Home Assistant. The main reason to use an off the shelf device is that the hard work has already been done for you and it is in a neat attractive box rather than a led stuck in front of your set.
A friend of mine wanted to do similar to what I had done and turn his TV set off with a shout out to his Google Home. He already had Home Assistant running so it was just a matter of setting up an IR blaster. He was not fond of my DIY device, so we went with a Broadlink RM Mini 3 from Banggood.com. This device is a small black plastic cylinder that sits on his shelf opposite his TV. Their main use is to control your Devices from the Broadlink app that is available on IOS or Android. The Broadlink RM Mini 3 is nicely made and rather cheap (under $20 when we purchased it) while the app is free and ok I guess, it does require you to set up a Broadlink account in order to configure the device to your network. While the app lets you control your device from your phone there is nothing stopping you removing the app once the device is on your network if your only intention is to control it via Home Assistant.
The first step is to download the Broadlink app from the Apple App store or the Google Play Store. Broadlink seem to have 3 apps available, I used the one with the Blue B logo (called Broadlink – Universal Remote) which was a fairly clean design. Setting up the device is a straight forward process and once you set up an account you will hit the + icon in the top right corner followed by add device. The app will ask you for your Wi-Fi password and then try and discover your new device. Once the app finds your device it will join the device to your network.
Once your device is on the network it is best to reserve its IP address in your router, this is due to the fact that you need to add the IP address to your home assistant configuration.yaml file. If your router reboots your device may get a new IP address and stop communications with Home Assistant. Every router is different, so I won’t cover how to do that here, in my tp-link router this setting was under Advanced / LAN Settings then Address Reservation (you would need to look for similar terminology in your router). To find the devices IP address you can check the Broadlink app or the Windows program called Broadlink Manager that we are going to download next.
In order to get your Broadlink RM mini talking to home assistant we are going to need to add your remote codes as a switch in your configuration.yaml. An example of my configuration with the on and off codes of my Samsung TV is listed below. In order to get a copy of the code I used a free Windows program known as Broadlink Manger that can be downloaded here.
The program is pretty straight forward. When you open it up hit scan and it will find your device and list its IP and mac address (something you will want to note down for your Home Assistant config). From the Learn New Command select Learn Infrared and proceed to point your remote at the RM Mini device. The program will spit out 2 long strings of text and prompt you to name the command. This will be helpful if you are learning a lot of IR codes. You can even save the commands to a text file that you can load with Broadlink Manager later on to send and test your learned commands or as what will do, copy out the desired base64 code for use with Home Assistant.
To use the device with Home Assistant you will need to edit your configuration.yaml file and add a switch like in my example. Further examples are also shown over at the Home Assistant website.
Below you will see I have a separate command for both on and off of my Samsung TV, if your TV only has a power toggle than you will need to add that single base64 code twice. The downfall of that is you do not know what mode your TV is in, so adding this to an automation may lead to your TV turning off when you want it to turn on and vise versa. Fortunately despite my Samsung TV remote having only a power toggle button I found that the TV does support on and off by experimenting with different models with my Logitech Harmony remote. Your results my vary with other brands and devices as not all brands would have implemented a full set of IR commands. The command_on and command_off string listed below is the base64 string we copied from Broadlink Manager earlier.
Example from my configuration.yaml
switch: - platform: broadlink host: 192.168.1.79 mac: c8:f7:XX:XX:XX:XX type: rm_mini timeout: 30 switches: tv: friendly_name: "Samsung TV" command_on: 'JgDSAI+SFDYUNhM3ExISEhQSEhITERQ2EzcTNhQSExETEhMRFBITNhQRExETNxQ2ExMSEhM3ExETNxM3ExITEhM2FDYTEhMABfuVkxM2FDYUNhMSExITERMSExEUNhQ2FDYTEhMSExETEhMSEzcTERMSFDUUNhMTExETNxMSEjcTNxMSExITNhQ2FBETAAX8lJMTNxM2FDYTEhMSExITERMSEzcTNhQ2FBETEhMRExMTERM3ExETExM2FDUUEhMREzcTEhM2EzcTExMREzcTNhQREwANBQAAAAAAAA==' command_off: 'JgDQABM3EzcTNhQQFBEUEhMRExITNhM3EzcTEhQRExEUERQSEhITERMSEzcTNxMSExETNxM3EzYUNhMSExITNxM3ExISAAX8lZITNxM3EzcTERMSFBETERMSFDYTNhQ2ExMTERMSExEUEhISExITEhM2FDYTEhMREzcTNxM3EzYUDhcREzcTNxMREwAF/JWSFDYUNhM3ExISExMRExITERQ2FDYUNRQSExETEhMSExITERMTEhITNxM2FBETERQ2EzcTNxM3ExEUERQ2EzcTEhMADQUAAAAAAAAAAA=='
Wrap Up
I’ve had this Broadlink RM Mini up and running at a friends house for several months and it has been very reliable. He also has a Samsung TV so by using the separate on and off commands we were able to send a turn off command as part of his good night routine that turns off many other lights in his house. I have not checked if this device phones home to China at any point of the day, if that is of a concern to you, I would look into the possibility of putting these cheap Chinese made devices behind some sort of firewall. This should not affect operation with Home Assistant as this appears to be all local communications.
Resources
My Wemos D1 mini IR Blaster with Tasmota
Broadlink Apple app
Broadlink Android app
Broadlink Manager
Broadlink RM Mini 3 at banggood.com