Created
May 11, 2018 09:51
-
-
Save kittinan/b3dcb2e718b7aa8e88711cd7607d90ed to your computer and use it in GitHub Desktop.
Broadlink send IR command
This file contains hidden or 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 pickle | |
| import broadlink | |
| import sys | |
| import os | |
| if len(sys.argv) != 3: | |
| sys.exit(0) | |
| type = sys.argv[1] | |
| command = sys.argv[2] | |
| command = command.upper() | |
| print("type: " + type + " | command: " + command) | |
| pathname = os.path.dirname(sys.argv[0]) | |
| full_path = os.path.abspath(pathname) + "/" | |
| file_name = "" | |
| if type == 'air': | |
| file_name = "air.pckl" | |
| elif type == 'tv': | |
| file_name = "tv.pckl" | |
| if len(file_name) == 0: | |
| sys.exit(0) | |
| f = open(full_path + file_name, 'rb') | |
| KEY = pickle.load(f) | |
| f.close() | |
| if command in KEY.keys(): | |
| ir_packet = KEY[command] | |
| devices = broadlink.discover(timeout=5) | |
| if (len(devices) == 0): | |
| print("Not found broadlink device") | |
| sys.exit(0) | |
| devices[0].auth() | |
| devices[0].send_data(ir_packet) | |
| print("Sent IR Packet " + str(len(ir_packet)) + " bytes") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment