Broadlink RM-PRO and TC2 switch

or

Great to hear that. I guess we just need to wait for @Danielhiversen to make it works on the next release. By the way, I can help you to test it. I just need to know how. Thanks guys!

No issues have been reported for the dev version, so I am not going to fix anything more before the next release.
So the release version will probably be the same as the dev.

Always great if someone will test the dev version: https://home-assistant.io/developers/development_environment

1 Like

5 TC2 switches are coming, so I can’t test. Will do as soon as they come

how do i test out the dev version? The link you sent earlier is too deep for me…

1 Like

@masterkenobi @Danielhiversen OK Guys, It’s working

Line 148: /homeassistant/components/switch/broadlink.py

Change:

self._device.send_data(packet)

To:

self._device.send_data(binascii.unhexlify(packet))

Works with TC2 duplicated hex code (converted to b64) and IR (no need to duplicate it like the tc2) works great as well.

So it looks like this fix is doing the trick, but i am not sure if it will break something else like SP1/SP2

2 Likes

great to hear. Can’t wait to test it out. @Danielhiversen, where can I get the latest copy of broadlink.py? I would like to try it out by replacing the existing one; /usr/local/lib/python3.4/dist-packages/homeassistant/components/switch/broadlink.py?

Anyone know how do i add an sp2 power plug to my configuration in addition to the ir and rf codes going to my RM pro ?

@NightRanger

I went to https://github.com/home-assistant/home-assistant/blob/dev/homeassistant/components/switch/broadlink.py and I cannot find self.device.senddata(packet) on line 148. I can only find self._device.send_data(packet) on line 183.

Sorry…

self._device.send_data(packet) is at line 183
It was 148 when i opened it in nano from my RPI

OK. So I have replaced the original /usr/local/lib/python3.4/dist-packages/homeassistant/components/switch/broadlink.py with the one I got from https://github.com/home-assistant/home-assistant/blob/dev/homeassistant/components/switch/broadlink.py after edit the line 183 to become self._device.send_data(binascii.unhexlify(packet))

When you said…

Does that mean, I need to use the hex code generated by Broadlink-e-control-db-dump/getBroadlinkSharedData.py at master · NightRang3r/Broadlink-e-control-db-dump · GitHub, duplicate it (a+a) and then convert it to b64 using

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

??

import base64
print base64.b64encode('e9144600df09...')

do you know how do I add a sp2 power plug to my configuration in addition to the ir and rf codes going to my RM pro?

I am sorry. I don’t understand. Try…

- platform: broadlink
  host: 192.168.1.999
  mac: 'XX:XX:XX:XX:XX:XX'
  type: sp2
  switches:
    entrance_light:
      command_on: '6RRGAN8JFgkWCQkWCRYWCQkWCR....'
      command_off: '6RRGAN8JCRYJFgkWCRYJFhYJFgkW...'

It’s a wifi based controller it doesn’t have IR or RF codes

I can’t add more than one broadlink platform or type i get yaml error it says i have duplicate values because my rm is already configured.

It is explained in the documentation for the next release https://github.com/home-assistant/home-assistant.github.io/blob/next/source/_components/switch.broadlink.markdown

For the second platform you have to use

switch 2:
  platform: broadlink

Thanks you so much, I missed it!

Anyway guys. I have tested and it is still NOT working for me. This is what I did.

  1. I have replaced the original /usr/local/lib/python3.4/dist-packages/homeassistant/components/switch/broadlink.py with the one I got from https://github.com/home-assistant/home-assistant/blob/dev/homeassistant/components/switch/broadlink.py1 after edit the line 183 to become self._device.send_data(binascii.unhexlify(packet))
  2. I downloaded the getBroadlinkSharedData.py file and add these lines; import base64 to the top and then code = base64.b64encode(code+code) below code = ''.join('%02x' % (i & 0xff) for i in jsonIrCodeData[i]['code'])
  3. I use the generated code into my configuration…

example:

- platform: broadlink
  host: 192.168.1.999
  mac: 'XX:XX:XX:XX:XX:XX'
  type: rm
  switches:
    entrance_light:
      command_on: 'ZTkxNDQ2MDBkZjA5MTYwOTE2MDkwOTE2MDkx....'
      command_off: 'ZTkxNDQ2MDBkZjA5MDkxNjA5MTYwOTE2MDkxN....'

It is still not working. Did I do anything wrong?

base64encode.py

import base64
encoded = base64.b64encode(‘e90a34000b21220b0b21210c0b22210c0b22210c0c21210c0b21210c0c220b210c210c210c210b22210c210c0b000150220b220b0c21220b00000000’)
print encoded

ZTkwYTM0MDAwYjIxMjIwYjBiMjEyMTBjMGIyMjIxMGMwYjIyMjEwYzBjMjEyMTBjMGIyMTIxMGMwYzIyMGIyMTBjMjEwYzIxMGMyMTBiMjIyMTBjMjEwYzBiMDAwMTUwMjIwYjIyMGIwYzIxMjIwYjAwMDAwMDAw

switch:

  • platform: broadlink
    host: 192.168.1.33
    mac: ‘b4:43:0d:38:4c:48’
    switches:
    reciever:
    friendly_name: “livingroom lights”
    command_on: 'ZTkwYTM0MDAwYjIxMjIwYjBiMjEyMTBjMGIyMjIxMGMwYjIyMjEwYzBjMjEyMTBjMGIyMTIxMGMwYzIyMGIyMTBjMjEwYzIxMGMyMTBiMjIyMTBjMjEwYzBiMDAwMTUwMjIwYjIyMGIwYzIxMjIwYjAwMDAwMDAw

    command_off: ‘’

It is still not working. Did I do anything wrong?

I am sorry. I don’t understand what you are trying to tell me.

@masterkenobi I am using version 0.35.3 on a raspberry pi, I didn’t replace any file I used the original one and changed only:

self.device.senddata(packet)

to

self.device.senddata(binascii.unhexlify(packet))

Maybe that’s why mine was at line 148 and yours was at line 183

And this is how my config file looks like:

switch:
platform: broadlink
host: 10.0.0.5
mac: ‘b4:43:00:00:00:00’
switches:
entrance_light:
friendly_name: “Entrance Light”
command_on: ‘ZTkwYTQyMDBkZjA5MDkxNjE2MDkxNjA5MDkxNjE2MDkxNjA5MDkxNjE2MDkwOTE2MTYwOTE2MDkwOTE2MDkxNjE2MDkxNjA5MDkxNjA5MTYxNjA5MTYwOTE2MDkxNjA5MDkxNjA5MTYxNjA5MDkxNjE2MDkwOTE2MTYwOTE2MDkxNjA5MDkxNjE2MDllOTBhNDIwMGRmMDkwOTE2MTYwOTE2MDkwOTE2MTYwOTE2MDkwOTE2MTYwOTA5MTYxNjA5MTYwOTA5MTYwOTE2MTYwOTE2MDkwOTE2MDkxNjE2MDkxNjA5MTYwOTE2MDkwOTE2MDkxNjE2MDkwOTE2MTYwOTA5MTYxNjA5MTYwOTE2MDkwOTE2MTYwOQ==’
command_off: ‘ZTkwYTQyMDBkZjA5MDkxNjE2MDkwOTE2MTYwOTA5MTYwOTE2MTYwOTA5MTYwOTE2MTYwOTE2MDkwOTE2MDkxNjE2MD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