The codes are an array of numbers that can be converted to a byte array. They are stored as signed integers and python seems to need unsigned so they need to be converted. I wrote this code today to test them out. This code isn't great, but it works to test the codes to see if they work. I think I'm doing the byte conversion correctly. Some of my codes seemed to work and others didn't. I didn't get much time to work on it today though. The broadlink library came from here https://github.com/mjg59/python-broadlink
Edit: I fixed a problem with this code converting the negative values in the arrays to positive values. All the codes from my saved file work now,
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import broadlink | |
import json | |
import sys | |
code_index = int(sys.argv[1]) | |
codefile = open('ircodes.json','r') | |
codes = json.loads(codefile.read()) | |
code_list = codes[code_index]['code'] | |
converted_code_list = [] | |
for byte in code_list: | |
if(byte < 0): | |
byte = 256 + byte | |
converted_code_list.append(byte) | |
code_to_send = bytearray(converted_code_list) | |
devices = broadlink.discover(timeout=5) | |
devices[0].auth() | |
print devices[0].send_data(code_to_send) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
params = { | |
'method':'download', | |
'pathname':'', | |
'timestamp':'', | |
'token':'' | |
} | |
headers = { | |
'timestamp': '', | |
'token': '', | |
'accountType': 'bl', | |
'reqUserId': '', | |
'reqUserSession': '', | |
'serialVersionUID': '' | |
} | |
r = requests.get('http://ebackup.ibroadlink.com/rest/1.0/backup',params = params,headers = headers) | |
f = open('backup_test.zip','wb') | |
f.write(r.content) |