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.7.tar.gz
(4.5 kB
view details)
Built Distribution
File details
Details for the file bond_api-0.1.7.tar.gz
.
File metadata
- Download URL: bond_api-0.1.7.tar.gz
- Upload date:
- Size: 4.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.48.0 CPython/3.8.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | a229b17d48fb6018801437c7bcc953ceb0a68f1d24febc614bf75ca24d525ee6 |
|
MD5 | a158ca671e5d479abae05d343e7578cd |
|
BLAKE2b-256 | a0d9ce3d508874db292fae8e84e169d3257d0848de41d82ac1ca03cd00322212 |
File details
Details for the file bond_api-0.1.7-py3-none-any.whl
.
File metadata
- Download URL: bond_api-0.1.7-py3-none-any.whl
- Upload date:
- Size: 5.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.48.0 CPython/3.8.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | bb32ffa95d6041e66489e0706b6129d8ca9f448846215b9e066f46c43a6ec007 |
|
MD5 | be21e3637cd12185c726cf4be5723fc7 |
|
BLAKE2b-256 | 39e8aee3d831ed3db2a5968b2fc254cd31efdffba302c209dff56f05597ad42f |