How to use the broadlink.gendevice function in broadlink

To help you get started, we’ve selected a few broadlink examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github nickw444 / home / broadlink / broadlink_cli.py View on Github external
parser.add_argument("--learn",action="store_true", help="learn command")
parser.add_argument("--learnfile", help="learn command and save to specified file")
args = parser.parse_args()

if args.device:
    values = args.device.split();
    type = int(values[0],0)
    host = values[1]
    mac = bytearray.fromhex(values[2])
else:
    type = args.type
    host = args.host
    mac = bytearray.fromhex(args.mac)


dev = broadlink.gendevice(type, (host, 80), mac)
dev.auth()
if args.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:
    data = bytearray.fromhex(args.send)
    print(repr(data))
    dev.send_data(data)
if args.learn or args.learnfile: