Skip to main content

bond-async

Asynchronous Python wrapper library over Bond Local API

Forked from https://github.com/prystupa/bond-api Thanks @prystupa for the great work!

Installation

From PyPi:

pip3 install bond-async

Library Usage

import asyncio

from aiohttp import ClientResponseError, ClientConnectorError

from bond_async 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())

Metadata

Release files for bond-async 0.2.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for bond-async 0.2.1
File Size Uploaded
bond_async-0.2.1.tar.gz 9.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for bond-async 0.2.1
File Interpreter ABI Platform
bond_async-0.2.1-py3-none-any.whl Python 3 none any Details

Total release size: 20.2 kB

Release files / bond_async-0.2.1.tar.gz

Download URL bond_async-0.2.1.tar.gz
Size 9.6 kB
Tags Source
SHA-256 checksum
How to use checksums
8ad2452d3d69b5db444de33035629ea4804675150050060197945e765f4e4251
BLAKE2b-256 checksum
How to use checksums
88b88f687aef0f5ccf1ef9d5fe84b6b7cc9f30b3656b4182c84fc22d737b48d4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.4

Release files / bond_async-0.2.1-py3-none-any.whl

Download URL bond_async-0.2.1-py3-none-any.whl
Size 10.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
ea59b0dece1c56a9b5d8f3e8908b01eba8a091bac4a8fa744bb53e170907e514
BLAKE2b-256 checksum
How to use checksums
7983c796dbe88d79efb7d93b85d05c269094b02e94b2f329c6d7362a793eab6f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.4

Release history Release notifications | RSS feed

This release

0.2.1 This release

2 release files

0.2.0

2 release files

0.1.23

2 release files

0.1.22

2 release files

0.1.21

2 release files

0.1.20

2 release files

0.1.19

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page