python-broadlink
python-broadlink copied to clipboard
How do you save the command (e.g., ir_packet) for use in a script?
Could you flesh out the readme a little more describe how to later use the learned command? Do you have to write/read from a file or something? Could you provide some example? Thanks.
The examples posted here work fine (both ir and rf)
Thanks. I'll try that.
Oops posted from different account. Thanks. I will try.
Is it possible to load config from the "share to other phones in WLAN" from broadlink's E-control app? It will made setup much easier.
Another approach is to dump the packet to YAML:
import broadlink
from IPython import embed
import time
import yaml
devices = broadlink.discover(timeout=5)
device = devices[0]
device.auth()
device.enter_learning()
packet = None
print("Learning", end="", flush=True)
while packet is None:
print(".", end="", flush=True)
time.sleep(5)
packet = device.check_data()
print()
print(yaml.dump(packet))
I'm taking that snippet, and putting into a YAML like:
christmas_lights:
on: !!binary |
sgD8AAYSEgYGEgYTBRMRBwUTEQcFEwUTBhISBxEGEgcFExEHBRMFEwUTBRMGEgYSEgYSBwW7BhIS
BgYTBRMFExEHBRMRBwUTBhIGEhIHEQcRBwUTEQcGEgYSBhIGEgYSBhMRBxEHBbsGEhIGBhMFEwUT
EQcFExIGBRMGEwUTEQYSBxEHBRMRBwUTBRMGEgYSBhIGExEHEQcFuwYTEQcFEwUTBRMRBwUTEQcG
EgUTBhISBxEHEQcFExEHBRMFEwYSBRMGEgYTEQcRBwW7BhISBwUTBRMFExEHBRMRBwUTBRMFExIG
EgcRBwUTEQcFEwUTBRMFEwUTBRMGEgYTBQAF3AAAAAAAAAAAAAAAAA==
off: !!binary |
sggyAAcTEgcGEwYTBhMSBwYTEgcGEwYTBhMSBxIHEgcHExIHBhMGEwYTBhMSBxMHBhMGEwa8AAAA
AAAA
And then sending like:
import broadlink
import yaml
with open('codes.yaml', 'r') as file:
data = yaml.load(file)
packet = data['christmas_lights'][True] # YAML treats on as True
devices = broadlink.discover(timeout=5)
device = devices[0]
device.auth()
device.send_data(packet)
Hi there. This looks like an excellent integration. I've just placed an order for the RM2 but I can't work out how to install the library for use in Python. I have cloned the folders and run the setup but i get no module error when trying to import Broadlink Can anyone help me please - apologies if I'm being dumb :-)
@keptenkurk
The examples posted here work fine (both ir and rf)
From the link it looks as tho it only works for IR. How does it need to be modified to work with RF?
And can the HEX codes that are read into the text file be used in other applications?
I've been trying to figure out the codes including protocol, pulse length etc for use in a MQTT gateway using RCSwitch. But RCSwitch doesn't read my remote but the RM Pro has.
Another approach is to dump the packet to YAML:
import broadlink from IPython import embed import time import yaml devices = broadlink.discover(timeout=5) device = devices[0] device.auth() device.enter_learning() packet = None print("Learning", end="", flush=True) while packet is None: print(".", end="", flush=True) time.sleep(5) packet = device.check_data() print() print(yaml.dump(packet))
I'm taking that snippet, and putting into a YAML like:
christmas_lights: on: !!binary | sgD8AAYSEgYGEgYTBRMRBwUTEQcFEwUTBhISBxEGEgcFExEHBRMFEwUTBRMGEgYSEgYSBwW7BhIS BgYTBRMFExEHBRMRBwUTBhIGEhIHEQcRBwUTEQcGEgYSBhIGEgYSBhMRBxEHBbsGEhIGBhMFEwUT EQcFExIGBRMGEwUTEQYSBxEHBRMRBwUTBRMGEgYSBhIGExEHEQcFuwYTEQcFEwUTBRMRBwUTEQcG EgUTBhISBxEHEQcFExEHBRMFEwYSBRMGEgYTEQcRBwW7BhISBwUTBRMFExEHBRMRBwUTBRMFExIG EgcRBwUTEQcFEwUTBRMFEwUTBRMGEgYTBQAF3AAAAAAAAAAAAAAAAA== off: !!binary | sggyAAcTEgcGEwYTBhMSBwYTEgcGEwYTBhMSBxIHEgcHExIHBhMGEwYTBhMSBxMHBhMGEwa8AAAA AAAA
And then sending like:
import broadlink import yaml with open('codes.yaml', 'r') as file: data = yaml.load(file) packet = data['christmas_lights'][True] # YAML treats on as True devices = broadlink.discover(timeout=5) device = devices[0] device.auth() device.send_data(packet)
Nice answer. We should use YAML in the CLI imo.