mirror of
https://github.com/mjg59/python-broadlink.git
synced 2024-11-13 03:00:11 +01:00
3d4789305e
Calling check_temperature is only possible on the RM family of devices. The program used to crash if other types of devices were discovered (A1, MP1 etc.).
27 lines
1.0 KiB
Python
Executable File
27 lines
1.0 KiB
Python
Executable File
#!/usr/bin/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()
|
|
|
|
print "discover"
|
|
devices = broadlink.discover(timeout=args.timeout)
|
|
#print devices
|
|
for device in devices:
|
|
if device.auth():
|
|
print "###########################################"
|
|
# print device
|
|
print device.type
|
|
print "# broadlink_cli --type 0x2712 --host {} --mac {}".format(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 "0x2712 {} {}".format(device.host[0], ''.join(format(x, '02x') for x in device.mac))
|
|
if hasattr(device, 'check_temperature'):
|
|
print "temperature = {}".format(device.check_temperature())
|
|
print ""
|
|
else:
|
|
print "Error authenticating with device : {}".format(device.host)
|