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.6.tar.gz
(4.5 kB
view details)
Built Distribution
File details
Details for the file bond_api-0.1.6.tar.gz
.
File metadata
- Download URL: bond_api-0.1.6.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 | 26d7243e2b801e91b4724d4742d59559e996c3108e24dafd12980bf480c94660 |
|
MD5 | f0ff95dbf40b9fd09e86e245c65d8b99 |
|
BLAKE2b-256 | b5f3984557cf381506e92932d2e6980056d947731994bf5fe369332e4e2d4d03 |
File details
Details for the file bond_api-0.1.6-py3-none-any.whl
.
File metadata
- Download URL: bond_api-0.1.6-py3-none-any.whl
- Upload date:
- Size: 5.7 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 | 45864cfaaeeb42f3b74e2d7ae9628d7362654ab6edc70103e5c109b9f9d8f212 |
|
MD5 | 41b6a3343b4c3842ba9920ce6490402b |
|
BLAKE2b-256 | 56c9156b5687a3486afcbd7d5b64fbb6bd007f07f93ad3ce58ffea1e04ef699a |