Xt211
ESPHome component DLMS/Cosem PUSH mode readout. Works with ČEZ Sagecom XT211 AMM
Install / Use
/learn @Tomer27cz/Xt211README
ESPHome DLMS/Cosem PUSH RS485 readout
For Sagecom XT211 smart meter used by ČEZ Distribuce (Czechia)
[Česká verze]
My electricity provider (ČEZ Distribuce) has just installed a new smart meter at my home. Up until this time I was using the Home Assistant Glow to track my household energy consumption. So I was excited to finnaly get my hands on the new smart meter and see if I can read out the data from it. Unfortunately it was not as easy as I hoped, but after many failed attempts I managed to get it working, and I want to share my experience with you.
Sagecom XT211 - My smart meter
Distribution company website (in czech) | Datasheet

The Sagecom XT211 is a three-phase smart meter that supports DLMS/COSEM protocol for data communication. It has a built-in RS485 interface that can be used to read out the meter data. The meter is configured for PUSH communication, which means it sends data every 60 seconds without the need for polling.

In my case, the meters port was connected to the WM-RelayBox device, which is used for remote disconnection of the electricity supply. The RS485 interface is accessible via an RJ12 port that is located on the device.

WM-RelayBox
Datasheet | Installation Guide | Quick Guide
The RelayBox connects to the electricity meter (via its RJ12 E-Meter interface) and it receives unidirectional (one-way) DLMS / COSEM „push” commands and messages from the Head-end System through the meter.
Then it executes the relay switch requests and sends all data provided by the smart meter to the Customer Interface HAN / P1 output interface (separate, isolated RJ12 port) of the RelayBox.

HAN port
The HAN port is an isolated RJ12 port that provides access to the data sent by the electricity meter. The port uses RS485 communication with the following pinout:

Some sources say that the 6th pin is connected to GND, while others say it is not used. I only have pins 3 and 4 connected, because I only need the data lines for RS485 communication (and I only had an RJ11 telephone cable that does not have pins 1 and 6).
| Pin | Signal | |-----|-------------| | 1 | Not used | | 2 | Not used | | 3 | Data A (+) | | 4 | Data B (-) | | 5 | Not used | | 6 | GND |
RS485 to TTL converter
To connect the HAN port to my ESPHome device, I used a RS485 to TTL converter. I used this AliExpress TTL To RS485 module, but there are many other similar modules available.

RS485 parameters
The RS485 communication parameters are defined in připojovací podmínky NN document provided by ČEZ Distribuce:

| Parameter | Value | |-----------------|----------| | Baud rate | 9600 bps | | Data bits | 8 | | Start bits | 0 | | Stop bits | 1 | | Parity | None | | Flow control | None |
PulseMeter (Home Assistant Glow)
One thing I liked about the Home Assistant Glow meter was that it updated fairly quickly (depending on the pulse frequency). The new meter sends PUSH messages only every 60 seconds, which is not ideal for real-time monitoring.
So I decided to get the best of both worlds and use the PulseMeter in Home Assistant for real-time power consumption (W) monitoring, while using the ESPHome DLMS/Cosem readout for the energy (kWh) monitoring.
For more information about the PulseMeter, see the Home Assistant Glow documentation.
LM393 Photo-diode sensor

Mounting
I mounted the ESPHome device and the RS485 to TTL converter inside a small project box.
Box.stl

I took the photodiode sensor box from the Home Assistant Glow meter.
Sensor_bottom_side_v1.stl

Sensor_top_side_v1.stl

I made a Frame for mounting the sensor box on the XT211 meter.
Frame XT211 Wide.stl

Wiring diagram

LM393 Photo-diode sensor:
- VCC to 5V
- GND to GND
- DO (Digital Output) to GPIO6
- AO (Analog Output) to GPIO5 (analog input, optional)
RS485 to TTL converter:
- VCC to 5V
- GND to GND
- TXD to RX (GPIO21)
- RXD to TX (GPIO22)
HAN port (RJ12 / RJ11):
- B- (Data B) to HAN port pin 4
- A+ (Data A) to HAN port pin 3
- GND to pin 6 (optional)
Activity LED (optional):
- Anode (longer leg) to GPIO4 (with 220 ohm resistor in series)
- Cathode (shorter leg) to GND
Power Led (optional):
- Anode (longer leg) to 5V (with 4700 ohm resistor in series - lower brightness)
- Cathode (shorter leg) to GND
Custom ESPHome component
There are two versions in this repository:
xt211- the original version that I used for my setup, which is based on the esphome-dlms-cosemdlms_push- written from scratch (no longer using Gurux Libraries) using common esphome component structure, it is more flexible and easier to maintain.
I will be using and maintaining the dlms_push version, but the xt211 version is still available for reference and for those who want to use it as is.
ESPHome configuration
For full configuration file, see: esphome-smartmeter.yaml
In your esphome configuration file, add the following lines at the top (for esp32c3):
esp32:
variant: esp32c3
framework:
type: esp-idf
Add the external component to your ESPHome configuration:
external_components:
- source: github://Tomer27cz/xt211
components: [dlms_push]
refresh: 1s
The configuration options are:
show_log(optional, default:false) - whether to show the log of the DLMS/COSEM communication. This is useful for debugging and first setup, but it can be quite verbose.receive_timeout(optional, default:50ms) - the timeout for receiving data from the meter. If the meter does not send any data within this time, the communication is considered finished and it will be processed.custom_pattern(optional) - custom COSEM object pattern
Disable the log onece everything is working fine.
logger:
baud_rate: 0
uart:
id: bus_1
rx_pin:
number: GPIO21
mode:
input: true
pullup: true
tx_pin: GPIO20
baud_rate: 9600
data_bits: 8
parity: NONE
stop_bits: 1
dlms_push:
id: my_dlms_meter
uart_id: bus_1
In newer versions of ESPHome (esp-idf > 5.x) , the uart pins need to be pulled up, otherwise the communication will not work. This is because the default state of the pins was changed to floating.
I am using the same pins for the RS485 converter as for the logger, so I had to disable the logger by setting the baud_rate to 0. You can use different pins for the logger if you want to keep it enabled.
Number sensor (sensor)
My electricity consumption is measured in kWh, but the meter sends the value in Wh. Therefore, I use a lambda filter to convert the value from Wh to kWh by dividing it by 1000.
sensor:
- platform: dlms_push
id: active_energy_consumed
name: "Energy"
obis_code: 1.0.1.8.0.255
unit_of_measurement: kWh
accuracy_decimals: 3
device_class: energy
state_class: total_increasing
filters:
- lambda: "return x/1000.0;"
Binary sensor (binary_sensor)
The binary sensor is false when the value is 0, and true when the value is anything else.
binary_sensor:
- platform: dlms_push
name: "Relay 1"
obis_code: 0.1.96.3.10.255
Text sensor (text_sensor)
The text sensor is used to display string values sent by the meter.
text_sensor:
- platform: dlms_push
name: "Serial number"
obis_code: 0.0.96.1.1.255
entity_category: diagnostic
Pulse meter (pulse_meter) - for real-time power consumption monitoring (W)
time:
- platform: homeassistant
id: homeassistant_time
number:
- platform: template
id: select_pulse_rate
name: 'Puls rate - imp/kWh'
optimistic: true
mode: box
min_value: 100
max_value: 10000
step: 100
restore_value: yes
initial_value: 1000
sensor:
- platform:
Related Skills
node-connect
348.5kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
109.1kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
348.5kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
qqbot-media
348.5kQQBot 富媒体收发能力。使用 <qqmedia> 标签,系统根据文件扩展名自动识别类型(图片/语音/视频/文件)。
