Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.

PYTBK-API

A Python API library client for TBK VMC (Ventilazione Meccanica Controllata) machines.

This library provides a simple, asynchronous interface to interact with TBK VMC devices over a local network, supporting both REST API for commands/status and WebSockets for real-time updates.

Context

TBK VMC devices use two fans to control airflow (Inflow and Outflow) and are equipped with multiple sensors (Temperature, Humidity, Pressure, IAQ). While these devices connect to TBK cloud services, they also expose a local LAN API for direct control.

Installation

Prerequisites

  • Python 3.11 or higher

Setup Virtual Environment

python -m venv .venv
source .venv/bin/activate  # On Windows: .venv\Scripts\activate
pip install -e .

For development:

pip install -e .[dev]
# Install pre-commit hooks
pre-commit install

Usage

The library uses httpx for asynchronous HTTP requests and websockets for real-time updates.

Basic Example

import asyncio
import logging
from pytbk_api.client import TbkVMCMachine
from pytbk_api.const import Speed

# Setup logging to see the library version and actions
logging.basicConfig(level=logging.INFO)

async def main():
    host = "http://192.168.1.50"
    # You can retrieve your API password from the device's menu using the on-board display
    password = "your_api_password"

    async with TbkVMCMachine(host, password) as vmc:
        # Get device info (Model, FW version, etc.)
        info = await vmc.get_info()
        print(f"Device: {info.model}, FW: {info.fw_ver}")

        # Fetch initial state
        state = await vmc.refresh_state()
        print(f"Current Speed: {state.mode.speed}")
        print(f"Temperature: {state.mode.temperatureIn_celsius}°C")

        # Send a command
        await vmc.send_command(Speed.LEVEL_3, flow_in=True, flow_out=True)

if __name__ == "__main__":
    asyncio.run(main())

Real-time Updates (WebSocket)

The library can listen for real-time updates pushed by the device:

async def on_data(data):
    print(f"Update received! New IAQ: {data.mode.iaq}")

# Initialize machine and websocket
async with TbkVMCMachine(host, password) as vmc:
    vmc.websocket._on_data = on_data
    vmc.websocket.start()
    # Keep the loop running to receive events
    await asyncio.sleep(60)

Library Architecture

Key Components

  • TbkVMCMachine: The primary entry point. Manages authentication, connection state, and coordination between REST and WebSocket clients.
  • Authenticator: Handles JWT token acquisition and automatic renewal.
  • TbkWebSocket: Manages the persistent WebSocket connection and reconnection logic.
  • Models: Pydantic models providing type-safe access to machine data, including automatic Kelvin-to-Celsius conversions.

Features

  • Asynchronous: Built on asyncio.
  • Automatic Auth: Handles login and token refreshing transparently via decorators.
  • Type Safety: Full Pydantic v2 model support.
  • Temperature Conversion: Access temperatures in both Kelvin (raw) and Celsius (processed).
  • Comprehensive Logging: Detailed internal logging for debugging, including version tracking at load time.
  • Dynamic Versioning: Versioning is automatically managed via Git tags (VCS).

Development

The project structure:

  • src/pytbk_api/: Library source code (src layout).
  • tests/: Unit tests (using pytest).
  • specs/: OpenAPI/YAML specifications for the device API.
  • example.py: A comprehensive CLI test client.

Quality Control

This project uses several tools to ensure code quality:

  • Linting & Formatting: black, isort, and mypy for type checking.
  • Git Hooks: pre-commit is used to run all checks locally before every commit.
  • CI/CD: GitHub Actions runs the full test suite across multiple Python versions and handles automated releases to PyPI.

To run tests locally:

pytest --cov=src --cov-report=term-missing

Metadata

Release files for pytbk-api 0.0.1.0b3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pytbk-api 0.0.1.0b3
File Size Uploaded Provenance Actions
pytbk_api-0.0.1.0b3.tar.gz 19.2 kB With provenance Details for pytbk_api-0.0.1.0b3.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for pytbk-api 0.0.1.0b3
File Interpreter ABI Platform Actions
pytbk_api-0.0.1.0b3-py3-none-any.whl Python 3 none any Details for pytbk_api-0.0.1.0b3-py3-none-any.whl

Total release size: 29.7 kB

Release files / pytbk_api-0.0.1.0b3.tar.gz

Download URL pytbk_api-0.0.1.0b3.tar.gz
Size 19.2 kB
Tags Source
SHA-256 checksum
How to use checksums
0fd2e78120b6eab8d0ecca3037cace127b6481301a027f2fee804bec6a716f05
BLAKE2b-256 checksum
How to use checksums
e73e8bad8dbbec15cfdfc7d67e1263903a3582c7b8b7ad3cc335f20293bf9b17
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jun 26, 2026.

Transparency log

Release files / pytbk_api-0.0.1.0b3-py3-none-any.whl

Download URL pytbk_api-0.0.1.0b3-py3-none-any.whl
Size 10.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
57fb1f532800c5e5d62248f4777c87ad76a8331fc065ec9955467bf2fe13e1e9
BLAKE2b-256 checksum
How to use checksums
c0f5975094cf23ffd28b9d90707d68b502a033f2d6341d75ea750b04226b135f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jun 26, 2026.

Transparency log

Security for pytbk-api 0.0.1.0b3

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for pytbk_api-0.0.1.0b3.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jun 26, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page