A python client for the Thermocktat, a lightweight, multi-protocol thermostat emulator.
Project description
Thermocktat client
A http client for thermocktat.
Thermocktat = mock + thermostat
It emulates a thermostat device with realistic controls and temperature simulation, and supports many control protocols (http, mqtt, modbus, bacnet, knx...).
It is primarily design to test and demo Building Management Systems (BMS) software.
This lib is a lightweight wrapper around its http API.
See the source repo for details.
Installation
uv add thermocktat-client # or: pip install thermocktat-client
Usage
Sync
from thermocktat_client import ThermocktatSync
with ThermocktatSync.connect("http://localhost:8080") as tmk:
print(tmk.snapshot.temperature_setpoint)
tmk.set_temperature_setpoint(23.5)
tmk.set_mode("cool")
print(tmk.snapshot.mode)
Async
import asyncio
from thermocktat_client import ThermocktatAsync
async def main():
async with await ThermocktatAsync.connect("http://localhost:8080") as tmk:
print(tmk.snapshot.temperature_setpoint)
await tmk.set_temperature_setpoint(23.5)
await tmk.set_mode("cool")
asyncio.run(main())
Pure construction (no network on init)
__init__ is side-effect-free. Call .sync() (or use .connect(...), which combines construct + sync) before reading .snapshot, otherwise properties raise NotSyncedError.
tmk = ThermocktatSync("http://localhost:8080")
tmk.sync()
print(tmk.snapshot)
Injecting a custom httpx client
Useful for auth, retries, or sharing a connection pool. The client is the caller's to close.
from httpx import Client
from thermocktat_client import ThermocktatSync
external = Client(headers={"Authorization": "Bearer ..."})
tmk = ThermocktatSync.connect("http://...", client=external)
# external.close() when you're done
Development
This project uses uv for dependency management.
Setup
uv sync
Quality checks
uv run ruff check . # lint
uv run ruff format --check . # format check
uv run pyright # type check
uv run pytest --cov=thermocktat_client # tests with coverage
Pre-commit hooks
We use prek (a Rust-based drop-in replacement for pre-commit) to run lint, format and type-check on commit.
Install the git hook once:
prek install
Run the hooks manually against all files:
prek run --all-files
Hooks are defined in .pre-commit-config.yaml.
Releasing
Releases are published to PyPI by .github/workflows/release-python-client.yaml when a python-client/vX.Y.Z tag is pushed. The workflow promotes the wheel built by CI on the tagged commit (build-once, promote pattern) and verifies that the wheel version matches the tag — so pyproject.toml and the tag must agree.
Versioning follows semver. While in 0.x, MINOR bumps may include breaking changes.
Steps
-
Open a PR bumping
versioninclients/python/pyproject.tomltoX.Y.Z. -
Merge to
main. CI runs and uploads thethermocktat-client-distartifact for the merge commit. -
Tag the merge commit and push:
git checkout main && git pull git tag python-client/vX.Y.Z git push origin python-client/vX.Y.Z
-
The release workflow runs automatically: finds the CI artifact, verifies version match, publishes to PyPI, creates a GitHub Release.
If the version-match step fails, you tagged a commit whose pyproject.toml doesn't match the tag — delete the tag (git push --delete origin python-client/vX.Y.Z), fix the version, and retry.
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 thermocktat_client-0.1.0.tar.gz.
File metadata
- Download URL: thermocktat_client-0.1.0.tar.gz
- Upload date:
- Size: 5.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ebb3795cb23baf00d9b50230e126cf041d9e1116560c401b2a34ab61aa4cbf30
|
|
| MD5 |
2e41936f73d296ecde00c95371d259ed
|
|
| BLAKE2b-256 |
9f636ea124db26a2a594b81a4fa6fec1e06e6953c1560084d60df074e8d6376f
|
Provenance
The following attestation bundles were made for thermocktat_client-0.1.0.tar.gz:
Publisher:
release-python-client.yaml on Agrid-Dev/thermocktat
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
thermocktat_client-0.1.0.tar.gz -
Subject digest:
ebb3795cb23baf00d9b50230e126cf041d9e1116560c401b2a34ab61aa4cbf30 - Sigstore transparency entry: 1309512998
- Sigstore integration time:
-
Permalink:
Agrid-Dev/thermocktat@8ed707ccdec8937e7c906ba45e4c0c3195ec3b4b -
Branch / Tag:
refs/tags/python-client/v0.1.0 - Owner: https://github.com/Agrid-Dev
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release-python-client.yaml@8ed707ccdec8937e7c906ba45e4c0c3195ec3b4b -
Trigger Event:
push
-
Statement type:
File details
Details for the file thermocktat_client-0.1.0-py3-none-any.whl.
File metadata
- Download URL: thermocktat_client-0.1.0-py3-none-any.whl
- Upload date:
- Size: 7.7 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 |
b1086d28953bb1ca42398c75fd42d3f4fdd6876acddbd1d2b505a3b14b2aced1
|
|
| MD5 |
6597b6b216f16e81b8fdb0fc5c924721
|
|
| BLAKE2b-256 |
09259feeffa98df759912d924fa4ee3565635d7cd229f5dbf93ba3526c0329ce
|
Provenance
The following attestation bundles were made for thermocktat_client-0.1.0-py3-none-any.whl:
Publisher:
release-python-client.yaml on Agrid-Dev/thermocktat
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
thermocktat_client-0.1.0-py3-none-any.whl -
Subject digest:
b1086d28953bb1ca42398c75fd42d3f4fdd6876acddbd1d2b505a3b14b2aced1 - Sigstore transparency entry: 1309513190
- Sigstore integration time:
-
Permalink:
Agrid-Dev/thermocktat@8ed707ccdec8937e7c906ba45e4c0c3195ec3b4b -
Branch / Tag:
refs/tags/python-client/v0.1.0 - Owner: https://github.com/Agrid-Dev
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release-python-client.yaml@8ed707ccdec8937e7c906ba45e4c0c3195ec3b4b -
Trigger Event:
push
-
Statement type: