Based on esphome-p1reader, which is an ESPHome custom component for reading P1 data from electricity meters. Designed for Swedish meters that implements the specification defined in the Swedish Energy Industry Recommendation For Customer Interfaces version 1.3 and above.
The component can be used by itself from any config file or with one of the config files included in the project, which matches the suggested hardware configurations and is kept up to date with any updates to the component.
Notable differences from esphome-p1reader are:
- More frequent update of sensors with configurable update period.
- No additional components needed. RJ12 cable connects directly to ESP module. (A resistor may be needed in some cases)
- Code rewritten to not spend excessive amounts of time in calls to the
loop
function. This should ensure stable operation of ESPHome and might help prevent some serial communication issues. - Rewritten as an external component since custom components are deprecated.
The current version is tested with ESPHome version 2025.2.1
and the yaml will not work with versions earlier than 2024.6.0
.
- Sagemcom T211 / Ellevio, Skånska Energi
- Aidon 6534 with RJ12/P1-port module (not RJ45/NVE module) / SEVAB
- Landis+Gyr E360 / E.ON - But read this
- S34U18 (Sanxing SX631) / Vattenfall - But read this
- Kamstrup OMNIPOWER
- KAIFA MA304H4E (and MA304T4E) / Nacka Energi - But read this
- Itron A300 / Borås Elnät
- KAIFA CL109 / Öresundskraft
- SWEMET / Shenzhen Star - STZ351: Seems to have an incorrectly formatted message and incorrectly calculated checksum. A possible workaround is discussed here.
This project is named after the Wemos D1 mini board, which is based on the ESP8266 processor. D1 mini boards (or clones) are very cheap and still work well.
The build instructions for the D1 mini match the p1mini.yaml
configuration.
However, the ESP8266 is now over 10 years old and no longer recommended for ESPHome projects. As a result I have moved to using a Waveshare ESP32-C3-Zero board, with a more powerfull processor that does not require more power than the ESP8266.
The build instructions for the C3-Zero match the p1mini32.yaml
configuration.
It is also fairly easy to take any board that ESPHome supports and modifying one of the configurations to work with that. It is mostly a question of figuring out what pins to use for what. If you have pre built hardware which does not connect the RTS signal to a GPIO, read this. Also, if your pre built hardware inverts the signal in hardware, make sure to remove the inversion in the configration!
Note that ESP32 based boards other than the ESP32-C3 draw more power, which may cause a problem with the supply from the meter and generally offer no advantage. The P1 port on the meter provides 5V up to 250mA.
The component can be used by itself from any config file, or with one of the included config files, which are kept up to date with any updates and matches one of the hardware configurations.
If you are making substantial changes to the config it may make more sense to use the component only in your config file.
Clone the repository and create a companion secrets.yaml
file with the following fields:
wifi_ssid: <your wifi SSID>
wifi_password: <your wifi password>
p1mini_password: <Your p1mini password (for OTA, etc)>
p1mini_api_key: <Home Assistant API key>
The p1mini_password
field can be set to any password before doing the initial upload of the firmware. A new API key can be generated on this page.
The file structure should include these files:
|- p1mini.yaml (or p1mini32.yaml)
|- secrets.yaml
|- components
|- p1mini
|- __init__.py
|- p1_mini.cpp
|- p1_mini.h
|- sensor
|- __init__.py
|- p1_mini_sensor.cpp
|- p1_mini_sensor.h
|- text_sensor
|- __init__.py
|- p1_mini_text_sensor.cpp
|- p1_mini_text_sensor.h
Flash ESPHome as usual, with the relevant files in place. Don't connect USB and the P1 port at the same time! If everything works, Home Assistant will autodetect the new integration after you plug it into the P1 port.
Things to try if you are having problems. (Ideally before opening a GitHub Issue)