Skip to main content

Python package for controlling MyQ-Enabled Garage Door.

Project description

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

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

  • 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 awaited – 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 awaited – 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 awaited – 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 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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

python_myq-3.1.13.tar.gz (19.0 kB view details)

Uploaded Source

Built Distribution

python_myq-3.1.13-py3-none-any.whl (22.1 kB view details)

Uploaded Python 3

File details

Details for the file python_myq-3.1.13.tar.gz.

File metadata

  • Download URL: python_myq-3.1.13.tar.gz
  • Upload date:
  • Size: 19.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.9.6 readme-renderer/42.0 requests/2.31.0 requests-toolbelt/1.0.0 urllib3/2.0.6 tqdm/4.66.1 importlib-metadata/6.8.0 keyring/24.2.0 rfc3986/2.0.0 colorama/0.4.6 CPython/3.10.13

File hashes

Hashes for python_myq-3.1.13.tar.gz
Algorithm Hash digest
SHA256 63ab6d3352b5ba59ca0ba90825b1f04f5be7d7ec19fd8a3996fd7319e8b298c9
MD5 c45196d12b1051be09befb9aff937aac
BLAKE2b-256 5436f1aca68ca19c38cebfb1a84223a8ef477e7491c5fc96efd0ff43e83496c2

See more details on using hashes here.

File details

Details for the file python_myq-3.1.13-py3-none-any.whl.

File metadata

  • Download URL: python_myq-3.1.13-py3-none-any.whl
  • Upload date:
  • Size: 22.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.9.6 readme-renderer/42.0 requests/2.31.0 requests-toolbelt/1.0.0 urllib3/2.0.6 tqdm/4.66.1 importlib-metadata/6.8.0 keyring/24.2.0 rfc3986/2.0.0 colorama/0.4.6 CPython/3.10.13

File hashes

Hashes for python_myq-3.1.13-py3-none-any.whl
Algorithm Hash digest
SHA256 5ad41fbc736a2988637e99bbbf489f3f2e6290d8d24ee213c2c89b8c5cccc95e
MD5 c3e9a885b046823844a3a87ac345d1aa
BLAKE2b-256 a1e6be6e819860b41f816dba07f66f2b58af2b33f0e34f6a3c14fc5715e9102e

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page