# Introduction
This 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 as [Ratgdo](https://github.com/RATGDO/esphome-ratgdo)
# [Homeassistant](https://home-assistant.io)
[Homeassistant](https://home-assistant.io) has a [core myQ component](https://www.home-assistant.io/integrations/myq/) leveraging this package.
In addition, there is also a [HACS myQ component](https://github.com/ehendrix23/hass_myq) available that can be added into HACS as a custom repository.
# Getting Started
## Installation
```python
pip install pymyq
```
## Usage
`pymyq` starts within an [aiohttp](https://aiohttp.readthedocs.io/en/stable/)
`ClientSession`:
```python
import asyncio
from aiohttp import ClientSession
async def main() -> None:
"""Create the aiohttp session and run."""
async with ClientSession() as websession:
# YOUR CODE HERE
asyncio.get_event_loop().run_until_complete(main())
```
To get all MyQ devices associated with an account:
```python
import asyncio
from aiohttp import ClientSession
import pymyq
async def main() -> None:
"""Create the aiohttp session and run."""
async with ClientSession() as websession:
myq = await pymyq.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 Properties
- `accounts`: 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 items
- `password`: password used for authentication. Can only be set, not retrieved
- `username`: username for authentication.
## Account Properties (MyQAccount)
- `api`: Associated API object
- `id`: ID for the account
- `name`: Name of the account
- `covers`: 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 MyQ
- `last_state_update`: datetime (in UTC) last state update was retrieved for all devices within this account
## Device Properties
- `account`: 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 MyQ
- `device_platform`: Return the device platform.
- `device_type`: Return the device type.
- `firmware_version`: Return the family in which this device lives.
- `href`: URI for device
- `name`: 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 updated
- `low_battery`: Returns if the garage has a low battery or not.
## API Methods
These are coroutines and need to be `await`ed – see `example.py` for 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 devices
## Account Methods
All of the routines on the `MyQAccount` class are coroutines and need to be
`await`ed – see `example.py` for examples.
- `update`: get the latest device info (state, etc.) for all devices associated with this account.
## Device Methods
All of the routines on the `MyQDevice` class are coroutines and need to be
`await`ed – see `example.py` for examples.
- `update`: get the latest device info (state, etc.). Note that
this runs MyQAccount.update and thus all devices within account will be updated
## Cover Methods
All Device methods in addition to:
- `close`: close the cover
- `open`: open the cover
## Lamp Methods
All Device methods in addition to:
- `turnon`: turn lamp on
- `turnoff`: turn lamp off
# Acknowledgement
Huge thank you to [hjdhjd](https://github.com/hjdhjd) for figuring out the updated V6 API and
sharing his work with us.
# Disclaimer
The code here is based off of an unsupported API from
[Chamberlain](http://www.chamberlain.com/) and 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.
Raw data
{
"_id": null,
"home_page": "https://github.com/Python-MyQ/Python-MyQ",
"name": "python-myq",
"maintainer": "",
"docs_url": null,
"requires_python": ">=3.8,<4.0",
"maintainer_email": "",
"keywords": "",
"author": "Lash-L",
"author_email": "lukelashley99@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/54/36/f1aca68ca19c38cebfb1a84223a8ef477e7491c5fc96efd0ff43e83496c2/python_myq-3.1.13.tar.gz",
"platform": null,
"description": "# Introduction\n\nThis is a Python 3.8+ module aiming to interact with the Chamberlain MyQ API.\n\nCode is licensed under the MIT license.\n\n It is recommended that you consider using an open-source solution instead of a myq such as [Ratgdo](https://github.com/RATGDO/esphome-ratgdo)\n\n# [Homeassistant](https://home-assistant.io)\n\n[Homeassistant](https://home-assistant.io) has a [core myQ component](https://www.home-assistant.io/integrations/myq/) leveraging this package.\nIn addition, there is also a [HACS myQ component](https://github.com/ehendrix23/hass_myq) available that can be added into HACS as a custom repository.\n\n# Getting Started\n\n## Installation\n\n```python\npip install pymyq\n```\n\n## Usage\n\n`pymyq` starts within an [aiohttp](https://aiohttp.readthedocs.io/en/stable/)\n`ClientSession`:\n\n```python\nimport asyncio\n\nfrom aiohttp import ClientSession\n\n\nasync def main() -> None:\n \"\"\"Create the aiohttp session and run.\"\"\"\n async with ClientSession() as websession:\n # YOUR CODE HERE\n\n\nasyncio.get_event_loop().run_until_complete(main())\n```\n\nTo get all MyQ devices associated with an account:\n\n```python\nimport asyncio\n\nfrom aiohttp import ClientSession\n\nimport pymyq\n\n\nasync def main() -> None:\n \"\"\"Create the aiohttp session and run.\"\"\"\n async with ClientSession() as websession:\n myq = await pymyq.login('<EMAIL>', '<PASSWORD>', websession)\n\n # Return only cover devices:\n devices = myq.covers\n # >>> {\"serial_number123\": <Device>}\n\n # Return only lamps devices:\n devices = myq.lamps\n # >>> {\"serial_number123\": <Device>}\n\n # Return only locks devices:\n devices = myq.locks\n # >>> {\"serial_number123\": <Device>}\n\n # Return only gateway devices:\n devices = myq.gateways\n # >>> {\"serial_number123\": <Device>}\n\n # Return *all* devices:\n devices = myq.devices\n # >>> {\"serial_number123\": <Device>, \"serial_number456\": <Device>}\n\n\nasyncio.get_event_loop().run_until_complete(main())\n```\n\n## API Properties\n\n- `accounts`: dictionary with all accounts (MyQAccount)\n- `covers`: dictionary with all covers (MyQGarageDoor)\n- `devices`: dictionary with all devices (MyQDevice)\n- `gateways`: dictionary with all gateways (MyQDevice)\n- `lamps`: dictionary with all lamps (MyQLamp)\n- `locks`: dictionary with all locks (MyQLock)\n- `last_state_update`: datetime (in UTC) last state update was retrieved for all items\n- `password`: password used for authentication. Can only be set, not retrieved\n- `username`: username for authentication.\n\n## Account Properties (MyQAccount)\n\n- `api`: Associated API object\n- `id`: ID for the account\n- `name`: Name of the account\n- `covers`: dictionary with all covers for account (MyQGarageDoor)\n- `devices`: dictionary with all devices for account (MyQDevice)\n- `gateways`: dictionary with all gateways for account (MyQDevice)\n- `lamps`: dictionary with all lamps for account (MyQLamp)\n- `locks`: dictionary with all locks for account (MyQLock)\n- `account_json`: Dictionary containing all account information as retrieved from MyQ\n- `last_state_update`: datetime (in UTC) last state update was retrieved for all devices within this account\n\n## Device Properties\n\n- `account`: Return account associated with device (MyQAccount)\n- `close_allowed`: Return whether the device can be closed unattended.\n- `device_family`: Return the family in which this device lives.\n- `device_id`: Return the device ID (serial number).\n- `device_json`: Dictionary containing all device information as retrieved from MyQ\n- `device_platform`: Return the device platform.\n- `device_type`: Return the device type.\n- `firmware_version`: Return the family in which this device lives.\n- `href`: URI for device\n- `name`: Return the device name.\n- `online`: Return whether the device is online.\n- `open_allowed`: Return whether the device can be opened unattended.\n- `parent_device_id`: Return the device ID (serial number) of this device's parent.\n- `state`: Return the current state of the device.\n- `state_update`: Returns datetime when device was last updated\n- `low_battery`: Returns if the garage has a low battery or not.\n\n## API Methods\n\nThese are coroutines and need to be `await`ed \u2013 see `example.py` for examples.\n\n- `authenticate`: Authenticate (or re-authenticate) to MyQ. Call this to\n re-authenticate immediately after changing username and/or password otherwise\n new username/password will only be used when token has to be refreshed.\n- `update_device_info`: Retrieve info and status for all accounts and devices\n\n## Account Methods\n\nAll of the routines on the `MyQAccount` class are coroutines and need to be\n`await`ed \u2013 see `example.py` for examples.\n\n- `update`: get the latest device info (state, etc.) for all devices associated with this account.\n\n## Device Methods\n\nAll of the routines on the `MyQDevice` class are coroutines and need to be\n`await`ed \u2013 see `example.py` for examples.\n\n- `update`: get the latest device info (state, etc.). Note that\n this runs MyQAccount.update and thus all devices within account will be updated\n\n## Cover Methods\n\nAll Device methods in addition to:\n\n- `close`: close the cover\n- `open`: open the cover\n\n## Lamp Methods\n\nAll Device methods in addition to:\n\n- `turnon`: turn lamp on\n- `turnoff`: turn lamp off\n\n# Acknowledgement\n\nHuge thank you to [hjdhjd](https://github.com/hjdhjd) for figuring out the updated V6 API and\nsharing his work with us.\n\n# Disclaimer\n\nThe code here is based off of an unsupported API from\n[Chamberlain](http://www.chamberlain.com/) and is subject to change without\nnotice. The authors claim no responsibility for damages to your garage door or\nproperty by use of the code within.\n\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "Python package for controlling MyQ-Enabled Garage Door.",
"version": "3.1.13",
"project_urls": {
"Homepage": "https://github.com/Python-MyQ/Python-MyQ",
"Repository": "https://github.com/Python-MyQ/Python-MyQ"
},
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "a1e6be6e819860b41f816dba07f66f2b58af2b33f0e34f6a3c14fc5715e9102e",
"md5": "c3e9a885b046823844a3a87ac345d1aa",
"sha256": "5ad41fbc736a2988637e99bbbf489f3f2e6290d8d24ee213c2c89b8c5cccc95e"
},
"downloads": -1,
"filename": "python_myq-3.1.13-py3-none-any.whl",
"has_sig": false,
"md5_digest": "c3e9a885b046823844a3a87ac345d1aa",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.8,<4.0",
"size": 22142,
"upload_time": "2023-10-12T00:46:28",
"upload_time_iso_8601": "2023-10-12T00:46:28.347090Z",
"url": "https://files.pythonhosted.org/packages/a1/e6/be6e819860b41f816dba07f66f2b58af2b33f0e34f6a3c14fc5715e9102e/python_myq-3.1.13-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "5436f1aca68ca19c38cebfb1a84223a8ef477e7491c5fc96efd0ff43e83496c2",
"md5": "c45196d12b1051be09befb9aff937aac",
"sha256": "63ab6d3352b5ba59ca0ba90825b1f04f5be7d7ec19fd8a3996fd7319e8b298c9"
},
"downloads": -1,
"filename": "python_myq-3.1.13.tar.gz",
"has_sig": false,
"md5_digest": "c45196d12b1051be09befb9aff937aac",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.8,<4.0",
"size": 19024,
"upload_time": "2023-10-12T00:46:30",
"upload_time_iso_8601": "2023-10-12T00:46:30.095982Z",
"url": "https://files.pythonhosted.org/packages/54/36/f1aca68ca19c38cebfb1a84223a8ef477e7491c5fc96efd0ff43e83496c2/python_myq-3.1.13.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-10-12 00:46:30",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "Python-MyQ",
"github_project": "Python-MyQ",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "python-myq"
}