Broadlink RM-PRO and TC2 switch

If the switch state does not change,How to run the script?

   - service: homeassistant.turn_on
     entity_id: switch.YOUR_SWITCH
   - service: homeassistant.turn_on
     entity_id: switch.YOUR_SWITCH

Detailed info about scripts can be found here: https://home-assistant.io/components/script/

Thank you very much!

Hi all,

Just setup my home assistant with TC2 and thought, maybe I can contribute here a little bit. As I have forgotten most of my programming knowledge, I’m having hard time to understand all the terms of HEX and 64BASED but this is what I did:

I used the broadlink learn service from homeassistant dev tools, then use E-Control apps from my phone to trigger the on or off of the TC2 switch. Then homeassistant will receive the packet and store in log and notification. Not working all the times but I managed to setup all my 10 switches this way within half an hour. Keep trying until you get the packet with enough length (about 1200++) and ended with AAAAAA= .

The idea is easy, trying to get RM Pro to learn back the RF sent from itself. :smiley:

Hope this helps. Thanks.

Hi Guy, I spend a lot of time reading all reply,
after some test here I discovery a pattern in the return of these codes which find all devices in your RM

in the case of the TC2 Switch the script return this:
Button Name: | Button ID: 64 | Code: e90a4200ef0909160916160916091609091616090916160909161609160916090916160916091609091616090916091609161609091609161609160916091609160916090916

Button Name: | Button ID: 65 | Code: e90a4200ee0916090916091616090916091609161609160916090916091609161609160909160916160916091609160916090916091609161609091616090916160909160916

Button Name: | Button ID: 66 | Code: e90a4200ee0909160916160916091609160909161609160909161609091609161609091609160916091616091609160909160916091616090916160916091609160916091609

Button Name: | Button ID: 67 | Code: e90a4200ee0916090916091609161609160916091609091616090916160916091609160916091609160916090916091609160916160909161609091609161609160916090916

Button Name: | Button ID: 68 | Code: e90a4200ee0916090916160916090916091609161609160909160916160909160916091616091609160909161609091616091609091616090916091609160916091609161609

Button Name: | Button ID: 69 | Code: e90a4200ee0916090916160909161609160916091609160909161609160909160916160909161609160909160916091609160916091616090916160909160916091616090916

Each two records buttons have one physical element control:
In this model TC2 we have 2 buttons, so you can think, if I have only 2 buttons and each button has 2 records, why the script return 6 records of button? the last 2 records controller the both button(in e-controll app has Turn on All and Turn off All)

I read in past reply about concat the 2 hex and pass in “send_data”
in my case works with:
device.send_data(binascii.unhexlify(myhex)) dont forget to import binascii

myhex always concat 2 records, so

so following my Buttons ID you need to concat in this order

If I want to turn on the first button, I can pass
the Code of Button ID 64 + Code of Button ID 65

If I want to turn on the second button, I can pass
the Code of Button ID 66 + Code of Button ID 67

If I want to turn on all buttons, I can pass
the Code of Button ID 68 + Code of Button ID 69

to send commands to Turn OFF you can switch the order of the Button ID:

If I want to turn off the first button, I can pass
the Code of Button ID 65 + Code of Button ID 64

If I want to turn off the second button, I can pass
the Code of Button ID 67 + Code of Button ID 66

If I want to turn off all buttons, I can pass
the Code of Button ID 69 + Code of Button ID 68

Here works well, so I hope this instructions can help you too

hei friend , ur TC2 is work?

Yeah. They work fine.

great job , now im using NightRang3r/Broadlink-e-control-db-dump/blob/master/getBroadlinkSharedData.py to get a tc2 switch code , but tat code not work for me , did u have any suggestion?

My problem same like u b4 , i really dunno how to fix my problem :cry:

Hi Luis_Goh, can you send me what your getBroadlinkSharedData.py is returning?

now i already get my tc2 switch hex code
e90a4200df0909160916091609160916160909160916091616090916160909161609091616090916160916091609091609160916091609160916091616091609091616091609 after tat i convert to base64
6QpCAN8JCRYJFgkWCRYJFhYJCRYJFgkWFgkJFhYJCRYWCQkWFgkJFhYJFgkWCQkWCRYJFgkWCRYJFgkWFgkWCQkWFgkWCQ==
but this code still NOT WORKING for my TC2 switch…

This print is your first part of the script getBroadlinkSharedData.py,
when you input the ID, the script print another informations about the code of this specific device.

Send me this return, Copy an Paste Here.

If the return send 6 codes, you need to copy the first and the second to concatenate and put the result string where: in the send_data

Ex.:
cod1 = “CLKJDLKJSLKJFSLKJFLSKDJLKDF”
cod2 = “asdasdfasldfjasdf”
device.send_data(binascii.unhexlify(cod1 + cod2))

this works to me

1 Like

ok , u mean use
Button Name: | Button ID: 64 | Code: e90a4200ef0909160916160916091609091616090916160909161609160916090916160916091609091616090916091609161609091609161609160916091609160916090916
+
Button Name: | Button ID: 65 | Code: e90a4200ee0916090916091616090916091609161609160916090916091609161609160909160916160916091609160916090916091609161609091616090916160909160916
convert to base64 code ?

Yes That is,

you just need to concatenate code 64 to code 65 to turn on and change the order to turn off like this:

TURN ON
e90a4200ef0909160916160916091609091616090916160909161609160916090916160916091609091616090916091609161609091609161609160916091609160916090916e90a4200ee0916090916091616090916091609161609160916090916091609161609160909160916160916091609160916090916091609161609091616090916160909160916

TURN OFF
e90a4200ee0916090916091616090916091609161609160916090916091609161609160909160916160916091609160916090916091609161609091616090916160909160916e90a4200ef0909160916160916091609091616090916160909161609160916090916160916091609091616090916091609161609091609161609160916091609160916090916

now you put one of this values in a variable like:
myhex = “e90a4200e…”

and then you pass this variable to this command:
device.send_data(binascii.unhexlify(myhex))

get this code here

in the line 17 has a variable “codeData” put one of the values in this variable,
and the line 21 change the command to this one:
device.send_data(binascii.unhexlify(codeData))

ps.: to use this binascii.unhexlify you will need to import this library in the top of the file
import binascii

1 Like

thx u very much ,is work for me:slight_smile:

Any assistance would be great, I am stuck at the point on getting the results from using the ‘getBroadlinkSharedData’ for the TC2 2 gang plug. I get the following output:

Button Name: 1-Gang | Button ID: 88 | Code: e9144600df090916160916090916160916090916160916090916160916091609091616090916160909161609160916090916091616090916091609160916160916090916160909000148

Button Name: 1-Gang | Button ID: 89 | Code: e9144600df091609160916091609160916091609160916091609160909160916091609160916091609160916160909160916160916090916160916091609091609161609160909000148

Button Name: 2-Gang | Button ID: 90 | Code: e9144600df091609160909161609091609161609160909161609091616091609160916091609160909160916160916090916160916090916160916091609160909160916160909000148

Button Name: 2-Gang | Button ID: 91 | Code: e9144600df091609091609161609160909160916160916091609160909161609160909160916091616091609160916091609160916090916160916091609091609161609160909000148

Button Name: | Button ID: 92 | Code: e9144600df091609091609160916160909161609160916090916091609160916160916091609160909160916160916091609160916091609160909161609091616090916160909000148

Button Name: | Button ID: 93 | Code: e9144600df090916091609160916160909161609091616091609091609161609160916091609091609161609091609160916091616091609160916090916091609161609160909000148

Apologies managed to suss it out by looking back at @NightRanger and @masterkenobi comments. Basically what worked for me after testing was to muliply the above code 6 times (same as masterkenobi) then convert to base64: http://tomeko.net/online_tools/hex_to_base64.php?lang=en1

The TC2 sounds very interesting, did anybody figured out if its possible to receive the status of the TC2 somehow? I know z-wave devices can, but some comments above somebody mentioned pressing the physical button changes the switch in the app, can someone confirm?

no, it doesn’t change the state in HA if press the switch physically

Hi Guys,

My HA version is 0.40 and I replaced the broadlink.py to use MP1 & MP2 powerstrips.
http://pastebin.com/AGu9Tph8

I resolved the TC2 issue like below.
Just add 4 zero number to the code and convert it.

My original TC2 code is “e9144600df091609160909161609091609160916091616091609160916091609160909160916091616091609091609161609091616090916091609160916160916091609160909000148”

I added 0000 to it
“e9144600df0916091609091616090916091609160916160916091609160916091609091609160916160916090916091616090916160909160916091609161609160916091609090001480000”

And then convert it at the site http://tomeko.net/online_tools/hex_to_base64.php?lang=en1
If you do it, you can get the output like the below.
“6RRGAN8JFgkWCQkWFgkJFgkWCRYJFhYJFgkWCRYJFgkWCQkWCRYJFhYJFgkJFgkWFgkJFhYJCRYJFgkWCRYWCRYJFgkWCQkAAUgAAA==”

Because of the 4 zero, every converted code end with ‘AAA==’
I have 9 TC2 and they are all working well.

BTW I have some RF Relay which has 120 code length. They also have the problem ‘Input strings must be a multiple of 16 in length’
Below is the problem code:
‘e90834003710133336111333371113333711123413321333123336123611133312331300020b14313710133237111333371113333711133300000000’
I tried to add and remove 0, make it double, I didn’t resolve this problem.