pymyq2


Namepymyq2 JSON
Version 3.1.7 PyPI version JSON
download
home_pagehttps://github.com/overallcoma/pymyq2
SummaryPython package for controlling MyQ-Enabled Garage Door
upload_time2023-10-26 07:29:20
maintainer
docs_urlNone
authorSteven Loftus
requires_python>=3.8
licenseMIT
keywords
VCS
bugtrack_url
requirements aiohttp beautifulsoup4 pkce
Travis-CI No Travis.
coveralls test coverage No coveralls.
            
# Introduction

This is a Python 3.8+ module aiming to interact with the Chamberlain MyQ API.

Code is licensed under the MIT license.

# [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 pymyq2


async def main() -> None:
  """Create the aiohttp session and run."""
  async with ClientSession() as websession:
    myq = await pymyq2.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/overallcoma/pymyq2",
    "name": "pymyq2",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.8",
    "maintainer_email": "",
    "keywords": "",
    "author": "Steven Loftus",
    "author_email": "",
    "download_url": "https://files.pythonhosted.org/packages/74/06/2356aabfdbf07ed224a118469c254fe985acbee02a957ea32aed6131a9fa/pymyq2-3.1.7.tar.gz",
    "platform": null,
    "description": "\r\n# Introduction\r\n\r\nThis is a Python 3.8+ module aiming to interact with the Chamberlain MyQ API.\r\n\r\nCode is licensed under the MIT license.\r\n\r\n# [Homeassistant](https://home-assistant.io)\r\n\r\n[Homeassistant](https://home-assistant.io) has a [core myQ component](https://www.home-assistant.io/integrations/myq/) leveraging this package.\r\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.\r\n\r\n# Getting Started\r\n\r\n## Installation\r\n\r\n```python\r\npip install pymyq\r\n```\r\n\r\n## Usage\r\n\r\n`pymyq` starts within an [aiohttp](https://aiohttp.readthedocs.io/en/stable/)\r\n`ClientSession`:\r\n\r\n```python\r\nimport asyncio\r\n\r\nfrom aiohttp import ClientSession\r\n\r\n\r\nasync def main() -> None:\r\n    \"\"\"Create the aiohttp session and run.\"\"\"\r\n    async with ClientSession() as websession:\r\n      # YOUR CODE HERE\r\n\r\n\r\nasyncio.get_event_loop().run_until_complete(main())\r\n```\r\n\r\nTo get all MyQ devices associated with an account:\r\n\r\n```python\r\nimport asyncio\r\n\r\nfrom aiohttp import ClientSession\r\n\r\nimport pymyq2\r\n\r\n\r\nasync def main() -> None:\r\n  \"\"\"Create the aiohttp session and run.\"\"\"\r\n  async with ClientSession() as websession:\r\n    myq = await pymyq2.login('<EMAIL>', '<PASSWORD>', websession)\r\n\r\n    # Return only cover devices:\r\n    devices = myq.covers\r\n    # >>> {\"serial_number123\": <Device>}\r\n\r\n    # Return only lamps devices:\r\n    devices = myq.lamps\r\n    # >>> {\"serial_number123\": <Device>}\r\n\r\n    # Return only locks devices:\r\n    devices = myq.locks\r\n    # >>> {\"serial_number123\": <Device>}\r\n\r\n    # Return only gateway devices:\r\n    devices = myq.gateways\r\n    # >>> {\"serial_number123\": <Device>}\r\n\r\n    # Return *all* devices:\r\n    devices = myq.devices\r\n    # >>> {\"serial_number123\": <Device>, \"serial_number456\": <Device>}\r\n\r\n\r\nasyncio.get_event_loop().run_until_complete(main())\r\n```\r\n\r\n## API Properties\r\n\r\n- `accounts`: dictionary with all accounts (MyQAccount)\r\n- `covers`: dictionary with all covers (MyQGarageDoor)\r\n- `devices`: dictionary with all devices (MyQDevice)\r\n- `gateways`: dictionary with all gateways (MyQDevice)\r\n- `lamps`: dictionary with all lamps (MyQLamp)\r\n- `locks`: dictionary with all locks (MyQLock)\r\n- `last_state_update`: datetime (in UTC) last state update was retrieved for all items\r\n- `password`: password used for authentication. Can only be set, not retrieved\r\n- `username`: username for authentication.\r\n\r\n## Account Properties (MyQAccount)\r\n\r\n- `api`: Associated API object\r\n- `id`: ID for the account\r\n- `name`: Name of the account\r\n- `covers`: dictionary with all covers for account (MyQGarageDoor)\r\n- `devices`: dictionary with all devices for account (MyQDevice)\r\n- `gateways`: dictionary with all gateways for account (MyQDevice)\r\n- `lamps`: dictionary with all lamps for account (MyQLamp)\r\n- `locks`: dictionary with all locks for account (MyQLock)\r\n- `account_json`: Dictionary containing all account information as retrieved from MyQ\r\n- `last_state_update`: datetime (in UTC) last state update was retrieved for all devices within this account\r\n\r\n## Device Properties\r\n\r\n- `account`: Return account associated with device (MyQAccount)\r\n- `close_allowed`: Return whether the device can be closed unattended.\r\n- `device_family`: Return the family in which this device lives.\r\n- `device_id`: Return the device ID (serial number).\r\n- `device_json`: Dictionary containing all device information as retrieved from MyQ\r\n- `device_platform`: Return the device platform.\r\n- `device_type`: Return the device type.\r\n- `firmware_version`: Return the family in which this device lives.\r\n- `href`: URI for device\r\n- `name`: Return the device name.\r\n- `online`: Return whether the device is online.\r\n- `open_allowed`: Return whether the device can be opened unattended.\r\n- `parent_device_id`: Return the device ID (serial number) of this device's parent.\r\n- `state`: Return the current state of the device.\r\n- `state_update`: Returns datetime when device was last updated\r\n- `low_battery`: Returns if the garage has a low battery or not.\r\n\r\n## API Methods\r\n\r\nThese are coroutines and need to be `await`ed \u2013 see `example.py` for examples.\r\n\r\n- `authenticate`: Authenticate (or re-authenticate) to MyQ. Call this to\r\n  re-authenticate immediately after changing username and/or password otherwise\r\n  new username/password will only be used when token has to be refreshed.\r\n- `update_device_info`: Retrieve info and status for all accounts and devices\r\n\r\n## Account Methods\r\n\r\nAll of the routines on the `MyQAccount` class are coroutines and need to be\r\n`await`ed \u2013 see `example.py` for examples.\r\n\r\n- `update`: get the latest device info (state, etc.) for all devices associated with this account.\r\n\r\n## Device Methods\r\n\r\nAll of the routines on the `MyQDevice` class are coroutines and need to be\r\n`await`ed \u2013 see `example.py` for examples.\r\n\r\n- `update`: get the latest device info (state, etc.). Note that\r\n  this runs MyQAccount.update and thus all devices within account will be updated\r\n\r\n## Cover Methods\r\n\r\nAll Device methods in addition to:\r\n\r\n- `close`: close the cover\r\n- `open`: open the cover\r\n\r\n## Lamp Methods\r\n\r\nAll Device methods in addition to:\r\n\r\n- `turnon`: turn lamp on\r\n- `turnoff`: turn lamp off\r\n\r\n# Acknowledgement\r\n\r\nHuge thank you to [hjdhjd](https://github.com/hjdhjd) for figuring out the updated V6 API and\r\nsharing his work with us.\r\n\r\n# Disclaimer\r\n\r\nThe code here is based off of an unsupported API from\r\n[Chamberlain](http://www.chamberlain.com/) and is subject to change without\r\nnotice. The authors claim no responsibility for damages to your garage door or\r\nproperty by use of the code within.\r\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Python package for controlling MyQ-Enabled Garage Door",
    "version": "3.1.7",
    "project_urls": {
        "Homepage": "https://github.com/overallcoma/pymyq2"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "1e5ab47d9607d8c689d57fbb51d48214eeb0df980fc656d5c912f32c2f26c961",
                "md5": "987e41ba87cc6264d7dc1ece67413637",
                "sha256": "6b44866a6e81cb9ee53b50ea9ed8141c5d4e4736717ca9cdb62fd390007b24a2"
            },
            "downloads": -1,
            "filename": "pymyq2-3.1.7-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "987e41ba87cc6264d7dc1ece67413637",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8",
            "size": 20958,
            "upload_time": "2023-10-26T07:29:19",
            "upload_time_iso_8601": "2023-10-26T07:29:19.025272Z",
            "url": "https://files.pythonhosted.org/packages/1e/5a/b47d9607d8c689d57fbb51d48214eeb0df980fc656d5c912f32c2f26c961/pymyq2-3.1.7-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "74062356aabfdbf07ed224a118469c254fe985acbee02a957ea32aed6131a9fa",
                "md5": "0415bfafc89f4e0899963dd99df36098",
                "sha256": "d1e048bf7da3d656252bd0f1deba03e58ff9b58c04247d58890957011a45b1d0"
            },
            "downloads": -1,
            "filename": "pymyq2-3.1.7.tar.gz",
            "has_sig": false,
            "md5_digest": "0415bfafc89f4e0899963dd99df36098",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8",
            "size": 19869,
            "upload_time": "2023-10-26T07:29:20",
            "upload_time_iso_8601": "2023-10-26T07:29:20.567175Z",
            "url": "https://files.pythonhosted.org/packages/74/06/2356aabfdbf07ed224a118469c254fe985acbee02a957ea32aed6131a9fa/pymyq2-3.1.7.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-10-26 07:29:20",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "overallcoma",
    "github_project": "pymyq2",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "requirements": [
        {
            "name": "aiohttp",
            "specs": [
                [
                    ">=",
                    "3.7"
                ]
            ]
        },
        {
            "name": "beautifulsoup4",
            "specs": [
                [
                    ">=",
                    "4.9.3"
                ]
            ]
        },
        {
            "name": "pkce",
            "specs": [
                [
                    ">=",
                    "1.0.2"
                ]
            ]
        }
    ],
    "lcname": "pymyq2"
}
        
Elapsed time: 0.58396s