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.2.tar.gz
(12.1 kB
view details)
Built Distribution
aioshelly-0.6.2-py3-none-any.whl
(12.2 kB
view details)
File details
Details for the file aioshelly-0.6.2.tar.gz
.
File metadata
- Download URL: aioshelly-0.6.2.tar.gz
- Upload date:
- Size: 12.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.1 importlib_metadata/3.10.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.9.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 356d3b25ea760093b22056fcd7296f8d6af976e56bdb6fb390c19268b1950b59 |
|
MD5 | 6c5adb8028ed470d1d114c99449a555f |
|
BLAKE2b-256 | 6db706b3b0ca321cf81b081e027605008aa61404680f95f5bdd80fdfd53b6f67 |
File details
Details for the file aioshelly-0.6.2-py3-none-any.whl
.
File metadata
- Download URL: aioshelly-0.6.2-py3-none-any.whl
- Upload date:
- Size: 12.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.1 importlib_metadata/3.10.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.9.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1a9b50fe9ea58a09a836757f0239c5bc1fc9097695d39ac64acc8abc6cddcc2b |
|
MD5 | 50eb93766d544cb52b56171a20809fc7 |
|
BLAKE2b-256 | 71825a53ddd61a35f93ff15b0f5b9f7c7ac800e9ae12291be76bbd3d52378efd |