Skip to main content

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

This version

0.5.1

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.1.tar.gz (11.0 kB view details)

Uploaded Source

Built Distribution

aioshelly-0.5.1-py3-none-any.whl (11.5 kB view details)

Uploaded Python 3

File details

Details for the file aioshelly-0.5.1.tar.gz.

File metadata

  • Download URL: aioshelly-0.5.1.tar.gz
  • Upload date:
  • Size: 11.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.24.0 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.51.0 CPython/3.9.0

File hashes

Hashes for aioshelly-0.5.1.tar.gz
Algorithm Hash digest
SHA256 3c26f813a9d8dbe34d556adc027dcc14dbdff8ddd715594abc08f8d82a8d3f1b
MD5 e1bc3ab013a23f51d13acfd5f328bf89
BLAKE2b-256 fb8b3b33415481095cd8700ca174f4bd83ec9aefbf1c80a7d368324baeae6d72

See more details on using hashes here.

File details

Details for the file aioshelly-0.5.1-py3-none-any.whl.

File metadata

  • Download URL: aioshelly-0.5.1-py3-none-any.whl
  • Upload date:
  • Size: 11.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.24.0 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.51.0 CPython/3.9.0

File hashes

Hashes for aioshelly-0.5.1-py3-none-any.whl
Algorithm Hash digest
SHA256 1ce62c503bf9336d77c82835423afd9d7d9ee51d32e926f59d1f8d8130bae52a
MD5 1ee199ef6af2f2347a457aa4188ef053
BLAKE2b-256 8c9e5432f5fbbfcc7bfab1dcfcea81d24a16d0b42711a0d36d72ff740b50a553

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page