Package: python-myq
IntroductionThis is a Python 3.8+ module aiming to interact with the Chamberlain MyQ API.Code is licensed under the MIT license.It is recommended that you consider using an open-source solution instead of a myq such asRatgdoHomeassistantHomeassistanthas acore myQ componentleveraging this package.
In addition, there is also aHACS myQ componentavailable that can be added into HACS as a custom repository.Getting StartedInstallationpipinstallpymyqUsagepymyqstarts within anaiohttpClientSession:importasynciofromaiohttpimportClientSessionasyncdefmain()->None:"""Create the aiohttp session and run."""asyncwithClientSession()aswebsession:# YOUR CODE HEREasyncio.get_event_loop().run_until_complete(main())To get all MyQ devices associated with an account:importasynciofromaiohttpimportClientSessionimportpymyqasyncdefmain()->None:"""Create the aiohttp session and run."""asyncwithClientSession()aswebsession:myq=awaitpymyq.login('<EMAIL>','<PASSWORD>',websession)# Return only cover devices:devices=myq.covers# >>> {"serial_number123": <Device>}# Return only lamps devices:devices=myq.lamps# >>> {"serial_number123": <Device>}# Return only locks devices:devices=myq.locks# >>> {"serial_number123": <Device>}# Return only gateway devices:devices=myq.gateways# >>> {"serial_number123": <Device>}# Return *all* devices:devices=myq.devices# >>> {"serial_number123": <Device>, "serial_number456": <Device>}asyncio.get_event_loop().run_until_complete(main())API Propertiesaccounts: dictionary with all accounts (MyQAccount)covers: dictionary with all covers (MyQGarageDoor)devices: dictionary with all devices (MyQDevice)gateways: dictionary with all gateways (MyQDevice)lamps: dictionary with all lamps (MyQLamp)locks: dictionary with all locks (MyQLock)last_state_update: datetime (in UTC) last state update was retrieved for all itemspassword: password used for authentication. Can only be set, not retrievedusername: username for authentication.Account Properties (MyQAccount)api: Associated API objectid: ID for the accountname: Name of the accountcovers: dictionary with all covers for account (MyQGarageDoor)devices: dictionary with all devices for account (MyQDevice)gateways: dictionary with all gateways for account (MyQDevice)lamps: dictionary with all lamps for account (MyQLamp)locks: dictionary with all locks for account (MyQLock)account_json: Dictionary containing all account information as retrieved from MyQlast_state_update: datetime (in UTC) last state update was retrieved for all devices within this accountDevice Propertiesaccount: Return account associated with device (MyQAccount)close_allowed: Return whether the device can be closed unattended.device_family: Return the family in which this device lives.device_id: Return the device ID (serial number).device_json: Dictionary containing all device information as retrieved from MyQdevice_platform: Return the device platform.device_type: Return the device type.firmware_version: Return the family in which this device lives.href: URI for devicename: Return the device name.online: Return whether the device is online.open_allowed: Return whether the device can be opened unattended.parent_device_id: Return the device ID (serial number) of this device's parent.state: Return the current state of the device.state_update: Returns datetime when device was last updatedlow_battery: Returns if the garage has a low battery or not.API MethodsThese are coroutines and need to beawaited – seeexample.pyfor examples.authenticate: Authenticate (or re-authenticate) to MyQ. Call this to
re-authenticate immediately after changing username and/or password otherwise
new username/password will only be used when token has to be refreshed.update_device_info: Retrieve info and status for all accounts and devicesAccount MethodsAll of the routines on theMyQAccountclass are coroutines and need to beawaited – seeexample.pyfor examples.update: get the latest device info (state, etc.) for all devices associated with this account.Device MethodsAll of the routines on theMyQDeviceclass are coroutines and need to beawaited – seeexample.pyfor examples.update: get the latest device info (state, etc.). Note that
this runs MyQAccount.update and thus all devices within account will be updatedCover MethodsAll Device methods in addition to:close: close the coveropen: open the coverLamp MethodsAll Device methods in addition to:turnon: turn lamp onturnoff: turn lamp offAcknowledgementHuge thank you tohjdhjdfor figuring out the updated V6 API and
sharing his work with us.DisclaimerThe code here is based off of an unsupported API fromChamberlainand is subject to change without
notice. The authors claim no responsibility for damages to your garage door or
property by use of the code within.