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

[KNX Energy Meter] ---(KNX Bus)---> [KNX/IP Gateway] ---(UDP)---> [energy2mqtt] ---> [Home Assistant]

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:

Main/Middle/Sub

Examples:

  • 1/2/3 - Main group 1, middle group 2, sub address 3
  • 2/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

knx:
  - name: "Main KNX Line"
    host: "192.168.1.100"
    port: 3671
    enabled: true
    meters:
      - name: "Heat Pump"
        manufacturer: "ABB"
        model: "Energy Meter EM/S"
        read_interval: 60
        phases:
          - name: "L1"
            voltage_ga: "2/3/10"
            current_ga: "2/3/20"
            power_ga: "2/3/30"
            energy_ga: "2/3/40"
          - name: "L2"
            voltage_ga: "2/3/11"
            current_ga: "2/3/21"
            power_ga: "2/3/31"
            energy_ga: "2/3/41"
          - name: "L3"
            voltage_ga: "2/3/12"
            current_ga: "2/3/22"
            power_ga: "2/3/32"
            energy_ga: "2/3/42"
        total_energy_ga: "2/3/50"
        calculate_totals: true

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:

knx:
  - name: "Office Line"
    host: "192.168.1.101"
    meters:
      - name: "Office Meter"
        voltage_ga: "3/1/10"
        current_ga: "3/1/11"
        power_ga: "3/1/12"
        energy_ga: "3/1/13"
        energy_type: ActiveEnergyWh  # Values in Wh, converted to kWh

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:

meters:
  - name: "Main Meter"
    phases:
      - name: "L1"
        # ... phase config
    # Option 1: Read totals from bus
    total_energy_ga: "2/3/50"
    total_power_ga: "2/3/51"
    total_current_ga: "2/3/52"

    # Option 2: Calculate from phases
    calculate_totals: true  # Sums power/current/energy, averages voltage
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:

{
  "voltage_l1": 230.5,
  "voltage_l2": 231.2,
  "voltage_l3": 229.8,
  "current_l1": 5.2,
  "current_l2": 4.8,
  "current_l3": 5.0,
  "power_l1": 1196.6,
  "power_l2": 1110.96,
  "power_l3": 1149.0,
  "energy_l1": 1234.567,
  "energy_l2": 1198.432,
  "energy_l3": 1212.891,
  "voltage_avg": 230.5,
  "current_all": 15.0,
  "power_all": 3456.56,
  "energy_all": 3645.89
}

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 ActiveEnergyWh or ActiveEnergyKwh)
  • Ensure power values use the correct DPT (2-byte float vs 4-byte float)

“Connection drops frequently”

  • Increase connection_timeout and read_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:

  1. Ask your installer - They should provide a group address list
  2. Use a KNX monitor - Tools like KNXtools can show bus traffic
  3. Check device documentation - Energy meters often have standard address schemes
  4. 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:

e2m_management (energy2mqtt)
└── KNX Adapter (e.g., "Main KNX Line")
    β”œβ”€β”€ Meter 1 (e.g., "Heat Pump")
    β”œβ”€β”€ Meter 2 (e.g., "Solar Inverter")
    └── ...

Each meter appears as a separate device linked to its adapter via via_device.