Skip to main content

Asynchronous Python wrapper library over Bond Local API

Project description

bond-api

Asynchronous Python wrapper library over Bond Local API

Installation

From PyPi:

pip3 install bond-api

Library Usage

import asyncio

from aiohttp import ClientResponseError, ClientConnectorError

from bond_api import Bond, Action


async def main():
    """Example of library usage."""

    bond = Bond("[your ip or hostname here]", "[your bond API token here]")

    try:
        print("Version:")
        print(await bond.version())

        print("Device IDs:")
        device_ids = await bond.devices()
        print(device_ids)

        print("Devices:")
        devices = await asyncio.gather(*[bond.device(device_id) for device_id in device_ids])
        print(devices)

        print("Devices Properties:")
        properties = await asyncio.gather(*[bond.device_properties(device_id) for device_id in device_ids])
        print(properties)

        print("Devices State:")
        state = await asyncio.gather(*[bond.device_state(device_id) for device_id in device_ids])
        print(state)

        print("Turn on fan!")
        await bond.action("[your fan device ID here]", Action.turn_on())

        print("Change fan speed!")
        await bond.action("[your fan device ID here]", Action.set_speed(2))

        print("Turn off fan!")
        await bond.action("[your fan device ID here]", Action.turn_off())

    except ClientResponseError as x:
        print("Client response error: ", x)
    except ClientConnectorError as x:
        print("Client connector error: ", x)


if __name__ == '__main__':
    loop = asyncio.get_event_loop()
    loop.run_until_complete(main())

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

bond_api-0.1.11.tar.gz (5.4 kB view details)

Uploaded Source

Built Distribution

bond_api-0.1.11-py3-none-any.whl (6.7 kB view details)

Uploaded Python 3

File details

Details for the file bond_api-0.1.11.tar.gz.

File metadata

  • Download URL: bond_api-0.1.11.tar.gz
  • Upload date:
  • Size: 5.4 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.57.0 CPython/3.9.1

File hashes

Hashes for bond_api-0.1.11.tar.gz
Algorithm Hash digest
SHA256 0ef11db6347d7ccb0282db6d5bce7d9e77bbee273fa47f23df727a680eaac4c8
MD5 cd9dedd4c65ffb5420ad2689576b3fbd
BLAKE2b-256 b7cfd3bb60cd78232f9edacdb39a3f65cf7d285b8f820d39f556ed9ca7eaa28d

See more details on using hashes here.

File details

Details for the file bond_api-0.1.11-py3-none-any.whl.

File metadata

  • Download URL: bond_api-0.1.11-py3-none-any.whl
  • Upload date:
  • Size: 6.7 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.57.0 CPython/3.9.1

File hashes

Hashes for bond_api-0.1.11-py3-none-any.whl
Algorithm Hash digest
SHA256 236449a23f11ecf1652a8799cfe1e9db1759c0c3c74836561783f267c6ae95fa
MD5 755065b4aed3c0ec78b3e876eda99d0d
BLAKE2b-256 a9d3d04bc45de897faeebf4357cc9e8a37032559a6ed5d031710a19295187628

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