Talk to the HubSpace API asynchronously
Project description
_hs_api_default:
hubspace-async
Creates a session to HubSpace and handles authentication
This project was designed to asynchronously connect to the HubSpace API and retrieve data. The implementation was based on jdeath/Hubspace-Homeassistant but converted to async and cleaned up.
Examples
These examples provide sample usage when running from the python shell. If the code is running within an async loop, gathering the loop and telling it to run is not required.
Gather all devices from the API
from hubspace_async import connection
import asyncio
conn = connection.HubSpaceConnection("username", "password")
loop.run_until_complete(conn.populate_data())
A sample output would look like
[{"id": "blah1"}, {"id": "blah2"}]
After running this code, the following attributes will be populated:
homes: Dictionary of all homes from the API response
rooms: Dictionary of all rooms from the API response
devices: Dictionary of all devices from the API response
Updating a devices state
In this example we will turn a light on. The request requires the use of functionInstance for it to work. However some updates may not require this field.
from hubspace_async import connection, HubSpaceState
import asyncio
conn = connection.HubSpaceConnection("username", "password")
state = HubSpaceState(
functionClass="power",
functionInstance="light-power",
value="on",
)
child_id = "abc123"
loop.run_until_complete(conn.set_device_state(child_id, new_states))
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
Built Distribution
Hashes for hubspace_async-0.0.6-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9bbbeaf59742a3808e0278d38c3e1622b9e1d012c998167a8491bda30e4e2b6e |
|
MD5 | 15042e25b44d21e421a1c1bf14ce4e15 |
|
BLAKE2b-256 | 54e3fcf738ab0f7e118bbadbf4c758deea78a808bb1a7097019a7a37f5a7b985 |