about summary refs log tree commit diff
path: root/cli/broadlink_discovery
blob: 2bb8d998d93f64a0f32855af10e07a95a6fffbbb (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#!/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()

print("Discovering...")
devices = broadlink.discover(timeout=args.timeout)
for device in devices:
    if device.auth():
        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'):
            print("temperature = {}".format(device.check_temperature()))
        print("")
    else:
        print("Error authenticating with device : {}".format(device.host))