How to Extract All Your Custom IR Hex Codes from a Broadlink RM Mini 3 for Homebridge

The homebridge-broadlink-rm plugin for homebridge allows you to automate your devices which have an IR (infrared) remote by emitting those button codes from a Broadlink RM Mini3. You can add individual “buttons” that exist in the RM Mini’s iPhone app (e-Control), by adding the button’s hex code to homebridge’s configuration file (~/.homebridge/config.json).

The homebridge plugin provides a way to obtain these codes, one-at-a-time, by using the “Learn” button it adds to your Home app. You tap the Learn button, then point your remote at the RM Mini3 and hit the button you want to be able to control. The hex code can then be retrieved from the homebridge log file.

However, if you have numerous remotes with numerous buttons already programmed into the RM Mini3, and some remotes in a drawer, some without batteries, this can be a quite long and tedious process. I personally had 238 individual codes programmed into my RM Mini3 and some of my remotes took coin batteries that were dead and I had no replacements on hand. So I wanted a way to grab all of the codes at once without having to manually re-record all of the button presses. I worked out the process to do this last night, and googling this stuff was rather laborious, so I am posting what I learned here.

Here is my setup:

  1. Broadlink RM Mini3
  2. MacBook running Catalina 10.15.6
  3. iPhone running iOS 13.6
  4. Homebridge running on a Raspberry Pi B3

I will not be reviewing how to get homebridge or the Broadlink plugin working.

  1. Download and install iExplorer on your Mac
  2. Connect your iPhone to your Mac using a USB/Lightning cable
  3. Click the iPhone in a Finder window’s left pane (Note: iPhone Synching has moved from the old iTunes app to the Finder)
  4. Click “Trust” on the Finder window to trust your iPhone
  5. Unlock your iPhone and tap “Trust” when the dialog appears prompting you to trust your computer
  6. Launch iExplorer (Click the “Demo” mode button). It may take some time for the app to process the data on your phone.
  7. Click “Backup” and then “Backup Explorer” in the left pane
  8. Expand the “Apps” selection
  9. Drag the folder named “cn.com.broadlink.e-Control” to a location in the Finder (e.g. your desktop)
  10. Download, install, and launch an app called DB Browser for SQLite
  11. In the “cn.com.broadlink.e-Control” folder you saved on your computer, locate and drag the e-Control database file “cn.com.broadlink.e-Control/Documents/BroadLinkDeviceList.sqlite” onto the DB Browser for SQLite app
  12. Click the “Execute SQL” tab
  13. In the top left text area, paste the following SQL query (without the quotes): “select s.name, b.name, c.buttonID, c.codeID, hex(c.code) from broadlink_subir as s left join broadlink_button as b using(subirID) left join broadlink_code as c using(buttonID)
  14. Click in the resulting table in the pane below and copy its contents (e.g. command-a to select all and command-c to copy)
  15. Paste the results into a text file (e.g. using Text Edit.app) or excel document
  16. Use the hex codes in the last column to add accessories to your homebridge config file. (The columns are Remote name, Button Name, Button ID, Code ID, and Hex Code. Note, if you created any combo buttons that send a series of codes, there will be repeated hex codes and Button IDs.)

Here’s an example of what you will get:

TV Power 171 177 26003C00211A3E1A20000B97201A211A3E1A201A211A201A211A201A2037201A3F1A20000B962119211A3E1A211A201A201A211A201A2136211A3E1A20000D05000000000000000000000000
TV Source 172 178 26004E00211A3E1A211A201A211A201A2037201A211A3E1A211A20000B96211A3E1A201A211A201A211A2036211A201A3F1A201A20000B97201A3F19211A201A211A201A2037201A211A3E1A211A20000D0500000000000000000000

And here’s an example of an accessory entry in the config.json file:

            {
                "name":"TV",
                "type":"outlet",
                "data":{
                    "on":"26004e002119211a3e1a211a201a2119211a201a2136211a3e1a21000b96201a211a3e1a201a211a201a211a201a213621193f1a20000b96201a211a3e1a201a211a201a211a201a2136201a3f1a20000d0500000000000000000000",
                    "off":"26004e002119211a3e1a211a201a2119211a201a2136211a3e1a21000b96201a211a3e1a201a211a201a211a201a213621193f1a20000b96201a211a3e1a201a211a201a211a201a2136201a3f1a20000d0500000000000000000000"
                }
            },

You will have to restart homebridge after adding accessories so that the new controls show up in your Home app on your iPhone.