Skip to main content

Viessmann API Python Client

A Python library for accessing the Viessmann Climate Solutions API. Designed for integration with Home Assistant and other async Python applications.

Features

  • Asynchronous: Built on aiohttp and asyncio.
  • OAuth2 Authentication: Handles token retrieval and automatic renewal.
  • Auto-Discovery: Automatically finds installations, gateways, and devices.
  • Recursive Feature Flattening: Converts complex nested API responses into a simple, flat list of features (e.g., heating.circuits.0.heating.curve.shift).
  • Gateway-Scoped Refresh: Refreshes multiple known devices with one normal-case request while preserving partial successes.
  • Command Execution: Supports safe single-feature writes with automatic parameter resolution and explicit multi-parameter commands.
  • Fixture-backed Client: Runs the same client workflows against bundled real-device responses without authentication, sessions, or network requests.
  • Strictly Typed: Ships as a PEP 561 complete package with py.typed; the shipped code passes strict Pyright and dynamic values follow a typed JSON value contract.

Public API

Import consumer-facing symbols from vi_api_client:

from vi_api_client import (
    AbstractAuth,
    DEFAULT_SCOPES,
    Device,
    ENDPOINT_AUTHORIZE,
    ENDPOINT_TOKEN,
    EventHistoryPage,
    EventHistoryWindow,
    Feature,
    FeatureConstraints,
    FeatureDeprecation,
    FeatureValue,
    Gateway,
    GatewayDeviceRefreshResult,
    Installation,
    InstallationEvent,
    JsonValue,
    FixtureViClient,
    OAuth,
    ScheduleConstraints,
    ValidationDetail,
    ViAuthError,
    ViClient,
    ViCommandRejectedError,
    ViConnectionError,
    ViDeviceCommunicationError,
    ViError,
    ViNotFoundError,
    ViRateLimitError,
    ViResponseError,
    ViServerInternalError,
    ViValidationError,
    format_feature,
    redact_device,
    redact_feature,
    redact_sensitive,
    validate_json_value,
)

DEFAULT_SCOPES, ENDPOINT_AUTHORIZE, and ENDPOINT_TOKEN support external OAuth integrations. JsonValue, FeatureValue, ValidationDetail, and validate_json_value form the public recursive JSON value contract that dynamic feature values and API validation details follow. redact_sensitive, redact_feature, and redact_device redact secrets, address data, identifiers, and coordinates in log text, API documents, and model objects. CLI helpers, transport details, persistence, and parsing remain available from their dedicated modules.

Installation

Requires Python 3.14+. Install the released package from PyPI:

python3.14 -m venv .venv
source .venv/bin/activate
pip install vi_api_client

To work on the library itself, install it from a clone in editable mode:

git clone https://github.com/ignazhabibi/vi_api_client.git
cd vi_api_client
pip install -e .

Development and Tests

Install the development dependencies with the CI constraints to reproduce the tested HTTP client and mock combination locally:

python -m pip install -c constraints-ci.txt '.[dev]'
pre-commit install
ruff check .
ruff format --check .
pyright --pythonpath python
pyright --project pyrightconfig.strict.json
python -m pytest -q
python scripts/check_coverage.py
python -m build
python scripts/verify_distributions.py

The shipped package is strictly typed and PEP 561 complete: the strict Pyright pass covers src/vi_api_client, the built wheel and source distribution ship py.typed, and the installed wheel passes pyright --verifytypes vi_api_client --ignoreexternal. Tests remain under standard type checking. The suite must keep at least 95% line and branch coverage over src/vi_api_client; scripts/check_coverage.py enforces both thresholds in the quality gate.

Quick Start

CLI

The vi-client tool is the easiest way to explore the API.

# 1. Login
vi-client login --client-id <YOUR_CLIENT_ID>

# 2. List Devices
vi-client list-devices

# 3. List only available Features with values (auto-detects first device)
vi-client list-features --available --values

# 4. List Writable Features (Settings)
vi-client list-writable

# 5. List the complete installation event history (last 7 days)
vi-client list-events --days 7

# All commands with examples, or the options of one command
vi-client --help
vi-client set --help

See CLI Reference for more details.

Python Code

The example reads tokens from tokens.json. Create that file once with vi-client login, or log in from Python as shown in the Authentication reference.

import asyncio
import aiohttp
from vi_api_client import OAuth, ViClient, ViCommandRejectedError


async def main():
    async with aiohttp.ClientSession() as session:
        # Initialize Auth (tokens saved to tokens.json)
        auth = OAuth(
            client_id="YOUR_CLIENT_ID",
            redirect_uri="http://localhost:4200/",
            token_file="tokens.json",
            websession=session,
        )

        client = ViClient(auth)

        # 1. Get Installations & Gateways
        installations = await client.get_installations()
        if not installations:
            return
        installation = installations[0]

        gateways = await client.get_gateways()
        gateway = next(
            (
                gateway
                for gateway in gateways
                if gateway.installation_id == installation.id
            ),
            None,
        )
        if gateway is None:
            return

        # 2. Discover and refresh devices behind one gateway
        devices = await client.get_devices(installation.id, gateway.serial)
        refresh = await client.refresh_gateway_devices(devices)
        for device_id, error in refresh.errors_by_device_id.items():
            print(f"Device {device_id} could not be refreshed: {error}")
        if not refresh.refreshed_devices:
            return
        device = refresh.refreshed_devices[0]
        print(f"Device: {device.model_id} ({device.status})")

        # 3. Iterate Features (Flat List)
        for feature in device.features:
            print(f"{feature.name}: {feature.value}")

        # 4. Write one Feature with automatic dependency resolution
        # Find a feature that can be set right now (e.g. heating curve slope)
        slope = next(
            (f for f in device.features if "curve.slope" in f.name and f.is_settable),
            None,
        )
        if slope:
            print("Setting slope to 1.4...")
            try:
                # Use the returned device for subsequent calls.
                device = await client.set_feature(device, slope, 1.4)
            except ViCommandRejectedError as error:
                print(f"The device rejected the write: {error}")
            else:
                print("✅ Success! Device updated.")

        # 5. Run any command an API feature reports
        holiday = "heating.operating.programs.holiday"
        if "schedule" in device.get_command_names(holiday):
            try:
                await client.run_command(
                    device,
                    holiday,
                    "schedule",
                    {"start": "2026-12-24", "end": "2026-12-31"},
                )
            except ViCommandRejectedError as error:
                print(f"The device rejected the command: {error}")


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

Documentation

The detailed documentation is available in the docs/ directory:

  1. Getting Started: Installation and First Steps.
  2. API Structure & Concepts: Understanding the Flat Architecture.
  3. Authentication & Connection: Tokens, Sessions, and Thread-Safety.
  4. Models Reference: Devices, Features, and Constraints.
  5. Client Reference: The ViClient class methods.
  6. CLI Reference: Using the command line interface.
  7. Exceptions Reference: Handling errors.
  8. Architecture Guide: System structure, responsibilities, data flows, and diagrams explained for developers and non-specialists.

Metadata

Release files for vi-api-client 7.1.0

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

Source distribution (sdist)

Source distribution for vi-api-client 7.1.0
File Size Uploaded Provenance Actions
vi_api_client-7.1.0.tar.gz 173.0 kB With provenance Details for vi_api_client-7.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for vi-api-client 7.1.0
File Interpreter ABI Platform Actions
vi_api_client-7.1.0-py3-none-any.whl Python 3 none any Details for vi_api_client-7.1.0-py3-none-any.whl

Total release size: 355.2 kB

Release files / vi_api_client-7.1.0.tar.gz

Download URL vi_api_client-7.1.0.tar.gz
Size 173.0 kB
Tags Source
SHA-256 checksum
How to use checksums
528b5d995b85108297cc6df2326e90c11f0a89f7fdfc1af5ead9d5995e18af7d
BLAKE2b-256 checksum
How to use checksums
da2b960a1c25fdf239045cea99521178928c52dc4e3665bd27bcf4687505fcd0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Nov 13, 2026.

Transparency log

Release files / vi_api_client-7.1.0-py3-none-any.whl

Download URL vi_api_client-7.1.0-py3-none-any.whl
Size 182.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
33d68473a567a95c572a00fdca890fc3a67f56e96d749900d172d5ac4e61d10d
BLAKE2b-256 checksum
How to use checksums
54e94232e9f39d01575d7ba682bf212b7953f48aa1f41b4505e0481a549d527a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Nov 13, 2026.

Transparency log

Security for vi-api-client 7.1.0

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

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for vi_api_client-7.1.0.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 Nov 13, 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