Skip to main content

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

Contributing

See CONTRIBUTING.md.

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

thermocktat_client-0.2.0.tar.gz (4.3 kB view details)

Uploaded Source

Built Distribution

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

thermocktat_client-0.2.0-py3-none-any.whl (7.0 kB view details)

Uploaded Python 3

File details

Details for the file thermocktat_client-0.2.0.tar.gz.

File metadata

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

File hashes

Hashes for thermocktat_client-0.2.0.tar.gz
Algorithm Hash digest
SHA256 74bbd7987f8a0d6c1b350ab28f15a26364758d362e2ba96261a3651db55dc514
MD5 50702c0f9dd350132ef8cac13f03c401
BLAKE2b-256 ce2231fdffa44fec0acf2dd437cf59e64986fcbf8d9582f81f9617a67a91e9c5

See more details on using hashes here.

Provenance

The following attestation bundles were made for thermocktat_client-0.2.0.tar.gz:

Publisher: release-python-client.yaml on Agrid-Dev/thermocktat

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

File details

Details for the file thermocktat_client-0.2.0-py3-none-any.whl.

File metadata

File hashes

Hashes for thermocktat_client-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f66581aede497a8653499547cb88d641c210a0d862eec3b5c40badaacc4e9e65
MD5 9d93ca93d8d6b8d1886e2d6e7c356af8
BLAKE2b-256 b3cc43ef58a5931df6d89066364286fe2af1ab1ea08f040a8af66c9049672aaf

See more details on using hashes here.

Provenance

The following attestation bundles were made for thermocktat_client-0.2.0-py3-none-any.whl:

Publisher: release-python-client.yaml on Agrid-Dev/thermocktat

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