2017-11-25 21:14:34 +01:00
|
|
|
#!/usr/bin/env python
|
2017-01-11 01:55:02 +01:00
|
|
|
|
|
|
|
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()
|
|
|
|
|
2018-03-18 22:58:15 +01:00
|
|
|
print "Discovering..."
|
2017-01-11 01:55:02 +01:00
|
|
|
devices = broadlink.discover(timeout=args.timeout)
|
|
|
|
for device in devices:
|
|
|
|
if device.auth():
|
|
|
|
print "###########################################"
|
|
|
|
print device.type
|
2018-03-18 22:58:15 +01:00
|
|
|
print "# broadlink_cli --type {} --host {} --mac {}".format(hex(device.devtype), device.host[0], ''.join(format(x, '02x') for x in device.mac))
|
2017-01-11 01:55:02 +01:00
|
|
|
print "Device file data (to be used with --device @filename in broadlink_cli) : "
|
2018-03-18 22:58:15 +01:00
|
|
|
print "{} {} {}".format(hex(device.devtype), device.host[0], ''.join(format(x, '02x') for x in device.mac))
|
2017-11-25 21:04:10 +01:00
|
|
|
if hasattr(device, 'check_temperature'):
|
|
|
|
print "temperature = {}".format(device.check_temperature())
|
2017-01-11 01:55:02 +01:00
|
|
|
print ""
|
|
|
|
else:
|
|
|
|
print "Error authenticating with device : {}".format(device.host)
|