Broadlink RM-PRO and TC2 switch

Daniel is a great guy and great programmer … but not in clarity :smiley:

Hehe. :wink:
I am sorry for the confusion.
I am a bit confused my self by all the different Broadlink devices :slight_smile:

that’s alright Daniel. You’ve been great help for all of us. Keep up the good work we do appreciate every time you reply to us. Happy new year everyone!!!

You may be interested on this talk:

1 Like

Thanks. Since my phone is not rooted, I am following the method. Unfortunately, I cannot find jsonSubIr, jsonButton or jsonIrCode files. This is what I see…

Nvm about this. I can view the files via my phone explorer. Don’t know why it is not showing in my PC.


I tried to run the script but it returns this error…

$ python3
  File "", line 32
    print "ID:", jsonSubIrData[i]['id'], "| Name:", jsonSubIrData[i]['name']
SyntaxError: Missing parentheses in call to 'print'

Please help.

Use python2

Thanks. But now I am receiving this error…

$ python2
Traceback (most recent call last):
  File "", line 20, in <module>
    import simplejson as json
ImportError: No module named simplejson

FYI, I installed simplejson using pip3 install simplejson. When I tried to reinstall it using pip, it says…

$ pip install simplejson
Requirement already satisfied: simplejson in /usr/local/lib/python3.4dist-packages

I manage to install Python2 in my Windows PC and manage to generate the text file filed with the TC2 codes. Will try to use the codes in my configuration soon.


I put the codes into my configuration…

  platform: broadlink
  mac: 'AA:AA:AA:AA:AA:AA'
      command_on: 'e9144600df090916091616090916091616091609160916091609160916090916160916091609160909161609091609161609160916090916091609161609160916090916160909000148'
      command_off: 'e9144600df090916091609160916160909161609160909160916091609161609160916091609091616091609160916090916091609160916160916091609160909161609160909000148'

It is not working. Any idea why?

That looks like hex format,
You have to convert it to the correct format,
You can try:

I am sorry. How do I use this…?

from base64 import b64encode, b64decode
hex_data  = "e9144600df090916160916090916091616090916160916090916160916090916160909161609091616091609160916091609160916091609091609160916160909161609091609000148"
packet = hex_data.decode('hex')

OK. If I understand correctly, that is code is in python. So, I modified by adding from base64 import b64encode, b64decode on line 21 and then…


code = ''.join('%02x' % (i & 0xff) for i in jsonIrCodeData[i]['code'])

add this…

        packet = code.decode('hex')
        code = b64encode(packet).decode('utf8')

The generated codes will become something like this…


However, it is still not working :sweat:

I notice this in the log ValueError: Input strings must be a multiple of 16 in length.

I can feel we are getting closer…

@masterkenobi That’s exactly the issue other users are experiencing as well, the code format you get from "" should work directly with “python-broadlink” (for the TC2 rf codes I found that you need to duplicate the code so it will be in the expected length and if you send it should work), but…I don’t know how python-broadlink was integrated into home assistant, the issue is still with the AES encryption, I believe it because of missing padding.

So you say that the code can be used directly as data in the send_data function?

Solving this issue will help:

I do not have the RM-PRO device, so it is hard for me to test this

Btw, here is how we encode the code in hass:


My script just dumps the codes from the e-Control app.

The first method for the rooted devices the codes stored in the rmt.db in binary, when you copy them in hex they work fine with the send_data function, you will still have the length issue (at least for TC2 switches) but if you duplicate the code and send it using the function it works great.

So for example if your code is: abcd you need to send abcdabcd

For the second script the codes are stored in decimal format array so my script converts them to hex which should be the format to use with python-broadlink but you still need to send duplicate code.


import broadlink
import time
import sys

device = broadlink.rm(host=(“IP ADDRESS”,80), mac=bytearray.fromhex(“MAC ADDRESS”))


myhex =“abcdabcd”

print “Code Sent…”

I will do some more tests later today

Btw: I don’t have home assistant installed yet, tried yesterday on a rpi with the one click install script but it failed, I’ll try to install the hassbian so I could see what’s going on

Hmm, then this should work:

hexcode = hexcode + hexcode
packet = hexcode.decode('hex')
code = b64encode(packet).decode('utf8')

Theoretically It should, but someone on another post mentioned he tried duplicating the code and it didn’t worked with HA, after I’ll install it I can do proper testing.

1 Like