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
import logging
import hubspace_async
import asyncio
# TRACE messages in logs
hubspace_async.logger.setLevel(logging.HS_TRACE)
hubspace_async.logger.addHandler(logging.StreamHandler())
try:
loop = asyncio.get_event_loop()
except RunTimeError:
loop = asyncio.new_event_loop()
username = "<username>"
password = "<password>
async def get_devices(username, password):
connection = hubspace_async.HubSpaceConnection(username, password)
return await connection.devices
loop.run_until_complete(get_devices(username, password))
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))
CLI Commands
A CLI is provided for testing your credentials and connection to hubspace. For all commands, click needs to be installed. The easiest way to install click is by using the cli extras.
pip install hubspace-async[cli]
Testing Auth
To test auth, run the following command: python -m hubspace_async.cli --username "<username>" --password "<password>" auth-flow
If successful, the message “Token has been successfully generated” will be displayed.
Testing Connectivity
To test connectivity, run the following command: python -m hubspace_async.cli --username "<username>" --password "<password>" auth-flow
If successful, an account id with several hyphens will appear.
Metadata
Release files for hubspace-async 0.4.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| hubspace_async-0.4.1.tar.gz | 30.4 kB | Without provenance | Details for hubspace_async-0.4.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| hubspace_async-0.4.1-py3-none-any.whl | Python 3 | none | any | Details for hubspace_async-0.4.1-py3-none-any.whl |
Total release size: 44.3 kB
Release files / hubspace_async-0.4.1.tar.gz
| Download URL | hubspace_async-0.4.1.tar.gz |
|---|---|
| Size | 30.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
37f38b691ae8200c48b9b9757dc069e55d24c1045b3cb4f5e24ad4f6bd744a59
|
|
BLAKE2b-256 checksum How to use checksums |
6a2054ddb8c8a893a4215cf066e289fc1f274f94b14a1331d01cc6f741bd93c2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.12.4
|
Release files / hubspace_async-0.4.1-py3-none-any.whl
| Download URL | hubspace_async-0.4.1-py3-none-any.whl |
|---|---|
| Size | 13.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
90138147157d6b766c8ab75c9d05d5c15b82faf528bb782f0a9cb4e8c1ca069d
|
|
BLAKE2b-256 checksum How to use checksums |
18bdc9c5574d6bd8ad2ea0aa754b9aac00851fe961de2b2dfdace53e7fc62f05
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.12.4
|
Security for hubspace-async 0.4.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.