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

Uploaded Source

Built Distribution

aioshelly-0.6.1-py3-none-any.whl (11.8 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: aioshelly-0.6.1.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.58.0 CPython/3.9.1

File hashes

Hashes for aioshelly-0.6.1.tar.gz
Algorithm Hash digest
SHA256 baa63bbbb6a2aeef195aa28d7dd13630702d335494ea4df7c85bfd4ab5f5e478
MD5 a5f03b6d55c5bfae891799b3bca1922a
BLAKE2b-256 e1c849afefec9252cc6b6ee3c71537b14c7458135f3f0da64ef1b34e54a17428

See more details on using hashes here.

File details

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

File metadata

  • Download URL: aioshelly-0.6.1-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.58.0 CPython/3.9.1

File hashes

Hashes for aioshelly-0.6.1-py3-none-any.whl
Algorithm Hash digest
SHA256 c2ac94882ebc90d9a9238193da0e5456e8cbd16c14ed92d2c39b22ad90fa6275
MD5 f3ece8bdbac4d32057865ffccc83171c
BLAKE2b-256 ecac2190bbb5fc5fdff3b5cbb5339420856b58c7b9fe4a6e3f5250a0267ea6f5

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