Hi Michael,
Been working on converting all my devices with your plugin but uncovered an issue with the plugin Pronto Hex conversion
( ... I knew the long A/C codes would generate some issues...)
So here it is,
not sure if you developed your own conversion code or are reusing some other code but here is an example:
Original/Working Pronto Hex code:
Using MCSMQTT/Broadlink to convert - This Code doesn't work
Using script below to convert ( I made it available to run online : jdoodle.com/ia/FtY)
This Code works when manually entered in Broadlink.ini
So there is something different in the way the ProntoHex to RawHex conversion is done with the plugin and unfortunately some resulting codes are not working.
I've tried playing with repeat/pulse with no success.
Any way you can compare both conversion methods (yours/below) to pinpoint the differences and hopefully fix this?
Let me know what you think, thx
Original references:
https://community.home-assistant.io/...-codes/48391/6
https://community.home-assistant.io/...aml/47536/3
Been working on converting all my devices with your plugin but uncovered an issue with the plugin Pronto Hex conversion
( ... I knew the long A/C codes would generate some issues...)
So here it is,
not sure if you developed your own conversion code or are reusing some other code but here is an example:
Original/Working Pronto Hex code:
Code:
0000 006D 0046 0000 015B 00AE 0016 0016 0016 0016 0016 0041 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0041 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0041 0016 0016 0016 0041 0016 0016 0016 0016 0016 0041 0016 0016 0016 02FA 0016 0016 0016 0041 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0041 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0041 0016 0016 0016 0016 0016 02FA
Using MCSMQTT/Broadlink to convert - This Code doesn't work
Code:
26008E0000012C96131313131338131313131313131313131313131313131313131313131313131313131313131313131313133813131313131313131313131313381313133813131313133813131300029213131338131313131313131313131313131313131313131313131313133813131313131313131313131313131313131313131313131313131313133813131313130002920D050000000000000000
Using script below to convert ( I made it available to run online : jdoodle.com/ia/FtY)
This Code works when manually entered in Broadlink.ini
Code:
2600920000012b96131313131338131313131313131313131313131313131313131313131313131313131313131313131313133813131313131313131313131313381313133813131313133813131300029113131338131313131313131313131313131313131313131313131313133813131313131313131313131313131313131313131313131313131313133813131313130002910d0500000000
I've tried playing with repeat/pulse with no success.
Any way you can compare both conversion methods (yours/below) to pinpoint the differences and hopefully fix this?
Let me know what you think, thx
Code:
CodesToConvert = [ # this is one code "0000 006D 0046 0000 015B 00AE 0016 0016 0016 0016 0016 0041 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0041 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0041 0016 0016 0016 0041 0016 0016 0016 0016 0016 0041 0016 0016 0016 02FA 0016 0016 0016 0041 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0041 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0041 0016 0016 0016 0016 0016 02FA", # this is another code (its actually a copy of the first code above just as an example, need a comma to seperate codes) "0000 006D 0046 0000 015B 00AE 0016 0016 0016 0016 0016 0041 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0041 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0041 0016 0016 0016 0041 0016 0016 0016 0016 0016 0041 0016 0016 0016 02FA 0016 0016 0016 0041 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0041 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0041 0016 0016 0016 0016 0016 02FA"] import binascii import struct import sys import base64 def pronto2lirc(pronto): codes = [long(binascii.hexlify(pronto[i:i+2]), 16) for i in xrange(0, len(pronto), 2)] if codes[0]: raise ValueError('Pronto code should start with 0000') if len(codes) != 4 + 2 * (codes[2] + codes[3]): raise ValueError('Number of pulse widths does not match the preamble') frequency = 1 / (codes[1] * 0.241246) return [int(round(code / frequency)) for code in codes[4:]] def lirc2broadlink(pulses): array = bytearray() for pulse in pulses: pulse = pulse * 269 / 8192 # 32.84ms units if pulse < 256: array += bytearray(struct.pack('>B', pulse)) # big endian (1-byte) else: array += bytearray([0x00]) # indicate next number is 2-bytes array += bytearray(struct.pack('>H', pulse)) # big endian (2-bytes) packet = bytearray([0x26, 0x00]) # 0x26 = IR, 0x00 = no repeats packet += bytearray(struct.pack('<H', len(array))) # little endian byte count packet += array packet += bytearray([0x0d, 0x05]) # IR terminator # Add 0s to make ultimate packet size a multiple of 16 for 128-bit AES encryption. remainder = (len(packet) + 4) % 16 # rm.send_data() adds 4-byte header (02 00 00 00) if remainder: packet += bytearray(16 - remainder) return packet for code in CodesToConvert: # get rid of spaces in the code. cleanCode = code.replace(" ","") # pronto2lirc needs a byte array, convert it pronto = bytearray.fromhex(cleanCode) # convert the pronto to LIRC pulse format pulses = pronto2lirc(pronto) # convert LIRC pulse format to broadlink packet = lirc2broadlink(pulses) print print binascii.hexlify(packet) #print Raw Hex print "" print base64.b64encode(packet) #print base64 # I'm not using this. # but it was in the original code so I'm leaving it # if someone compiles a python executable it uses the code below. if __name__ == '__main__': for code in sys.argv[1:]: pronto = bytearray.fromhex(code) pulses = pronto2lirc(pronto) packet = lirc2broadlink(pulses) print print binascii.hexlify(packet)
Original references:
https://community.home-assistant.io/...-codes/48391/6
https://community.home-assistant.io/...aml/47536/3
Comment