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
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
bond_api-0.1.10.tar.gz
(5.3 kB
view details)
Built Distribution
File details
Details for the file bond_api-0.1.10.tar.gz
.
File metadata
- Download URL: bond_api-0.1.10.tar.gz
- Upload date:
- Size: 5.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.57.0 CPython/3.9.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | a3083dc5a5cdb8dff981542aa0e0a277ed8d524781234f06bdacc7f3589e0125 |
|
MD5 | 2ad35fc4deb31fc37b4964f9c53b9d27 |
|
BLAKE2b-256 | 52f634c64701c3bb9630aea215aeaca5ce5cd961685df00d4081fe0e25debd6d |
File details
Details for the file bond_api-0.1.10-py3-none-any.whl
.
File metadata
- Download URL: bond_api-0.1.10-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
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5b22a05b013d076ecf493011d50b741abd0aaad629ef094b8abaa418e38f8ad4 |
|
MD5 | 135b08d5c46b47865404e050ebdb23a2 |
|
BLAKE2b-256 | ca09683b2a65053b08a80ac408d3e4aaf1c58e4e90e6ffe47786fab0b1db81f1 |