1
0
mirror of https://github.com/mjg59/python-broadlink.git synced 2024-11-21 22:51:41 +01:00

Handle storage error in broadlink_discovery (#372)

This commit is contained in:
Felipe Martins Diel 2020-06-08 07:21:55 -03:00 committed by GitHub
parent 89cd7d2970
commit bfbacbfffc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -3,6 +3,7 @@
import argparse
import broadlink
from broadlink.exceptions import StorageError
parser = argparse.ArgumentParser(fromfile_prefix_chars='@')
parser.add_argument("--timeout", type=int, default=5, help="timeout to wait for receiving discovery responses")
@ -20,8 +21,10 @@ for device in devices:
''.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'):
try:
print("temperature = {}".format(device.check_temperature()))
except (AttributeError, StorageError):
pass
print("")
else:
print("Error authenticating with device : {}".format(device.host))