KNX (Building Automation)
KNX is a standardized building automation protocol (ISO/IEC 14543) widely used in Europe for controlling lighting, HVAC, blinds, and energy metering. energy2mqtt connects to KNX/IP gateways via UDP tunneling to read energy meter data and expose it to Home Assistant.
Details
KNX was formerly known as EIB (European Installation Bus). The protocol uses group addresses to identify data points and datapoint types (DPT) to define how values are encoded.
How KNX Works
KNX devices communicate over a twisted-pair bus (KNX TP) or via IP (KNX/IP). energy2mqtt connects to a KNX/IP gateway or interface that bridges the bus to your network. It sends read requests to group addresses and caches the responses for publishing to MQTT.
Typical Setup
Common KNX/IP gateways include:
- Weinzierl KNX IP Interface 731
- ABB IPR/S 3.5.1
- MDT SCN-IP100.03
- JUNG IPR 300 SREG
- Siemens N 148/22
Protocol Details
Group Addresses
KNX uses group addresses to identify data points. They are written in a 3-level format:
Examples:
1/2/3- Main group 1, middle group 2, sub address 32/3/82- Typical energy meter address
Details
Group addresses are configured in the KNX project using ETS (Engineering Tool Software). Ask your KNX installer for the group address list if you don’t have access to the ETS project.
Datapoint Types (DPT)
Values on the KNX bus are encoded according to Datapoint Types. energy2mqtt supports the following DPTs for energy metering:
| DPT | Name | Description | Unit |
|---|---|---|---|
| DPT 9.020 | Voltage | 2-byte float | V |
| DPT 9.021 | Current | 2-byte float | A |
| DPT 9.024 | Power | 2-byte float | kW |
| DPT 14.056 | Power | 4-byte float | W |
| DPT 13.010 | Active Energy | 4-byte signed | Wh |
| DPT 13.013 | Active Energy | 4-byte signed | kWh |
| DPT 13.012 | Reactive Energy | 4-byte signed | VArh |
| DPT 13.015 | Reactive Energy | 4-byte signed | kVArh |
| DPT 13.014 | Apparent Energy | 4-byte signed | kVAh |
| DPT 1.001 | Switch | 1-bit boolean | ON/OFF |
Corresponding Configuration Values
| Measurement Type | Config Value | Default DPT |
|---|---|---|
| Voltage | VoltageV |
DPT 9.020 |
| Current | CurrentA |
DPT 9.021 |
| Power (W) | PowerW |
DPT 14.056 |
| Power (kW) | PowerKw |
DPT 9.024 |
| Active Energy (Wh) | ActiveEnergyWh |
DPT 13.010 |
| Active Energy (kWh) | ActiveEnergyKwh |
DPT 13.013 |
| Reactive Energy (VArh) | ReactiveEnergyVah |
DPT 13.012 |
| Reactive Energy (kVArh) | ReactiveEnergyKvarh |
DPT 13.015 |
| Apparent Energy (kVAh) | ApparentEnergyKvah |
DPT 13.014 |
| Switch | Switch |
DPT 1.001 |
Details
Energy values in Wh are automatically converted to kWh for consistency. All energy values are reported in kWh/kVArh/kVAh.
Configuration
KNX configuration in energy2mqtt uses a hierarchical structure:
- Adapters - KNX/IP gateways to connect to
- Meters - Energy meters with their group addresses
- Phases - Individual phases for 3-phase meters
- Switches - On/off switches (optional)
Basic Configuration Example
Adapter Parameters
| Parameter | Required | Default | Description |
|---|---|---|---|
name |
Yes | - | Friendly name for the adapter |
host |
Yes | - | IP address of KNX/IP gateway |
port |
No | 3671 |
UDP port (standard KNX/IP port) |
enabled |
No | true |
Enable/disable this adapter |
connection_timeout |
No | 10 |
Connection timeout in seconds |
read_timeout |
No | 5 |
Read timeout in seconds |
response_wait |
No | 3 |
Seconds to wait for responses after sending read requests |
meters |
No | [] |
List of meter configurations |
switches |
No | [] |
List of switch configurations |
Meter Parameters
| Parameter | Required | Default | Description |
|---|---|---|---|
name |
Yes | - | Friendly name (shown in Home Assistant) |
enabled |
No | true |
Enable/disable this meter |
read_interval |
No | 60 |
Seconds between read cycles |
manufacturer |
No | "KNX" |
Manufacturer name for HA discovery |
model |
No | "Energy Meter" |
Model name for HA discovery |
phases |
No | [] |
Phase configurations for 3-phase meters |
calculate_totals |
No | true |
Auto-calculate totals from phase values |
Single-Phase Meter Example
For simple single-phase meters, you can configure group addresses directly:
Phase Parameters
| Parameter | Required | Default | Description |
|---|---|---|---|
name |
Yes | - | Phase name (e.g., “L1”, “L2”, “L3”) |
voltage_ga |
No | - | Group address for voltage |
current_ga |
No | - | Group address for current |
power_ga |
No | - | Group address for power |
energy_ga |
No | - | Group address for energy |
voltage_type |
No | VoltageV |
Datapoint type for voltage |
current_type |
No | CurrentA |
Datapoint type for current |
power_type |
No | PowerW |
Datapoint type for power |
energy_type |
No | ActiveEnergyKwh |
Datapoint type for energy |
Total Values
For 3-phase meters, totals can come from the bus or be calculated:
Details
If both total_*_ga and calculate_totals are set, the bus value takes precedence. Calculated totals only appear if the corresponding phase values are configured.
Output Data
After processing, energy2mqtt publishes meter data to MQTT and creates Home Assistant auto-discovery entries.
MQTT Topics
State topic: energy2mqtt/devs/KNX/{meter_id}
Example output:
Home Assistant Entities
energy2mqtt creates the following entities in Home Assistant:
| Entity | Device Class | Unit | State Class |
|---|---|---|---|
| Voltage (per phase) | voltage |
V | measurement |
| Current (per phase) | current |
A | measurement |
| Power (per phase) | power |
W/kW | measurement |
| Energy (per phase) | energy |
kWh | total_increasing |
| Voltage Average | voltage |
V | measurement |
| Current Total | current |
A | measurement |
| Power Total | power |
W/kW | measurement |
| Energy Total | energy |
kWh | total_increasing |
Diagnostic Data
Each KNX adapter also exposes diagnostic statistics:
| Statistic | Description |
|---|---|
read_requests_sent |
Number of read requests sent to the bus |
responses_received |
Number of responses received |
cache_hits |
Values found in cache during publish |
cache_misses |
Values not found in cache |
connection_errors |
Number of connection failures |
reconnections |
Number of reconnection attempts |
poll_cycles_completed |
Completed polling cycles |
meters_published |
Number of meter data publishes |
Troubleshooting
Common Issues
“Connection timeout”
- Verify the KNX/IP gateway IP address and port
- Check that the gateway is reachable:
ping 192.168.1.100 - Ensure no firewall blocks UDP port 3671
- Check if another client is using the tunnel (most gateways only support one tunnel)
“No values received”
- Verify group addresses are correct (check ETS project)
- Ensure read flags (R) are set on the group addresses in ETS
- Some devices only send values on change; try increasing
response_wait - Check that the energy meter is actually transmitting data
“Wrong values or units”
- Verify the correct datapoint type is configured
- Check if the meter uses Wh or kWh for energy (use
ActiveEnergyWhorActiveEnergyKwh) - Ensure power values use the correct DPT (2-byte float vs 4-byte float)
“Connection drops frequently”
- Increase
connection_timeoutandread_timeout - Check for network stability issues
- Some gateways have limited tunnel sessions; ensure only energy2mqtt connects
Getting Group Addresses
If you don’t have access to the ETS project:
- Ask your installer - They should provide a group address list
- Use a KNX monitor - Tools like KNXtools can show bus traffic
- Check device documentation - Energy meters often have standard address schemes
- Bus scan - Some gateways support scanning for active addresses
Details
Never write to unknown group addresses. This could trigger unintended actions like switching relays or changing setpoints.
Device Hierarchy
energy2mqtt creates a logical device hierarchy in Home Assistant:
Each meter appears as a separate device linked to its adapter via via_device.