Last active
July 4, 2020 17:45
-
-
Save jsliang/52c4c4f2a130e4d5fbbc6628f375d5fa to your computer and use it in GitHub Desktop.
A script to learn IR code with Broadlink RM2/3 (Pro) remote controls using the mjg59/python-broadlink library
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
#!/usr/bin/python | |
from base64 import b64encode | |
import broadlink | |
print("Discovering Broadlink devices...") | |
devices = broadlink.discover(timeout=5, local_ip_address='192.168.4.4') | |
if len(devices) == 0: | |
print("No Broadlink devices found.") | |
else: | |
print("Found %d devices." % len(devices)) | |
for device in devices: | |
device.auth() | |
while True: | |
print("Enter learning mode...") | |
for device in devices: | |
device.enter_learning() | |
print("Point remote at the device to learn code.") | |
print( | |
"Press the enter/return key after the white light on the device disappears." | |
) | |
input() | |
print("Code learned:") | |
for i in range(len(devices)): | |
packet = devices[i].check_data() | |
if packet: | |
print(b64encode(packet).decode('utf8')) | |
print("\n") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment