How to use the pymyq.device.STATE_OPEN function in pymyq

To help you get started, we’ve selected a few pymyq 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 arraylabs / pymyq / example.py View on Github external
print('Device ID: {0}'.format(device.device_id))
                print('Parent ID: {0}'.format(device.parent_id))
                print('Online: {0}'.format(device.available))
                print('Unattended Open: {0}'.format(device.open_allowed))
                print('Unattended Close: {0}'.format(device.close_allowed))
                print()
                print('Current State: {0}'.format(device.state))
                if JSON_DUMP:
                    print(json.dumps(device._device, indent=4))
                else:
                    if device.state != STATE_OPEN:
                        print('Opening the device...')
                        await device.open()
                        print('    0 Current State: {0}'.format(device.state))
                        for waited in range(1, 30):
                            if device.state == STATE_OPEN:
                                break
                            await asyncio.sleep(1)
                            await device.update()
                            print('    {} Current State: {}'.format(
                                waited, device.state))

                        await asyncio.sleep(10)
                        await device.update()
                        print()
                        print('Current State: {0}'.format(device.state))

                    if device.state != STATE_CLOSED:
                        print('Closing the device...')
                        await device.close()
                        print('    0 Current State: {0}'.format(device.state))
                        for waited in range(1, 30):