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.0.tar.gz
(11.3 kB
view details)
Built Distribution
aioshelly-0.6.0-py3-none-any.whl
(11.8 kB
view details)
File details
Details for the file aioshelly-0.6.0.tar.gz
.
File metadata
- Download URL: aioshelly-0.6.0.tar.gz
- Upload date:
- Size: 11.3 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.1 CPython/3.9.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | b856c8ef0682924e2150478943eee77efdc4b3195bf533648cf6c8384dcb8b25 |
|
MD5 | 3788b9d3c9cb72c6353368ac6bed4677 |
|
BLAKE2b-256 | 406d6b685cd6d4b5736f81f71c0ac08a930b93a1f20f52ef34a115a80adb4d18 |
File details
Details for the file aioshelly-0.6.0-py3-none-any.whl
.
File metadata
- Download URL: aioshelly-0.6.0-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.7.0 requests/2.25.1 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.56.1 CPython/3.9.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | c0fa8fbf904384e969c0d7154d382e3dddd1245dfc2acd365b3aef055d4b4faf |
|
MD5 | 2f007ffa931551c23a9d69be8889c533 |
|
BLAKE2b-256 | bcae08ad59dd028434c67b8093a4c136dcfe2949abbc52cb59c1da7d8cb6d608 |