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 socket.
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 <ip> [-u <username>] [-p <password]
Connect to all the devices in devices.json
at once and print their status:
python3 example.py -d -i
Show usage help:
python3 example.py -h
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.6.3.tar.gz
(12.2 kB
view details)
Built Distribution
aioshelly-0.6.3-py3-none-any.whl
(12.3 kB
view details)
File details
Details for the file aioshelly-0.6.3.tar.gz
.
File metadata
- Download URL: aioshelly-0.6.3.tar.gz
- Upload date:
- Size: 12.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | f53f64c92f8ffbdb4e4e9df9c569ef742e3c694ab97f6c0e1d18e693ca4d92a6 |
|
MD5 | d7cc3ba8898af50f886145d191f742d9 |
|
BLAKE2b-256 | 8f3b413bfc3b16f70c1027be9aa1c56d208e1d820b6cc9bb5538450fbefc5049 |
File details
Details for the file aioshelly-0.6.3-py3-none-any.whl
.
File metadata
- Download URL: aioshelly-0.6.3-py3-none-any.whl
- Upload date:
- Size: 12.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 88fdaa3076163f5ee67f3468016b947a63e32ddfc0674445df1070f515e2c218 |
|
MD5 | f20d501bc239b3c69d97ad25e24314d9 |
|
BLAKE2b-256 | 023fafc25e00498591de89bc218a3027554e432c81bd9e25747b71ac41066065 |