Created
February 19, 2017 10:47
-
-
Save narongdejsrn/1f199ce1115a36dbb82878f6ba0cd75b to your computer and use it in GitHub Desktop.
Control your Broadlink TC2 using python
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 broadlink | |
HOST_IP = "192.168.1.1" | |
MAC_ADDRESS = "ZZZZZZZZ" | |
CODE = "e9144600df090916161919161916091609160916160916091609160909161609091616090916160909160916160916090916160909160916160909160916160916090916091609000148 | |
def fixCodeLength(code): | |
result = code | |
while (len(result) % 8) != 0: | |
rlen = len(result) | |
finalLength = ((rlen / 8) * 8) + 8 | |
result += code | |
result = result[:finalLength] | |
return result | |
device = broadlink.rm(host=(HOST_IP,80), mac=bytearray.fromhex(MAC_ADDRESS)) | |
device.auth() | |
# Send the code | |
device.send_data(fixCodeLength(CODE).decode('hex')) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment