Talk to the Hubspace API asynchronously
Project description
Connects to Hubspace API and provides an easy way to interact with devices.
This project was designed to asynchronously connect to the Hubspace API. It has the ability to retrieve the devices and set new states. It was updated from hubspace_async and merged with concepts from aiohue.
Overview
All data is stored within a “bridge” that knows of all of the devices aligned with the Hubspace account. This bridge contains multiple controllers for each device type. These controllers know how to interact with the Hubspace devices. Each controller manages the device’s states. To retrieve a device, you must query bridge.<controller>.get_device(<hubspace_id>) which will return a model containing all the states. Any changes to the model will not update Hubspace as the correct call needs to be made.
Controllers
The following controllers are implemented:
- bridge.devices: Top-level devices (such as a ceiling-fan, or light that
is not associated with another device). These entities also contain their respective sensors and binary sensors. This is purely an informational controller and cannot set any states.
bridge.fans: Any device that matches a fan. Can perform the following actions:
turn_on
turn_off
set_speed
set_direction
set_preset
bridge.lights: Any device that matches a fan. Can perform the following actions:
turn_on
turn_off
set_color_temperature
set_brightness
set_rgb
set_effect
bridge.locks: Any device that matches a lock. Can perform the following actions:
lock
unlock
bridge.switches: Any device that matches a switch. Can perform the following actions:
turn_on
turn_off
bridge.valves: Any device that matches a valves. Can perform the following actions:
turn_on
turn_off
Example Usage
All examples assume you entered the shell with python -m asyncio
from aiohubspace import v1
import logging
logging.getLogger("aiohubspace").setLevel(logging.DEBUG)
USERNAME="" # Hubspace username
PASSWORD="" # Hubspace password
POLLING_INTERVAL=30 # Number of seconds between polling cycles
# Create the bridge
bridge = v1.HubspaceBridgeV1(USERNAME, PASSWORD, polling_interval=POLLING_INTERVAL)
# Query the API and populate the controllers
await bridge.initialize()
# Turn on the light that matches id="84338ebe-7ddf-4bfa-9753-3ee8cdcc8da6"
await conn.lights.turn_off("84338ebe-7ddf-4bfa-9753-3ee8cdcc8da6")
Troubleshooting
Hubspace Device shows incorrect model
Hubspace does not always report all the pertinent information through the API. To resolve this, open a PR to src/aiohubspace/v1/device and update the dataclass HubspaceDevice.__post_init__ function to correctly identify the device.
Hubspace is slow to update
The API rate-limits request. If other things are hitting the API (such as the phone app or Home Assistant), you may need to stop using one to ensure a better connection.
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
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file aiohubspace-0.6.4.tar.gz.
File metadata
- Download URL: aiohubspace-0.6.4.tar.gz
- Upload date:
- Size: 102.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.0.1 CPython/3.12.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c57ea24b02879287882420e6fb25a3f433db1fb03cbbb79d0ad1da5a4a1cc270
|
|
| MD5 |
c04a534214be27771c1431a62001d1a1
|
|
| BLAKE2b-256 |
15ab556e5df26d5dc8664bb7970f70e661559419a9f4d3f82653f02cf431997a
|
Provenance
The following attestation bundles were made for aiohubspace-0.6.4.tar.gz:
Publisher:
release.yaml on Expl0dingBanana/aiohubspace
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
aiohubspace-0.6.4.tar.gz -
Subject digest:
c57ea24b02879287882420e6fb25a3f433db1fb03cbbb79d0ad1da5a4a1cc270 - Sigstore transparency entry: 162577275
- Sigstore integration time:
-
Permalink:
Expl0dingBanana/aiohubspace@aec909711b87c234dfb20e690e0f14b43415192e -
Branch / Tag:
refs/heads/main - Owner: https://github.com/Expl0dingBanana
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yaml@aec909711b87c234dfb20e690e0f14b43415192e -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file aiohubspace-0.6.4-py3-none-any.whl.
File metadata
- Download URL: aiohubspace-0.6.4-py3-none-any.whl
- Upload date:
- Size: 37.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.0.1 CPython/3.12.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
29f62aa9d9d62d2e15f9bc0073203c024c145fbffa1207373c31376216786e66
|
|
| MD5 |
81679a9829041db7a474366bee29e7cb
|
|
| BLAKE2b-256 |
539c2a55159e042b27d785dc6371dae6f41ed1b42035956dacddd12b62c6e934
|
Provenance
The following attestation bundles were made for aiohubspace-0.6.4-py3-none-any.whl:
Publisher:
release.yaml on Expl0dingBanana/aiohubspace
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
aiohubspace-0.6.4-py3-none-any.whl -
Subject digest:
29f62aa9d9d62d2e15f9bc0073203c024c145fbffa1207373c31376216786e66 - Sigstore transparency entry: 162577277
- Sigstore integration time:
-
Permalink:
Expl0dingBanana/aiohubspace@aec909711b87c234dfb20e690e0f14b43415192e -
Branch / Tag:
refs/heads/main - Owner: https://github.com/Expl0dingBanana
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yaml@aec909711b87c234dfb20e690e0f14b43415192e -
Trigger Event:
workflow_dispatch
-
Statement type: