viessmann-optolink2mqtt
⭐ If you find this App useful, please star this repo - it helps others discover the project! ⭐
Open-source MQTT bridge for Viessmann heating systems using the Optolink interface.
This project connects a Viessmann device such as a heat pump or gas boiler to a local MQTT broker, allowing you to read live telemetry, control writable registers, and integrate everything into Home Assistant or any other MQTT-capable automation stack without sending data to a vendor cloud.
Table of contents
- What is Optolink?
- Architecture
- Hardware requirements
- Features
- Installation
- Configuration
- How to discover register addresses/length/encoding
- Reading a single register with
read-register - Serial port naming
- Home Assistant integration
- Labelling the hardware
- Roadmap
- Related projects
🧩 What is Optolink?
Some Viessmann devices, especially those manufactured before roughly 2014, expose an optical interface called Optolink for communication with third-party tools.
This interface is normally located in the Vitotronic panel and is officially intended for use with the VitoConnect device. But it also allows advanced users to read and write registers on the heating system to collect telemetry such as temperatures and component states, and to change settings such as heating mode or target temperatures.
This project lets you connect to that interface and publish the data to a local MQTT broker, keeping the information on your own network instead of routing it through a vendor cloud.
🏗️ Architecture
🛠️ Hardware requirements
- A small single-board computer (SBC) capable of running Python and exposing a USB-A port if you use the original Viessmann Optolink USB cable. A typical choice is a Raspberry Pi; the author has also used an OLinuXino A64 as a lower-cost alternative.
- An Optolink-to-USB cable. You can either:
- buy the original Viessmann cable from a specialist vendor such as Loebbe Shop, or
- build a compatible cable yourself; more details are available from projects such as MyVitotronicLogger and the Optolink Splitter project.
✨ Features
This project is designed to be:
- reliable and ready to run 24/7, with robust error handling, automatic reconnection to the MQTT broker, and serial-port recovery after transient failures
- easy to configure through a single YAML file for all device parameters and metadata
- capable of both reading values from the heating system and writing writable registers such as heating modes or target temperatures
- Home Assistant friendly, with MQTT discovery support to make entities appear automatically in Home Assistant
- straightforward to install via PyPI or Docker, with simple upgrade paths
Current limitation:
- compatibility with VitoConnect is not implemented; if you need that approach, check out Optolink Splitter or Optolink Bridge.
🚀 Installation
This project supports two main setup paths: PyPI and Docker. Both are intended for Linux systems with the USB cable connected to the Optolink interface.
PyPI package
python3 -m venv optolink2mqtt-venv
source optolink2mqtt-venv/bin/activate
pip install viessmann-optolink2mqtt
optolink2mqtt --help
Python compatibility
The project aims to stay compatible with Python 3.9, to support Debian 11 (bullseye) and its derivatives, such as Raspberry Pi OS Legacy, which ship Python 3.9. The CI runs the unit tests on Python 3.9 (the oldest supported version), 3.11 and 3.15 (the latest release).
For this reason, dependencies are pinned to the last versions that still support Python 3.9. For example, platformdirs stays at 4.4.0, since later releases require Python 3.10 or 3.11.
On Debian 11, the venv module is in a separate package. Debian 11's pip (20.3) is old, so upgrade it inside the virtual environment before installing:
sudo apt install python3-venv
python3 -m venv optolink2mqtt-venv
source optolink2mqtt-venv/bin/activate
pip install --upgrade pip
pip install viessmann-optolink2mqtt
The Docker image ships its own Python, so it doesn't depend on the Python version of the host.
Docker
When using Docker, provide the YAML config path and the serial port name in the command line. For example, /dev/ttyUSB0:
docker run -d -v <your config file>:/etc/optolink2mqtt/optolink2mqtt.yaml \
--device=/dev/ttyUSB0 \
--hostname $(hostname) \
--name optolink2mqtt \
--restart=unless-stopped \
ghcr.io/f18m/optolink2mqtt:latest
docker logs -f optolink2mqtt
The --restart=unless-stopped option ensures the container is restarted after a system reboot.
The container runs as an unprivileged user that belongs to the dialout group (gid 20), which owns serial devices on Debian, Ubuntu and Raspberry Pi OS. If the serial device on your host belongs to another group (check with ls -ln /dev/ttyUSB0), add --group-add <gid of that group> to the docker run command.
The Docker image supports three architectures: amd64, armv7, and arm64.
If your MQTT broker requires authentication, set MQTT_BROKER_PASSWORD to provide the password as an environment variable. Alternatively, mount a Docker secret file and set MQTT_BROKER_PASSWORD_FILE to the file path:
docker run -d -v <your config file>:/etc/optolink2mqtt/optolink2mqtt.yaml \
-v <path to secret file>:/run/secrets/mqtt_broker_password:ro \
--env MQTT_BROKER_PASSWORD_FILE=/run/secrets/mqtt_broker_password \
--device=/dev/ttyUSB0 \
--hostname $(hostname) \
--name optolink2mqtt \
--restart=unless-stopped \
ghcr.io/f18m/optolink2mqtt:latest
The broker username is configured in mqtt.broker.username in the YAML file. MQTT_BROKER_PASSWORD takes precedence over MQTT_BROKER_PASSWORD_FILE, and either environment variable overrides mqtt.broker.password in the YAML configuration. A trailing newline in the password file is ignored. The password is only sent when mqtt.broker.username is set too.
To connect over TLS, set mqtt.broker.tls: true (the default when mqtt.broker.port is 8883). The broker certificate is always verified, against the system CA store or the CA bundle in mqtt.broker.ca_certs; mqtt.broker.certfile and mqtt.broker.keyfile provide an optional client certificate. Without TLS, credentials are sent in plaintext.
Docker Compose
If you prefer Docker Compose, use the provided docker-compose.yml file and adapt the serial port name to your system, for example replacing /dev/ttyUSB0 with the actual port provided by your device.
⚙️ Configuration
This software accepts declarative configuration in YAML format. Use optolink2mqtt.yaml as the reference for the supported syntax and configuration structure.
Register entries
Each entry of registers_poll_list has a name, which also gives its MQTT topic, and up to three sections:
| Section | Keys | Purpose |
|---|---|---|
register |
address, length, type, encoding, signed, scale_factor, enum, writable, copy_from |
the register of the Viessmann device, and how its bytes are decoded; this information is the hard part to discover, see the section How to discover register addresses/length/encoding |
processing |
sampling_period_seconds (mandatory), byte_filter, formatter |
how often the register is polled, and how the decoded value is transformed |
ha_discovery |
see optolink2mqtt.yaml | how the value is presented to Home Assistant (optional) |
Example:
- name: external_temperature
register: # this section lists all properties of the register that were defined by Viessmann and cannot be customized
address: 0x0101
length: 2
type: float
scale_factor: 0.1
signed: true
processing: # this section defines how this software will process the acquired register value
sampling_period_seconds: 10
formatter: "{{ x }}"
ha_discovery: # this section defines how to present the register to HomeAssistant (optional)
name: "External Temperature"
platform: sensor
device_class: temperature
unit_of_measurement: "°C"
Register types
The register.type attribute of each entry says how its bytes are decoded:
type |
Bytes | Published value |
|---|---|---|
int (default) |
little-endian integer, signed or not |
integer, e.g. 42 |
float |
little-endian integer multiplied by scale_factor |
number, e.g. 21.5 |
enum |
little-endian integer mapped to a label by the enum dictionary |
label, e.g. DHW only |
datetime_bcd |
the 8-byte Viessmann DateTimeBCD format | ISO 8601 date/time, e.g. 2026-12-24T00:00:00+01:00 |
A scale_factor other than 1 requires type: float, and an enum dictionary requires type: enum.
A datetime_bcd register is published as an ISO 8601 date/time, or as None when the date/time is not set on the device (Viessmann stores 1970-01-01 for that). The device clock has no timezone: set optolink.timezone to its IANA timezone, e.g. Europe/Berlin, otherwise the timezone of the host is used. Writing an ISO 8601 date/time sets the register, converting it to the device timezone if it carries a timezone; writing None clears it.
In Home Assistant, use the datetime platform for a writable register (Home Assistant 2026.5 or later), or the sensor platform with device_class: timestamp for a read-only one.
Byte order
The register.encoding attribute sets the byte order of int, float and enum registers: little_endian (the default) or big_endian. With big_endian the bytes are kept in address order, the first one being the most significant.
Formatting
The processing.formatter attribute is a Jinja2 template that renders the decoded value x into the published string, e.g. "0x{{ '%04X' | format(x) }}". It is optional, and it can only be used on read-only registers. Some common templates:
| Template | Register type |
Decoded x |
Published |
|---|---|---|---|
"0x{{ '%04X' | format(x) }}" |
int |
1234 |
0x04D2 |
"{{ '%X' | format(x) }}" |
int |
1234 |
4D2 |
"{{ '%.1f' | format(x) }}" |
float |
21.461 |
21.5 |
Formatters run in a Jinja2 sandbox and are checked at startup; a formatter failing on a value at runtime logs an error and skips publishing that value. A sensor with a formatter gets no default state_class, since its value may not be a number.
Split registers
Some registers pack several values, e.g. the 8-byte device identification block at 0x00F8. Two optional attributes help to publish each value on its own:
processing.byte_filterdecodes only the bytesb:<start>:<end>(both inclusive, zero-based) of anintorfloatregister. By default all bytes are decoded. A writable register cannot have abyte_filter, since a write sets all of its bytes.register.copy_fromnames another entry whose wholeregistersection is copied; the keys set next tocopy_fromoverride the copied ones.
All entries with the same register address and length are read from the device only once per poll and decoded for each of them, so they must have the same processing.sampling_period_seconds. For example, with the bytes 20 CB 04 60 00 00 01 0A:
- name: device_code
register:
address: 0x00F8
length: 8
encoding: big_endian
processing:
sampling_period_seconds: 3600
byte_filter: "b:0:1"
formatter: "{{ '%04X' | format(x) }}" # publishes "20CB"
- name: device_hardware_index
register:
copy_from: device_code
processing:
sampling_period_seconds: 3600
byte_filter: "b:2:2"
formatter: "0x{{ '%02X' | format(x) }}" # publishes "0x04"
Configuration version
The top-level config_version key says which version of the configuration format a file is written for. Each optolink2mqtt release accepts exactly one version and refuses to start (exit code 2) with any other, explaining why. Files without config_version are version 1. The version matches the major version of optolink2mqtt: 1.x releases use version 1, 2.x releases version 2. Version 2 moved the keys of each register entry into the register and processing sections, renaming register to address, and requires a type for scaled and enumerated registers.
When a release bumps the version, convert your file with the configuration upgrade tool: paste the current file and copy the converted one, with the changes highlighted. It runs entirely in your browser.
How to discover register addresses/length/encoding
This is typically the most difficult/convoluted step. I tried to provide a step-by-step procedure in this wiki page. Feedback is welcome.
As you will read on the wiki, exploring the registers of your Viessmann device is much simpler using the read-register helper provided by viessmann-optolink2mqtt. So checkout next section.
Reading a single register with read-register
optolink2mqtt has two modes:
optolink2mqtt runpolls the registers in the configuration file and bridges them to MQTT. It is the default mode, used when no mode is given.optolink2mqtt read-register <address> <length> [signed] [scale_factor] [byte_filter]reads one register once, prints everything about it on stdout, and exits. No MQTT broker is needed.
Use read-register to try out a register before adding it to registers_poll_list. The arguments match the register keys of the configuration file:
| Argument | Meaning | Default |
|---|---|---|
address |
register address, hexadecimal (0x0800) or decimal |
(required) |
length |
number of bytes to read | (required) |
signed |
signed/true or unsigned/false |
unsigned |
scale_factor |
factor the decoded integer is multiplied by, e.g. 0.1 |
1.0 |
byte_filter |
decode only bytes b:<start>:<end> (both inclusive) |
none |
The serial port is read from the configuration file. To skip the configuration file, pass --serial-port /dev/ttyUSB0. Add --show-received-bytes to log the raw serial traffic.
For example, to read the 2-byte signed outdoor temperature at 0x0800, scaled by 0.1:
optolink2mqtt read-register --serial-port /dev/ttyUSB0 0x0800 2 signed 0.1
The output shows:
- the serial port settings, and whether the VS2 handshake succeeded;
- the raw bytes, one per line, in hex, decimal and binary;
- the value decoded with the given parameters;
- other ways to read the same bytes (signed/unsigned, little/big endian, scaled by 0.1 and 0.01, ASCII), which help you guess the format;
- a
registers_poll_listsnippet you can paste into the configuration file.
Only one program at a time can talk over the Optolink interface. read-register refuses to start, with exit code 5, if the serial port is already in use, for example by an optolink2mqtt run instance. Stop that instance first (e.g. docker stop optolink2mqtt) and restart it when you are done.
With Docker, run the mode in a temporary container:
docker run --rm --device=/dev/ttyUSB0 \
ghcr.io/f18m/optolink2mqtt:latest \
python -m src.main read-register --serial-port /dev/ttyUSB0 0x0800 2 signed 0.1
read-register exits with code 0 if the read succeeded. It exits with 2 if the configuration file cannot be loaded, 4 if the register arguments are invalid, 5 if the serial port is busy, 6 if the Optolink connection cannot be set up, and 7 if the read failed.
🔌 Serial port naming
A common issue on some Linux platforms is that a USB serial adapter may be re-enumerated by the kernel after a bus reset, causing the device name to change from /dev/ttyUSB0 to /dev/ttyUSB1 or similar. In that case, a config file that references the old device path will stop working.
The recommended solution is to create a stable udev symlink for the adapter and use that path instead.
- Use
lsusbto identify the Viessmann Optolink adapter details. For example:
Bus 002 Device 006: ID 1a86:7523 QinHeng Electronics CH340 serial converter
In this example, 1a86 is the vendor ID and 7523 is the product ID.
- Create a udev rule:
sudo nano /etc/udev/rules.d/99_optolink_usb.rules
Then add a line like:
SUBSYSTEM=="tty", ATTRS{idVendor}=="1a86", ATTRS{idProduct}=="7523", SYMLINK+="optolinkUSB"
-
Unplug and reconnect the Optolink cable.
-
Use
/dev/optolinkUSBin optolink2mqtt.yaml and pass--device=/dev/optolinkUSBin Docker commands when needed.
🏠 Home Assistant integration
This project makes it easy to expose Viessmann entities to Home Assistant through MQTT discovery.
The ha_discovery section of each register in optolink2mqtt.yaml contains metadata that tells Home Assistant how to create entities automatically.
This makes it possible to build a Home Assistant dashboard that reflects the state of your Viessmann system. For example, the dashboard below was created for a heat pump:
Labelling the hardware
Your Viessmann device and the SBC used to monitor it may stay in service for many years. To make future maintenance easier, it's a good idea to document what is running where.
A simple approach is to print a QR code pointing to this project and attach it physically to the SBC so that anyone inspecting it can quickly find the relevant documentation.
Here's a QR code generated for that purpose:
🗺️ Roadmap
Planned work includes:
- Prometheus support for health statistics such as Optolink errors and network issues
If you are looking for a specific feature, open an issue.
🔗 Related projects
- Optolink Splitter: the original project that inspired this one
- Optolink Bridge: an approach based on the Optolink Splitter idea that requires a VitoConnect device and creates a man-in-the-middle bridge
- openv vcontrold: an older C-based implementation of the VS1 and VS2 protocols; its wiki contains extensive protocol details in German
- VitoWiFi: a C++ implementation of the VS1 (KW) and VS2 (P300) Optolink protocols for Linux and ESP-based systems
- FloorHeatingController: firmware for controlling floor-heating valves and replacing physical thermostats with Home Assistant virtual thermostats
Metadata
Release files for viessmann-optolink2mqtt 2.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| viessmann_optolink2mqtt-2.0.0.tar.gz | 772.5 kB | With provenance | Details for viessmann_optolink2mqtt-2.0.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| viessmann_optolink2mqtt-2.0.0-py3-none-any.whl | Python 3 | none | any | Details for viessmann_optolink2mqtt-2.0.0-py3-none-any.whl |
Total release size: 848.2 kB
Release files / viessmann_optolink2mqtt-2.0.0.tar.gz
| Download URL | viessmann_optolink2mqtt-2.0.0.tar.gz |
|---|---|
| Size | 772.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
6c2f238bc7bb614a761ece19881a5b4276ed9d8acb3b50c9add2c2f07e0682d0
|
|
BLAKE2b-256 checksum How to use checksums |
41ebd00e0c97d8cfc8588e00a80dcdd6b3153ca8c4dc1aaedfa58ae4ae1d061d
|
| 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 30, 2026.
Transparency logRelease files / viessmann_optolink2mqtt-2.0.0-py3-none-any.whl
| Download URL | viessmann_optolink2mqtt-2.0.0-py3-none-any.whl |
|---|---|
| Size | 75.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
b19078a8544de16fb7ca3cc74c590e831b62892b337811313a197f40787f7da2
|
|
BLAKE2b-256 checksum How to use checksums |
4d59f8603ed62eea2349c28c4e9d40cbc56dc3feabc305c463974e863d95d840
|
| 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 30, 2026.
Transparency logSecurity for viessmann-optolink2mqtt 2.0.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.
Attestation for viessmann_optolink2mqtt-2.0.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 30, 2026.
Transparency logA 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.