Broadlink e-control to yaml

I think I have sorted it, I copied my remotes to the e Control cloud and then deleted the app, reinstalled it and downloaded the remotes from the cloud. I then ran your script and I now have code in each switch. I’m on to the next stage now of how to integrate my Broadlink RMs into HA. Learning as I go.


nicely done!!
all you now need to do is copy that what you have in the yaml into your HA configuration on the right place.
then restart HA and if copied to the right places you have your switches in HA.

@ReneTode Thanks for the python3 version and outputting directly in YAML!!!
You R0X0r!

1 Like

Hi to All,
I need some help regarding 2 issues:

  1. I cannot install simplejson. I tried (via SSH) sudo apt-get install simplejson…and pip install simplejson…but the same result …5. Unable to locate package simplejson

Anyway, after move the directory Broadlink-e-control-db-dump-master in the same place where are located the configuration.yaml file…I run > python…but it seems that i cannot found the file…(cant’t open file …Errno 2 no such file or directory.

I copied correctly the 3 requested files fron android in the same directory of…py file…

Anyone could help me??..i’m no so much expert…maybe I’m wrong in some procedure steps…
Thanks so much.

try sudo apt-get install python-simplejson

Please show us what you type and what it responds with as well as what’s in the directory that you are in.

1 Like

thanks keithh666…simplejson has been installed.

but I have still the problem to run the command python

I do from pi@hassbian: $

this is my directory structure (Samba):

…inside Broadlink-econtro-db-dump-master directory

Thanks again for your help…

When you type python -V what do you get? or python3 -V


What directory are you in when you do python3

I think root.

maybe I have to do:
cd /home/homeassistant/.homeassistat/Broadlink-econtro-db-dump-master…and then run the command??

…I’m going to try.

1 Like

That would be correct or you can put in the full pathname before the filename :slight_smile:

WOW…Now working…Thanks a lot for your time.

No worries glad you have it working :slight_smile:

1 Like

Are there some remote controls that cannot be added to home assistant or maybe even the broad link device?

I struggled with one remote for an Arlec Air Conditioner, I captured multiple clicks off the remote and compared them and they are quite different.

Output from script for the same button (which has worked great for other devices, thanks)

    friendly_name: kitchenfan kitchenlight
    command_on: 'JgAnAAkHGgcaBxoHGhgJBxoIGhgJBwABFgcaGQkGGxgJBxoYCQcaCAANBQA='
    friendly_name: kitchenfan kitchenlight2
    command_on: 'JgAjABgICBoZCAcaGQgIGgcaBxoHGggZGQkHGgcaBxoIAAE/AA0FAAAAAAA='
    friendly_name: kitchenfan kitchenlight3
    command_on: 'JgAkAAgHGhgJBxoZCAgZCBoHGgcaBxoZCAgaBxkIGgcaBQABPgANBQAAAAA='
    friendly_name: kitchenfan kitchenlight4


I think some use a rolling code, so those won’t work :frowning:

That sounds likely, thanks.

I was having the same problem as described by Paul. It is caused by some small errors in the code. Below corrected version. In this version you need to select the ID, not the row of the ID.

Good luck!

# -*- coding: utf-8 -*-

This script will "parse" the broadlink e-Control Android application "SharedData" json files and dump the IR / RF codes for selected accessories into a text file which can be later used with broadlink-python to send the codes to the RM PRO hub

Just connect your Android device to your computer and browse the SD card / External Storage folder "/broadlink/newremote/SharedData/"
You need to get the following files:


and put them in the same folder as this script.

run: python


import simplejson as json
import codecs

buttonIDS = []
buttonNames = []

jsonSubIr = open("jsonSubIr").read()
jsonSubIrData = json.loads(jsonSubIr)

for i in range(0, len(jsonSubIrData)):
    print("ID:", jsonSubIrData[i]['id'], "| Name:", jsonSubIrData[i]['name'])

choice = input("Select accessory ID: ")

for i in range(0, len(jsonSubIrData)):
    if jsonSubIrData[i]['id'] == int(choice):
        accessory_name = jsonSubIrData[i]['name']
        print("[+] You selected: ", accessory_name)

jsonButton = open("jsonButton").read()
jsonButtonData = json.loads(jsonButton)

for i in range(0, len(jsonButtonData)):
    if str(jsonButtonData[i]['subIRId']) == str(choice):

jsonIrCode = open("jsonIrCode").read()
jsonIrCodeData = json.loads(jsonIrCode)

print ("[+] Dumping HEX codes to " + accessory_name + ".txt")
print ("[+] Dumping yaml to " + accessory_name + ".yaml")

codesFile = open(accessory_name + '.txt', 'w')
yamlFile = open(accessory_name + '.yaml', 'w')

groupstext = "\n\n\ngroup:\n"
groupstext = groupstext + "  " + accessory_name + ":\n"
groupstext = groupstext + "    name: " + accessory_name + "\n"
groupstext = groupstext + "    view: yes\n"
groupstext = groupstext + "    entities:\n"

yamltext = "    switches:\n"

for i in range(0, len(jsonIrCodeData)):
    for j in range(0, len(buttonIDS)):
        if jsonIrCodeData[i]['buttonId'] == buttonIDS[j]:
            code = ''.join('%02x' % (i & 0xff) for i in jsonIrCodeData[i]['code'])
            code_b64 = codecs.encode(codecs.decode(code, 'hex'), 'base64').decode()
            result = "Button Name: " + buttonNames[j] + " | Button ID: " + str(jsonIrCodeData[i]['buttonId']) + " | Code: " + code
            namepart = buttonNames[j].replace(" ","_")
            yamltext = yamltext + "      " + accessory_name + "_" + namepart + ":\n"
            yamltext = yamltext + "        friendly_name: " + accessory_name + " " + buttonNames[j] + "\n"
            yamltext = yamltext + "        command_on: '" + code_b64[:-1] + "'" + "\n"
            groupstext = groupstext + "      - switch." + accessory_name + "_" + namepart + "\n"


thx. i did rewrite that code in the beginning from my python learning.
and because i didnt use it much after that i never bothered to make it better.

Hello guys!

I’ve compiled this Python script into an executable Windows program for easy of use. You don’t even need Python installed on the machine.

Here is a video showing how it works:

Here is the program:!7N91xabJ!NXVBw6tSe8RIoCVaULGB5rJ5uUB8nsWTR4nJPgrBLC8

VirusTotal results (just for peace of mind, you can create your own if you want :slight_smile:):

You just need to copy the files jsonSubIr, jsonButton and jsonIrCode from the Android phone, located on “/broadlink/newremote/SharedData/”.

Used this method to compile the program:

I hope it helps!


Just gave it a try and a BIG thanks to you. Worked like a charm.

1 Like