Skip to content

Instantly share code, notes, and snippets.

@narongdejsrn
Created February 19, 2017 10:47
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save narongdejsrn/1f199ce1115a36dbb82878f6ba0cd75b to your computer and use it in GitHub Desktop.
Control your Broadlink TC2 using python
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