https://github.com/moff4/aqara_capi
SDK for Aqara Cloud API
https://github.com/moff4/aqara_capi
Last synced: 5 months ago
JSON representation
SDK for Aqara Cloud API
- Host: GitHub
- URL: https://github.com/moff4/aqara_capi
- Owner: moff4
- License: mit
- Created: 2022-07-29T14:56:12.000Z (almost 4 years ago)
- Default Branch: master
- Last Pushed: 2022-09-12T19:36:04.000Z (almost 4 years ago)
- Last Synced: 2025-12-22T08:42:18.061Z (6 months ago)
- Language: Python
- Homepage:
- Size: 34.2 KB
- Stars: 8
- Watchers: 1
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Aqara Cloud API
[](https://www.codefactor.io/repository/github/moff4/aqara_capi)
### Python SDK for Aqara Cloud API
_(Functionality is not full, but already has core for futher upgrades)_
### Install
```bash
pip install aqara_capi
```
### Example of usage
```python
from aqara_capi import CloudApiClient, Locality
# create client
client = CloudApiClient(
app_id=APP_ID, # your params from https://developer.aqara.com/console
app_key=APP_KEY,
key_id=KEY_ID,
locality=Locality.RU, # for cloud domain
)
# set access and refresh tokens
client.set_tokens(access_token='...', refresh_token='...')
# or generate them
client.get_auth_code(
account='my@example.com',
account_type=0,
access_token_validity='7d',
)
client.get_access_token(
auth_code='secret code from ur email',
account='my@example.com',
account_type=0,
)
# print your devices
response = client.query_device_info()
print(response.result)
# print device attributes
response = client.query_resource_info(
model='lumi.light....',
)
print(response.result)
# trigger some action (for example turn on light)
client.write_resource_device(
subject_id='lumi...',
resource_id='4.1.85',
value='1',
)
```
[](https://www.buymeacoffee.com/komissarov)