Talk to the HubSpace API asynchronously
Reason this release was yanked:
Bad code
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.4-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4957faece46b6efbe8da3129159c6ec3d3f0969536d55d5da9c8a7d51a2acff1 |
|
MD5 | 1540694fcc44aea0188e14dc2ead9035 |
|
BLAKE2b-256 | 35d435ffe425f327fe2586e8cede9284c742f3ef9b7e0a735e6dd6905c4dd3ec |