|
1 | 1 | # Introduction
|
2 | 2 |
|
3 |
| -This is a python module aiming to interact with the Chamberlain MyQ API. |
| 3 | +This is a Python 3.5+ module aiming to interact with the Chamberlain MyQ API. |
4 | 4 |
|
5 | 5 | Code is licensed under the MIT license.
|
6 | 6 |
|
7 |
| -Getting Started |
8 |
| -=============== |
| 7 | +# Getting Started |
9 | 8 |
|
10 |
| -# Usage |
| 9 | +## Installation |
11 | 10 |
|
12 | 11 | ```python
|
13 |
| -from pymyq import MyQAPI as pymyq |
| 12 | +pip install pymyq |
| 13 | +``` |
| 14 | + |
| 15 | +## Usage |
| 16 | + |
| 17 | +`pymyq` starts within an [aiohttp](https://aiohttp.readthedocs.io/en/stable/) |
| 18 | +`ClientSession`: |
| 19 | + |
| 20 | +```python |
| 21 | +import asyncio |
| 22 | + |
| 23 | +from aiohttp import ClientSession |
| 24 | + |
| 25 | + |
| 26 | +async def main() -> None: |
| 27 | + """Create the aiohttp session and run.""" |
| 28 | + async with ClientSession() as websession: |
| 29 | + # YOUR CODE HERE |
| 30 | + |
14 | 31 |
|
15 |
| -myq = pymyq(username, password, brand) |
| 32 | +asyncio.get_event_loop().run_until_complete(main()) |
16 | 33 | ```
|
17 | 34 |
|
18 |
| -# Methods |
| 35 | +To get all MyQ devices associated with an account: |
19 | 36 |
|
20 |
| -def is_supported_brand(self): |
21 |
| -"""Return true/false based on supported brands list and input.""" |
| 37 | +```python |
| 38 | +import asyncio |
| 39 | + |
| 40 | +from aiohttp import ClientSession |
| 41 | + |
| 42 | +import pymyq |
| 43 | + |
| 44 | + |
| 45 | +async def main() -> None: |
| 46 | + """Create the aiohttp session and run.""" |
| 47 | + async with ClientSession() as websession: |
| 48 | + # Valid Brands: 'chamberlain', 'craftsman', 'liftmaster', 'merlin' |
| 49 | + myq = await pymyq.login('<EMAIL>', '<PASSWORD>', '<BRAND>', websession) |
22 | 50 |
|
23 |
| -def is_login_valid(self): |
24 |
| -"""Return true/false based on successful authentication.""" |
| 51 | + # Return only cover devices: |
| 52 | + devices = await myq.get_devices() |
| 53 | + |
| 54 | + # Return *all* devices: |
| 55 | + devices = await myq.get_devices(covers_only=False) |
| 56 | + |
| 57 | + |
| 58 | +asyncio.get_event_loop().run_until_complete(main()) |
| 59 | +``` |
25 | 60 |
|
26 |
| -def get_devices(self): |
27 |
| -"""Return devices from API""" |
| 61 | +## Device Properties |
28 | 62 |
|
29 |
| -def get_garage_doors(self): |
30 |
| -"""Parse devices data and extract garage doors. Return garage doors.""" |
31 |
| - |
32 |
| -def get_status(self, device_id): |
33 |
| -"""Return current door status(open/closed)""" |
| 63 | +* `brand`: the brand of the device |
| 64 | +* `device_id`: the device's MyQ ID |
| 65 | +* `parent_id`: the device's parent device's MyQ ID |
| 66 | +* `name`: the name of the device |
| 67 | +* `serial`: the serial number of the device |
| 68 | +* `state`: the device's current state |
| 69 | +* `type`: the type of MyQ device |
34 | 70 |
|
35 |
| -def close_device(self, device_id): |
36 |
| -"""Send request to close the door.""" |
| 71 | +## Methods |
37 | 72 |
|
38 |
| -def open_device(self, device_id): |
39 |
| -"""Send request to open the door.""" |
| 73 | +All of the routines on the `MyQDevice` class are coroutines and need to be |
| 74 | +`await`ed. |
40 | 75 |
|
41 |
| -def set_state(self, device_id, state): |
42 |
| -"""Send request for request door state change.""" |
| 76 | +* `close`: close the device |
| 77 | +* `open`: open the device |
| 78 | +* `update`: get the latest device state (which can then be accessed via the |
| 79 | +`state` property) |
43 | 80 |
|
44 |
| -### Disclaimer |
| 81 | +# Disclaimer |
45 | 82 |
|
46 |
| -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. |
| 83 | +The code here is based off of an unsupported API from |
| 84 | +[Chamberlain](http://www.chamberlain.com/) and is subject to change without |
| 85 | +notice. The authors claim no responsibility for damages to your garage door or |
| 86 | +property by use of the code within. |
0 commit comments