mirror of
https://github.com/mjg59/python-broadlink.git
synced 2024-11-22 07:00:12 +01:00
included sensors option
This commit is contained in:
parent
de7c5c2a2a
commit
5195856200
@ -15,6 +15,7 @@ parser.add_argument("--host", help="host address")
|
|||||||
parser.add_argument("--mac", help="mac address (hex reverse), as used by python-broadlink library")
|
parser.add_argument("--mac", help="mac address (hex reverse), as used by python-broadlink library")
|
||||||
parser.add_argument("--temperature",action="store_true", help="request temperature from device")
|
parser.add_argument("--temperature",action="store_true", help="request temperature from device")
|
||||||
parser.add_argument("--send", help="send command")
|
parser.add_argument("--send", help="send command")
|
||||||
|
parser.add_argument("--sensors",action="store_true", help="check all sensors")
|
||||||
parser.add_argument("--learn",action="store_true", help="learn command")
|
parser.add_argument("--learn",action="store_true", help="learn command")
|
||||||
parser.add_argument("--learnfile", help="learn command and save to specified file")
|
parser.add_argument("--learnfile", help="learn command and save to specified file")
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
@ -34,6 +35,14 @@ dev = broadlink.gendevice(type, (host, 80), mac)
|
|||||||
dev.auth()
|
dev.auth()
|
||||||
if args.temperature:
|
if args.temperature:
|
||||||
print dev.check_temperature()
|
print dev.check_temperature()
|
||||||
|
if args.sensors:
|
||||||
|
try:
|
||||||
|
data = dev.check_sensors()
|
||||||
|
except:
|
||||||
|
data = {}
|
||||||
|
data['temperature'] = dev.check_temperature()
|
||||||
|
for key in data:
|
||||||
|
print "{} {}".format(key, data[key])
|
||||||
if args.send:
|
if args.send:
|
||||||
data = bytearray.fromhex(args.send)
|
data = bytearray.fromhex(args.send)
|
||||||
dev.send_data(data)
|
dev.send_data(data)
|
||||||
@ -56,4 +65,4 @@ if args.learn or args.learnfile:
|
|||||||
text_file.write(learned)
|
text_file.write(learned)
|
||||||
else:
|
else:
|
||||||
print "No data received..."
|
print "No data received..."
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user