How to convert LIRC codes to something useable by python-broadlink?
Given something like https://gist.github.com/voltagex/1546899, how could I convert this to something send_data would accept?
e.g. in Python 3:
>>> s = '000000000038BC81'
>>> on = codecs.decode(s,'hex_codec')
>>> devices[0].send_data(on)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python3.5/dist-packages/broadlink/__init__.py", line 376, in send_data
self.send_packet(0x6a, packet)
File "/usr/local/lib/python3.5/dist-packages/broadlink/__init__.py", line 215, in send_packet
payload = aes.encrypt(bytes(payload))
File "/usr/lib/python3/dist-packages/Crypto/Cipher/blockalgo.py", line 244, in encrypt
return self._cipher.encrypt(plaintext)
ValueError: Input strings must be a multiple of 16 in length
I used a program called IrScrutinizer to convert the LIRC command to 'bytes', I was given a string like
0000 006D 0000 0032 0081 0043 0010 0010 0010 0032 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0032 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0032 0010 0010 0010 0032 0010 0010 0010 0010 0010 0032 0010 0032 0010 0032 0010 0010 0010 0010 0010 0010 0010 0032 0010 0010 0010 0032 0010 0032 0010 0032 0010 0032 0010 0010 0010 0010 0010 0032 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0032 0010 0B14
But I'm still stuck:
>>> str_bytes = '0000 006D 0000 0032 0081 0043 0010 0010 0010 0032 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0032 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0032 0010 0010 0010 0032 0010 0010 0010 0010 0010 0032 0010 0032 0010 0032 0010 0010 0010 0010 0010 0010 0010 0032 0010 0010 0010 0032 0010 0032 0010 0032 0010 0032 0010 0010 0010 0010 0010 0032 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0032 0010 0B14'
>>> data = b"".join([int('0x' + x,16).to_bytes(2,'big') for x in str_bytes.split()])
>>> devices[0].send_data(data)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python3.5/dist-packages/broadlink/__init__.py", line 376, in send_data
self.send_packet(0x6a, packet)
File "/usr/local/lib/python3.5/dist-packages/broadlink/__init__.py", line 215, in send_packet
payload = aes.encrypt(bytes(payload))
File "/usr/lib/python3/dist-packages/Crypto/Cipher/blockalgo.py", line 244, in encrypt
return self._cipher.encrypt(plaintext)
ValueError: Input strings must be a multiple of 16 in length
For reference, a valid string from another remote:
>>> devices[0].enter_learning()
>>> print(devices[0].check_data())
b'&\x00\x90\x00\x00\x01/\x97\x14\x12\x148\x13\x13\x12\x14\x13\x14\x12\x13\x13\x14\x129\x149\x138\x139\x148\x139\x139\x139\x139\x12:\x13\x13\x12:\x13\x13\x12\x14\x12\x14\x13\x13\x13\x14\x12\x14\x12:\x12\x15\x11:\x12:\x139\x12:\x139\x13\x00\x04\xdc\x00\x01/N\x13\x00\x0cp\x00\x01/M\x15\x00\x0co\x00\x01/M\x13\x00\x0cq\x00\x010L\x13\x00\x0cq\x00\x010L\x13\x00\x0cq\x00\x01/M\x13\x00\x0cq\x00\x01/M\x12\x00\x0cq\x00\x01/M\x12\x00\x0cp\x00\x010L\x13\x00\r\x05\x00\x00\x00\x00\x00\x00\x00\x00'
hey. i did some decoding here. u might wanna read up https://github.com/mjg59/python-broadlink/issues/10#issuecomment-263129225
(I am the author of IrScrutinizer.)
I just implemented a Broadlink-python export format for IrScrutinizer, which should do exactly what you ask for. You can generate python code for sending your Lirc commands to the Broadlink. Let me know if it works for you.
@bengtmartensson I just downloaded IrScrutinizer to try this, how do I configure the Export tab to generate the signal in a format I can use with Broadlink-python?
Selecting "Broadlink Python IR" as export format?
I don't see it as an option using Scrutinzer 1.3. Do I need a different version or to build from source?
EDIT: doh looks like I downloaded an older version from the OSX link on your site
The Broadcom export is supported in version 1.4.2 and later. (I think my site is clear on that the latest version are available on Github only.)
Bu sure to select menu entry File -> Reset properties when you have installed the new version.
Just an FYI, the Mac app link points to your site and it’s the 1.3 version. I downloaded version 1.4.2 and was able to see it. Thanks!
On Fri, Oct 26, 2018 at 2:24 AM Bengt Martensson [email protected] wrote:
The Broadcom export is supported in version 1.4.2 and later. (I think my site is clear on that the latest version are available on Github only.)
Bu sure to select menu entry File -> Reset properties when you have installed the new version.
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/mjg59/python-broadlink/issues/27#issuecomment-433300200, or mute the thread https://github.com/notifications/unsubscribe-auth/AG6F1kYl2TELvmeIgKT27nr4dUvIh9Nbks5uoqqygaJpZM4LJ1-j .
-- Raman