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

Uploaded Source

Built Distribution

bond_api-0.1.0-py3-none-any.whl (4.5 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: bond_api-0.1.0.tar.gz
  • Upload date:
  • Size: 3.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.0.0 requests-toolbelt/0.9.1 tqdm/4.48.0 CPython/3.7.7

File hashes

Hashes for bond_api-0.1.0.tar.gz
Algorithm Hash digest
SHA256 8b1830ac3bf2f2936164b346c3635ff7f561d6700ba88a88f5c5bcc87b82dee9
MD5 fcb96579eca5f800d06286464b6a6e0f
BLAKE2b-256 f8bacf0d3593293ca7d7f8b33bffa012e784ab11ff4d742e1396428fd253acc0

See more details on using hashes here.

File details

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

File metadata

  • Download URL: bond_api-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 4.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.0.0 requests-toolbelt/0.9.1 tqdm/4.48.0 CPython/3.7.7

File hashes

Hashes for bond_api-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 b1682a8f51035a9bd40177c24a09d6b9000dcce38522c11c062605b7226cec81
MD5 34fd8d157efc518aab42c5166a66fd34
BLAKE2b-256 dacf2435a83e034911b5e7d94f484094b5d11a5d9e53e52bd05daeace0075885

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