Asynchronous library to control Shelly devices.
Project description
Aioshelly
Asynchronous library to control Shelly
This library is under development.
Requires Python 3 and uses asyncio, aiohttp and aiocoap.
import asyncio
from pprint import pprint
import aiohttp
import aioshelly
async def main():
options = aioshelly.ConnectionOptions("192.168.1.165", "username", "password")
async with aiohttp.ClientSession() as aiohttp_session, aioshelly.COAP() as coap_context:
try:
device = await asyncio.wait_for(
aioshelly.Device.create(aiohttp_session, coap_context, options), 5
)
except asyncio.TimeoutError:
print("Timeout connecting to", ip)
return
for block in device.blocks:
print(block)
pprint(block.current_values())
print()
if __name__ == "__main__":
asyncio.run(main())
Included examples
The repository includes two examples to quickly try it out.
Connect to a device and print its status whenever we receive a state change:
python3 example.py <ip> [<username> <password]
Connect to all the devices in devices.json
at once and print their status:
python3 example.py
Contribution guidelines
Object hierarchy and property/method names should match the Shelly API.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
aioshelly-0.5.2.tar.gz
(11.2 kB
view details)
Built Distribution
aioshelly-0.5.2-py3-none-any.whl
(11.8 kB
view details)
File details
Details for the file aioshelly-0.5.2.tar.gz
.
File metadata
- Download URL: aioshelly-0.5.2.tar.gz
- Upload date:
- Size: 11.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.3.0 pkginfo/1.6.1 requests/2.25.1 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.55.1 CPython/3.9.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 44c1249b487039c0efa2c5ec040e247a5d4463527c92e3b4e33c4a27e5a5fe88 |
|
MD5 | fac942909faa76457802f78d0f3a08db |
|
BLAKE2b-256 | a3ca2adca362ac6d38f520bbc76b647f93bb252b89b18e46cb7e8a4da8e35d46 |
File details
Details for the file aioshelly-0.5.2-py3-none-any.whl
.
File metadata
- Download URL: aioshelly-0.5.2-py3-none-any.whl
- Upload date:
- Size: 11.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.3.0 pkginfo/1.6.1 requests/2.25.1 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.55.1 CPython/3.9.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7c9ddf065cd5438b691a5590896821d1726f1a2b5e1c19ed46f4dbac7ec50a05 |
|
MD5 | 79b9bd1a6608e2e54abd62b824e5e75c |
|
BLAKE2b-256 | fb6f75ea7d83fb496b17c8d4095985522be8d78ef42a79ceaf5c54d9c24bcf63 |