Skip to main content

Talk to the Hubspace API asynchronously

Reason this release was yanked:

light control broken

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.

https://github.com/Expl0dingBanana/aiohubspace/actions/workflows/cicd.yaml/badge.svg?branch=main https://codecov.io/github/Expl0dingBanana/aiohubspace/graph/badge.svg?token=NP2RE4I4XK

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/device.py 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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

aiohubspace-1.0.0.tar.gz (114.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

aiohubspace-1.0.0-py3-none-any.whl (39.6 kB view details)

Uploaded Python 3

File details

Details for the file aiohubspace-1.0.0.tar.gz.

File metadata

  • Download URL: aiohubspace-1.0.0.tar.gz
  • Upload date:
  • Size: 114.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.8

File hashes

Hashes for aiohubspace-1.0.0.tar.gz
Algorithm Hash digest
SHA256 0b7ba64352294da4e532cb5f239231b4c3849e2b4790e2dabbc78aeb53b3bb77
MD5 f7846f5bd161c5c8222c5e629d1c97db
BLAKE2b-256 ec66c90c52467781a73e57e25f6af2b0cface040b754ef67e991b2710f468944

See more details on using hashes here.

Provenance

The following attestation bundles were made for aiohubspace-1.0.0.tar.gz:

Publisher: release.yaml on Expl0dingBanana/aiohubspace

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file aiohubspace-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: aiohubspace-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 39.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.8

File hashes

Hashes for aiohubspace-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 3f3a40f3a5d6546e65ff400ed2a43633cf6c7a1896bf524489cc649572188b69
MD5 9cbb44e59bc1dbc96a767dde9eeec6a2
BLAKE2b-256 84307c0564de133ef36b0b44c5cff0a9c990a369f6c23623e1d2830f2bcad259

See more details on using hashes here.

Provenance

The following attestation bundles were made for aiohubspace-1.0.0-py3-none-any.whl:

Publisher: release.yaml on Expl0dingBanana/aiohubspace

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page