arraylabs / pymyq

Python wrapper for MyQ API
MIT License
112 stars 42 forks source link

Introduction

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

Code is licensed under the MIT license.

Homeassistant

Homeassistant has a core myQ component leveraging this package. In addition, there is also a HACS myQ component available that can be added into HACS as a custom repository.

Getting Started

Installation

pip install pymyq

Usage

pymyq starts within an aiohttp ClientSession:

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:

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

Account Properties (MyQAccount)

Device Properties

API Methods

These are coroutines and need to be awaited – see example.py for examples.

Account Methods

All of the routines on the MyQAccount class are coroutines and need to be awaited – see example.py for examples.

Device Methods

All of the routines on the MyQDevice class are coroutines and need to be awaited – see example.py for examples.

Cover Methods

All Device methods in addition to:

Lamp Methods

All Device methods in addition to:

Acknowledgement

Huge thank you to 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 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.