1
0
mirror of https://github.com/mjg59/python-broadlink.git synced 2024-11-14 03:20:14 +01:00
python-broadlink/cli/broadlink_discovery

25 lines
1.0 KiB
Plaintext
Raw Normal View History

#!/usr/bin/env python
import broadlink
import time
import argparse
parser = argparse.ArgumentParser(fromfile_prefix_chars='@');
parser.add_argument("--timeout", type=int, default=5, help="timeout to wait for receiving discovery responses")
args = parser.parse_args()
2019-05-22 07:28:02 +02:00
print("Discovering...")
devices = broadlink.discover(timeout=args.timeout)
for device in devices:
if device.auth():
2019-05-22 07:28:02 +02:00
print("###########################################")
print(device.type)
print("# broadlink_cli --type {} --host {} --mac {}".format(hex(device.devtype), device.host[0], ''.join(format(x, '02x') for x in device.mac)))
print("Device file data (to be used with --device @filename in broadlink_cli) : ")
print("{} {} {}".format(hex(device.devtype), device.host[0], ''.join(format(x, '02x') for x in device.mac)))
if hasattr(device, 'check_temperature'):
2019-05-22 07:28:02 +02:00
print("temperature = {}".format(device.check_temperature()))
print("")
else:
2019-05-22 07:28:02 +02:00
print("Error authenticating with device : {}".format(device.host))