Skip to main content

Async Python client for the TapHome smart home API

Project description

taphome-sdk

Async Python client for the TapHome smart home API. Originally developed for the TapHome Home Assistant integration, usable from any asyncio application.

Installation

pip install taphome-sdk

Usage

import asyncio

import aiohttp

from taphome_sdk import TapHomeHubFactory


async def main() -> None:
    async with aiohttp.ClientSession() as session:
        hub = await TapHomeHubFactory.async_connect(
            "http://192.168.1.10/api/TapHomeApi/v1",  # or https://api.taphome.com/api/TapHomeApi/v1
            "your-api-token",
            session,
        )
        try:
            for device in hub.devices.values():
                print(device.id, device.name, type(device).__name__)
        finally:
            hub.disconnect()


asyncio.run(main())

Key concepts:

  • TapHomeHubFactory.async_connect(api_url, token, session) discovers all devices exposed in the TapHome API and returns a connected TapHomeHub. Raises TapHomeAuthError for a rejected token and TapHomeConnectionError when the hub cannot be reached. The aiohttp.ClientSession is owned by the caller and never closed by the SDK.
  • hub.devices maps device ids to typed devices (RGBLightDevice, ThermostatDevice, BidirectionalDevice, …) created by DeviceFactory from the value types each device supports.
  • device.state is an ObservableValue; subscribe to state.changed to get push updates. The hub also polls periodically as a fallback.
  • hub.async_handle_webhook(payload) feeds a parsed webhook JSON body into the hub for instant push updates.
  • hub.disconnect() stops the periodic refresh task.

Development

pip install -e . pytest pytest-asyncio ruff mypy
pytest
ruff check .
mypy

Releasing

  1. Bump version in pyproject.toml and update CHANGELOG.md.
  2. Create a GitHub release with tag v<version> (e.g. v1.0.0).
  3. The Release to PyPI workflow builds and publishes the package via trusted publishing — no API tokens are stored in the repository.

License

GPL-3.0-or-later.

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

taphome_sdk-1.0.0.tar.gz (32.2 kB view details)

Uploaded Source

Built Distribution

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

taphome_sdk-1.0.0-py3-none-any.whl (37.5 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for taphome_sdk-1.0.0.tar.gz
Algorithm Hash digest
SHA256 6e48e0d4067efcf86f8c91afd92371692c3a9b0b9087f28e78263ca5e9e566a9
MD5 5d08986622cf7eac0409686f3a5b640f
BLAKE2b-256 c96fee1df567329151334b89d8ebf66f5b636b4caf6ecd0993fa5b71275a951e

See more details on using hashes here.

Provenance

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

Publisher: release.yml on martindybal/taphome-sdk

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

File details

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

File metadata

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

File hashes

Hashes for taphome_sdk-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 134e6bbfa4936a0afa4bd892a5b887e79207cba18ec589b1cc67c23d6dba51ca
MD5 1fdb16af51f26dbe2062187f3ef7d31c
BLAKE2b-256 970c225abf5f31d0cddec24dbc6a022f70eaf1db6b2405f95f1f47551a8ccb8c

See more details on using hashes here.

Provenance

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

Publisher: release.yml on martindybal/taphome-sdk

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