Hello everyone,
I’m excited to share dsmr-custom, an enhanced ESPHome component for reading P1 port data from smart meters. It was born out of the need to reliably support Finnish meters (SESKO standard), but it has been built with flexibility in mind to support a wide range of DSMR-compatible meters, including experimental support for encrypted telegrams.
The key to this component is a diagnostics-first workflow. This guide will first show you the most stable way to discover every OBIS code your specific meter provides, and then how to build a powerful, custom configuration based on that data.
Getting Started: The 3-Step Guide
Follow these steps to get up and running reliably. This process is designed to prevent common issues like device crashes on platforms with limited memory like the ESP8266.
Step 1: Add the Component to ESPHome
You don’t need to copy any files. Simply add the following external_components block to your device’s YAML configuration. ESPHome will automatically download the component from GitHub.
external_components:
- source:
type: git
url: https://github.com/nikopaulanne/dsmr-custom
ref: v1.2.0 # Latest version with ESP-IDF encryption support
components: [ dsmr_custom ]
Step 2: Discover Your Meter’s OBIS Codes
Next, we’ll use a minimal configuration to safely listen to your meter and print its raw data to the ESPHome logs. This is the most important step.
-
Use the Diagnostic Configuration Below: Flash your device with this code. Its only job is to listen for one full data packet (a “telegram”) and print it to the logs.
# In your secrets.yaml, define your WiFi credentials, etc. # wifi_ssid: "YourNetwork" # ... esphome: name: dsmr-diagnostics esp8266: board: d1_mini # Add your wifi, api, ota... logger: level: INFO # Necessary to see the log output uart: id: uart_bus baud_rate: 115200 rx_pin: D7 # IMPORTANT: Change to your device's RX pin rx_buffer_size: 1700 external_components: - source: type: git url: https://github.com/nikopaulanne/dsmr-custom ref: v1.2.0 components: [ dsmr_custom ] dsmr_custom: id: dsmr_hub uart_id: uart_bus text_sensor: - platform: dsmr_custom dsmr_custom_hub_id: dsmr_hub # This confirms a connection, but the magic happens below. identification: name: "P1 Telegram Header" # This captures the full telegram internally and uses a lightweight # trigger to print it to the logs without crashing the device. telegram: internal: true on_value: - logger.log: level: INFO tag: "telegram_dump" format: "--- FULL TELEGRAM RECEIVED ---\n%s\n-----------------------------" args: [x.c_str()] -
View the Logs: In Home Assistant, go to Settings > Add-ons > ESPHome, select your device, and click LOGS.
-
Copy the Data: Wait for a telegram to arrive. You will see a block of text in the logs starting with
--- FULL TELEGRAM RECEIVED ---. Copy this entire block. You now have a complete list of every data point your meter provides!
Step 3: Build Your Final Configuration
Now, create your final YAML. Remove the diagnostic on_value trigger and use the OBIS codes you copied from the log to define your own sensors.
dsmr_custom:
id: dsmr_hub
uart_id: uart_bus
# ... other hub settings ...
custom_obis_sensors:
# Use the codes you discovered in Step 2!
- code: "1-0:1.8.0"
name: "Total Energy Import"
type: sensor
unit_of_measurement: "kWh"
device_class: energy
state_class: total_increasing
- code: "1-0:31.7.0"
name: "Phase Current L1"
type: sensor
unit_of_measurement: "A"
device_class: current
state_class: measurement
accuracy_decimals: 2
Component Features & Technical Details
-
User-Defined OBIS Sensors: The core feature. You can map any OBIS code from your meter to a sensor in Home Assistant, with full control over its name, unit, icon, and other properties.
-
Broad Protocol Support: The component’s parser is modified for lenient header validation, ensuring it works with standard DSMR, Dutch smart meters, and non-standard Finnish (SESKO) meters.
-
Encrypted Telegram Support: Full AES-128-GCM decryption for both Arduino and ESP-IDF platforms. To enable it, provide the 32-character decryption key.
dsmr_custom: decryption_key: "00112233445566778899AABBCCDDEEFF"Arduino (ESP8266/ESP32): Stable, using rweather/Crypto library.
ESP-IDF (ESP32-C6/H2): Hardware-accelerated (10x faster), compile-tested but needs field testing.
See v1.2.0 release notes for technical details.
-
Buffer and Request Management:
- Large Buffer: The
rx_buffer_sizeis configurable to handle large telegrams from modern meters. - Request Pin: For meters that require a data request signal, you can define a
request_pinto actively poll for data.
- Large Buffer: The
Call for Community Testing - v1.2.0
New in v1.2.0: Full ESP-IDF encryption support with hardware acceleration!
Community testing is especially needed for:
- ESP-IDF Platforms (ESP32-C6/H2): Testing encrypted telegrams with hardware acceleration. Does it work on your meter?
- Encryption on Arduino: Continue testing encrypted telegrams on ESP8266/ESP32.
- M-Bus Devices: Verifying OBIS codes for gas, water, or heat meters.
- Performance: Report battery/power usage and speed improvements on ESP32-C6.
Report your test results - Include hardware model, meter type, and success/failure.
Acknowledgments
This project would not be possible without the foundational work on DSMR parsing and integration from the ESPHome community, including contributions and inspiration from @glmnet, @matthijskooijman, @imars, and @zuidwijk.
A special thank you to the community members in the original HA thread for their testing and feedback.
GitHub Repository: nikopaulanne/dsmr-custom
Discussion: All feedback is welcome – I’m particularly interested in hearing from users with encrypted P1 streams or non-Finnish meters!
