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.4.tar.gz
(3.5 kB
view details)
Built Distribution
File details
Details for the file bond_api-0.1.4.tar.gz
.
File metadata
- Download URL: bond_api-0.1.4.tar.gz
- Upload date:
- Size: 3.5 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
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8f2f18d19bf5874d57156504ce2ecfac63c0fd5be73ec4ac9468952ae25fc742 |
|
MD5 | 4660c9cf189fe6ce09d5c12efafc39e0 |
|
BLAKE2b-256 | ca3a6cf5cc91b919f90392be5f7b05f98c91737d183de5e4b13df374040402f1 |
File details
Details for the file bond_api-0.1.4-py3-none-any.whl
.
File metadata
- Download URL: bond_api-0.1.4-py3-none-any.whl
- Upload date:
- Size: 5.0 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
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1b4838529878d13f0e4d6e527b6d6a55f1df99a4949e85f846db69f4ce963bcb |
|
MD5 | 9617785f627ebb3c4d012e95f82c38b5 |
|
BLAKE2b-256 | f17ca8614a5ddca3935327ea40a510be036165ea004d278dd9cb19177234e3d2 |