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 connectedTapHomeHub. RaisesTapHomeAuthErrorfor a rejected token andTapHomeConnectionErrorwhen the hub cannot be reached. Theaiohttp.ClientSessionis owned by the caller and never closed by the SDK.hub.devicesmaps device ids to typed devices (RGBLightDevice,ThermostatDevice,BidirectionalDevice, …) created byDeviceFactoryfrom the value types each device supports.device.stateis anObservableValue; subscribe tostate.changedto 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
- Bump
versioninpyproject.tomland updateCHANGELOG.md. - Create a GitHub release with tag
v<version>(e.g.v1.0.0). - The
Release to PyPIworkflow builds and publishes the package via trusted publishing — no API tokens are stored in the repository.
License
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 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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6e48e0d4067efcf86f8c91afd92371692c3a9b0b9087f28e78263ca5e9e566a9
|
|
| MD5 |
5d08986622cf7eac0409686f3a5b640f
|
|
| BLAKE2b-256 |
c96fee1df567329151334b89d8ebf66f5b636b4caf6ecd0993fa5b71275a951e
|
Provenance
The following attestation bundles were made for taphome_sdk-1.0.0.tar.gz:
Publisher:
release.yml on martindybal/taphome-sdk
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
taphome_sdk-1.0.0.tar.gz -
Subject digest:
6e48e0d4067efcf86f8c91afd92371692c3a9b0b9087f28e78263ca5e9e566a9 - Sigstore transparency entry: 2089471100
- Sigstore integration time:
-
Permalink:
martindybal/taphome-sdk@d304e4387943f5b92ebfeb4142cfb4da2861483c -
Branch / Tag:
refs/tags/v1.0.0-pre - Owner: https://github.com/martindybal
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@d304e4387943f5b92ebfeb4142cfb4da2861483c -
Trigger Event:
release
-
Statement type:
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
134e6bbfa4936a0afa4bd892a5b887e79207cba18ec589b1cc67c23d6dba51ca
|
|
| MD5 |
1fdb16af51f26dbe2062187f3ef7d31c
|
|
| BLAKE2b-256 |
970c225abf5f31d0cddec24dbc6a022f70eaf1db6b2405f95f1f47551a8ccb8c
|
Provenance
The following attestation bundles were made for taphome_sdk-1.0.0-py3-none-any.whl:
Publisher:
release.yml on martindybal/taphome-sdk
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
taphome_sdk-1.0.0-py3-none-any.whl -
Subject digest:
134e6bbfa4936a0afa4bd892a5b887e79207cba18ec589b1cc67c23d6dba51ca - Sigstore transparency entry: 2089471298
- Sigstore integration time:
-
Permalink:
martindybal/taphome-sdk@d304e4387943f5b92ebfeb4142cfb4da2861483c -
Branch / Tag:
refs/tags/v1.0.0-pre - Owner: https://github.com/martindybal
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@d304e4387943f5b92ebfeb4142cfb4da2861483c -
Trigger Event:
release
-
Statement type: