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, socket and netifaces.
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.5.4.tar.gz
(11.5 kB
view details)
Built Distribution
aioshelly-0.5.4-py3-none-any.whl
(12.0 kB
view details)
File details
Details for the file aioshelly-0.5.4.tar.gz
.
File metadata
- Download URL: aioshelly-0.5.4.tar.gz
- Upload date:
- Size: 11.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.9.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | eb537beeacbdfa95533394d3b6b1959308cd14b5af4250fcca49ac35958b30fb |
|
MD5 | 8c3fc62e5e533ecf8fb43b4f8f9db336 |
|
BLAKE2b-256 | 9e025bb82e1f230031e69f88e10ac35082bcfed2b78873ce5bb6453f833b00ef |
File details
Details for the file aioshelly-0.5.4-py3-none-any.whl
.
File metadata
- Download URL: aioshelly-0.5.4-py3-none-any.whl
- Upload date:
- Size: 12.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.9.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5e3f2569df9538d8c56bc614225a040cb5784b47826596b01bb9705f6ae92ee2 |
|
MD5 | 39cfce676ae52497d957d6d9dc1b3203 |
|
BLAKE2b-256 | 9113cce819d3892ece945045dd436f31ff397044a452b64316d60d11ee4061a8 |