eschava / broadlink-mqtt

MQTT client to control BroadLink devices
MIT License
222 stars 60 forks source link

Broadlink RM Plus RF Replay issue #35

Closed plains203 closed 5 years ago

plains203 commented 5 years ago

I have the Broadlink RM plus and the ir side of things works fine. I am unable to capture RF through this app and that has been noted by others. I captured them through the e-control app and then dumped the codes with python script (Broadlink-e-control-db-dump) which decodes a .db file from the e-Control android app and saves all learnt codes from the app into text files. The codes generated by this when saved as files in the command section will not replay without throwing an error.

[2018-09-18 18:06:33,993] DEBUG Replaying command from file /home/plains203/broadlink-mqtt/commands/shutters/rm1chan1/down [2018-09-18 18:06:34,014] ERROR Error Traceback (most recent call last): File "mqtt.py", line 132, in on_message replay(device, file) File "mqtt.py", line 190, in replay device.send_data(ir_packet.decode('hex')) File "/usr/lib/python2.7/encodings/hex_codec.py", line 42, in hex_decode output = binascii.a2b_hex(input) TypeError: Non-hexadecimal digit found

The contents of that file are as below. b1000403070611060807090609060807080e100e09060906090708070806100e1007090609060807090d09070f07080e100e09060906100f0f0e110d110d100f10060807090608070906090d110d09060906090609061106080e0906100e10070807080e090610070807080708070807080e110d09060906090609060906100e1106080708070807080e09061007080e100e09060906100e100e100e100e100e10070807080708070807080e100e09060807090608071007080e0906100e10070807080e090610060907080708060906090e100e09060807080709060906100e1006090609060906090e09061006090e100e08070807100e100e100e100e100e10060906090609060906090e100e09060807080709061006090e0807100e10060906090e080710060906090609060906090e100e08070807080709060807100d1106090609060906090e08071006090d110e08060907100d110e0f0f100d110d11060906090609060807090d110e08060906090708061106090d0906110d11060906080e090611060906090609060906080e100e09060906090609060906100e1007090609060807090d09061106080e100e09060906100e100e110d100e100e11050907080708070807080e100e09060906090608071006090e0906100e10070807080e090610070807080708070807080e100e09060906080709060906100e1006090708070807080e09061007080e100e09060906100e100e100e100e100e10070806090708060906090e100e09060906090608071006090e0906100e10060906090e090610060907080609070806090e100e09060906090608070906100e1006090708060906090e08071006090e100e09060906100e100e100e100e100e10060906090609070807080e100e09060807090608071006090e0906100e10070806090e080710060907080708070807080e110d09060906090609060906100e1106080708070806090e09061007080e110d09060906100e100e100e110d110d10070906080709060807080e100e09060906090609070f07080e0906110d10070906080e090005dc00000000

eschava commented 5 years ago

Are new-line symbols (\n or \r) present in that file? I suspect they could be a reason

plains203 commented 5 years ago

I double checked the up file for new lines and there are none.

[2018-09-18 21:15:20,630] DEBUG Replaying command from file /home/plains203/broadlink-mqtt/commands/shutters/rm1chan1/up [2018-09-18 21:15:20,646] ERROR Error Traceback (most recent call last): File "mqtt.py", line 132, in on_message replay(device, file) File "mqtt.py", line 190, in replay device.send_data(ir_packet.decode('hex')) File "/usr/lib/python2.7/encodings/hex_codec.py", line 42, in hex_decode output = binascii.a2b_hex(input) TypeError: Odd-length string

Edit: I double checked the down file and it did have 2 blank lines. It still generated the error of Odd-Length string though.

eschava commented 5 years ago

could you please share up/down files?

Also, I'm not sure that Broadlink-e-control-db-dump and broadlink-mqtt use the same format of files

plains203 commented 5 years ago

Sort in order.txt up.txt down.txt The broadlink dump is the sort in order file. I had to add a .txt extension to the commands to allow uploading them.

Thanks for looking into this.

eschava commented 5 years ago

There are new-line symbols (0A) at the end of files:

image

plains203 commented 5 years ago

Agghhh so nano does this by default and apparently I have stuffed up my down button on my remote in the broadlink app perhaps. Your code works beautifully and solves a home automation hurdle I have long been beating my head against. Thank you so much! Now to capture the rest of my blinds and put this together in openhab.

eschava commented 5 years ago

Looks like I have to adjust the code to skip such symbols in the file And it's perfect that both utilities share the same format!

plains203 commented 5 years ago

I am grateful that it works so easily to take the code from one to the other. I will be attempting to understand the data captured possibly as I have 2, 6 channel remotes but 15 blinds and I would like each blind to be on its own channel.

A note in the readme about the new line for a command file should suffice I would think. I used echo -n "code" > commandfilename to overcome the issue.