HTTP/MQTT/LIRC bridge for Broadlink devices, supports Pronto hex codes

Hello,

thanks foк addon but for me it do not work.
Some 433 codes works, some not. For example this code

curl -d 'sgKEAwgKBywHLAgKCCsICggrCAoICggrCCwHCggrCAsHCwcrCQoHLAgKBysICggrCAoIKwgKBywICggrCAoHLAgJCCsICggrCAoHKwgKCCsICggrCAoIKwgKCCsIKwgKCAABXQhTCSsHCwcLBysJKwcLCAoHLAgqCAsICgcrCQoHKwgKCCsICggrCAoIKwcrCAoIKwgKCCsHCwgKBysIKwgKCCsICggKCCsICQgrCAoIKwgKCCsICggrBwoIKwgLBysICggrCAoIKggKCCsICggrCAoIKwgKCCoJCgcrCAoIKwgrCAoIAAFdCFMJKggKCAoIKwgrCAoICggrCCsICgcLBysICggrCAoIKwgKCCsICwcrCCsICggrBwsIKggKCAsHKwgrCAoIKwgKCAoIKwgKBysICggrCAoIKwcLBysJCQgsBwoIKwgKCCsICggrCAoIKwgKCCsICggrCAoIKgkKCCsICgcsBysICwcAAV4HVAgrCAoICggrCCoICwcLBysIKgkKCAoHKwgKCCsICggrCAoIKggKCCsIKwgKCCoICwgqCAoICggrCCsHCwcrCAoICggrCAoIKggKCCsICggqCAoIKwgKCCsICgcrCAoIKwgJCSoICggrCAoIKggKCCsICggqCQkIKwgKCCoJKggKCAABXAlTCCsICggKBysIKwgKCAoIKgkqCAoICggrCAoIKggKCCsICggrBwsHLAcrCAoIKggLCCoICggKCCsIKggKCCsICggKCCsHCggrCAoIKwgJCCsICggrCAoIKggKCCsICgcrCAoIKwgKBysICggrCAoIKwcKCCsICggrBwoIKwgrBwsIAAFcCFQIKggKCAoIKwgrBwsHCwgqCCsICggKBysICggrCAoHKwgKCCsICggrBysICggrCAkIKwgKCAoIKwcrCAoIKwgKCAkJKggKCCsICgcrCAsHKwgKCCsHCggrCAoIKggKCCsICggrBwsHKwgKCCsICgcsBwoIKwgKCCsHCwcrCCsHCwcAAV4HVAgrCAoHCwcrCCsHCggLBysIKwcLCAoHKwgKCCsICggqCAoIKwgKBysIKwgKCCoICggrCAoICgcrCCsICggqCAsHCggrCAoIKwcLBysICggrCAkIKwgKCCoICwcsBwoIKwcKCCsICggrBwsHKwgKCCsICQgrCAoIKwcKCCsIKwgJCAAF3AAAAA=' http://raspberrypi:8780/device/192.168.178.21

gives me error in log

2020-12-17 16:58:56,961 WARNING  HTTP: POST /device/192.168.178.21 HTTP/1.1 code 400, message Bad payload

But codes from the same remote but other buttons works well. How can it be and why?
The code above working code, i used it with official broadlink intergration till stopped working…

This is not a proper BASE64 string. It has the wrong length.

Hello,

New HA user here.

I’ve been using RM bridge to control my Broadlink device for a while now and I have quite a few codes learned.

Could I use these codes with this addon?

The codes look something like this (this is the export of one IR remote button):

[{"data":"26004803cb10101212101111111012101012111033000342cb1012101012111012101012111010133200034acb1010121210111010121210101211103200034cc91211101210101211101013111011103400034aca1111101013111010121210111010123300034aca11101211111012111012101012111034000349ca1211101012121011101012121011103300034acb1110121110121010121110121012103100034cc913111011101013111011111012111034000349cb1111101012121011101111121010123200034acb1110121110111110121110101212103200034bca1112101110121012101012111012103300034acb1011111111111011121110111110123100034cca1110121110101212101110101212103300034acb1012101012111012101012111010133200034acb1010121210111010121210101211113100034cc91211101210101211101112111011113300034acb1011111012111010121210111010123200034bcb1011111210101211101210101211103400034ac91211101013111011101013111011113300034aca1110121111111010121210111012103200034bca12111012101012111011111210111034000349cb1111101012121011111111111010123200034bca1110121111101211101111101211103200034bca1211101012121011101012121011103400034aca1110121110140e1012130f130e10123200034bc913120f140e1012130e140e1012130e36000347cd0f120f10121111120f1012140e10123200034bca1110121012120f1012130f1012130e3200034bc9131110130f1012130e0f13130f130e36000348ca11130e1012101210121111120f10123200034bca111012130f1012130e130f1012130e35000348ca12130e1012130f120f1013120f10123200034bca111012130f120f101212101012120f3200034bca12120f10121012120f10130f12120f36000348cc0f120f1013120f11111210130e101234000349ca111012130f1012120f130f1012120f3200034cc912120f1112120f120f10131011120f35000349ca1110121210120f1012130f101110123200034bca121110130f10121011130f1012120f35000348cd0f120f1013101111101013120f10123300034aca1110121210120f1012130f1012120f32000d05","mac":"xx:xx:xx:xx:xx:xx","name":"crickets"},

Thanks!

This looks like it could be a hex representation of a Broadlink packet (which is normally in Base64). Try using Hex to Base64 | Base64 Encode | Base64 Converter | Base64 to convert those codes to Base64 and see if they work using the bridge.

Yes, indeed, you were right. Thanks!
Problem is that they do not work inside Home Assistant.
Now I learned some buttonsagain using the Broadlink Manager and I get different codes which, surprisingly, work in Home Assistant.
Do you have any idea why I would get two different codes for the same button? (one code learned with RM bridge and another with Broadlink Manager)

No, I don’t. My knowledge of IR is limited, but I know that decoding can be tricky and due to timing and jitter you don’t get the same results all the time. You probably got a bad learn in your first attempt.

There are some programs like IrScrutinizer that do “reverse engineering” of the IR signal and can analyse it to find out the IR protocol and the parameters. You can then generate new, clean signals via the program.

However, it doesn’t support the Broadlink format (only Pronto hex) so it won’t work for this use case.

I lost an air conditioner remote, so I can no longer use the official HAS Broadlink integration’s learn function. It’s a Haier AC. Where can I source codes to use with this if they aren’t on irdb.tk? Am I screwed or is there a way to brute force codes?

Try Control Tower IR Database (you’ll need an account). I did a quick check and they have the codes for Haier ACs. You’ll get an e-mail with all codes in Pronto hex, which you can use directly with this bridge.

Otherwise let me know the exact model and I’ll get them for you.

Thank you for your reply. Will using this integration prohibit me from using call-service remote.send_command with codes sourced from the broadlink integration’s learn feature?

I was able to obtain the codes I needed with that link, thank you.

As a side, I found a blog that stated Pronto codes can be converted using these two tools ([1] , [2]), but I cannot figure out what strings to put into what fields here, could you shed some light on this?

No. They’re completely independent.

The point of writing my bridge was exactly so I could use Pronto hex codes directly (the de facto format for describing IR codes) instead of the hassle of dealing with the proprietary Broadlink format. You can think of the bridge as being a fancy wrapper over the code you found in [2] (which is in fact incorporated into the bridge with the permission from the original author).

If you choose to use this bridge, you can just copy & paste the codes you got as “hex code”. If you want to use the built-in HASS Broadlink integration, you’ll need to convert them to Broadlink format by running the script you found in [2] and passing the Pronto hex code (in quotes) as a command line argument to the script. It should output a string which is the same code, but converted to the proprietary Broadlink representation.

I installed the integration and am trying to send via an entity button by mac address of the Broadlink, but I’m not sure where my yaml is going wrong; https://paste.ubuntu.com/p/k2N3gVjWnk/. In the documentation /device/ is written twice, but I don’t understand why or how to properly construct this (or if I’m even doing it right by using the mqtt entity button method).

I want to, but when I convert;

hex code1: 0000 006D 0022 0002 0156 00AB 0016 0015 0015 0015 0016 0015 0016 003F 0016 003F 0016 0015 0015 0015 0016 003F 0016 003F 0016 003F 0016 003F 0016 003F 0016 0015 0016 003F 0016 003F 0016 0015 0015 0040 0015 0015 0016 0015 0016 003F 0016 003F 0016 0015 0015 0016 0015 0015 0016 0015 0016 003F 0016 003F 0016 0015 0015 0015 0016 003F 0016 003F 0016 003F 0016 05CC 0155 0055 0016 05CC

I get

2600500000012793131212121312133613361312121213361336133613361336131213361336131212371212131213361336131212131212131213361336131212121336133613361300050100012649130005010d05000000000000

When I pass this, it doesn’t do anything. Here’s my yaml I’m passing using developer tools → services.
https://paste.ubuntu.com/p/pkXfnBT2wd/

Just to remove one factor from the equation, try using the HTTP method first so you talk directly to the bridge without an intermediary:

rest_command:
  my_command:
    url: http://BRIDGE_HOST:PORT/device/default
    method: post
    payload: '0000 006D 0022 0002 0156 00AB 0016 0015 0015 0015 0016 0015 0016 003F 0016 003F 0016 0015 0015 0015 0016 003F 0016 003F 0016 003F 0016 003F 0016 003F 0016 0015 0016 003F 0016 003F 0016 0015 0015 0040 0015 0015 0016 0015 0016 003F 0016 003F 0016 0015 0015 0016 0015 0015 0016 0015 0016 003F 0016 003F 0016 0015 0015 0015 0016 003F 0016 003F 0016 003F 0016 05CC 0155 0055 0016 05CC'

I’m assuming the you only have one Broadlink device, hence I’m using default and relying on auto-detection, but you can also try using the MAC address.

If this doesn’t seem to work, check if the LED of the Broadlink device is flashing when you trigger the command:

  • if it is, then the bridge is working and it sent the IR sequence: most likely the IR sequence is not the right one for your device
  • if not, then there’s something wrong with the set up: check the HASS logs and/or the bridge logs

If this works, then what went wrong in the first time is probably the MQTT setup. Double check the bridge config: hostname, username, password. Check with mosquitto_sub -t 'broadlink/#' while you trigger the command to see if the expected message is being sent to the broker.

This should work (although I’m not sure about that b64 prefix. I don’t think it should be there). If this is not working, it won’t work in the bridge as well (since the bridge is doing the same thing). Do the same troubleshooting steps: check if the LED in the device is flashing. If it’s flashing, then the command was sent but it’s probably not for your device. If not, check the HASS logs for any clues.

Edit: I got it working!

I had to specify my Broadlink /DEVICE/ as local IP or with a backwards mac address. Didn’t work with default for whatever reason (“Device not found” in bridge logs), but that’s fine as I’m going to use the mac address method.

I discovered the mac address bug by sending a successful IR code using my Broadlink’s IP address as /DEVICE/ and then checking the output in the bridge logs. There I saw the mac address was displayed backwards (as compared to my router’s DHCP table);

2021-06-08 13:34:03,563 INFO Device: [email protected] has alias 192.168.1.53

I’m happy to hear that you managed to make it work. I forgot to mention that you could use the IP address as well.

Regarding default alias, I’m not sure why your device wasn’t auto-discovered. Is it on a different subnet by any chance?

Regarding the inverted MAC address, that shouldn’t be happening. I will double check if it’s a bug in the bridge or in the Python Broadlink library.

It was a bug in the bridge. I released a new version of the bridge/add-on with the fix and seized the opportunity to upgrade to the latest version of python-broadlink, which should have better support for newer devices.

hi !

installed as an addon
tested with my old plasma TV Panasonic.
discrete codes on & off work.
now, i’ve to go further …

nice job, thx.