Skip to content

Electricity Peak Current Month

peno64 edited this page Feb 10, 2023 · 6 revisions

In Belgium, electricity cost is dependent of your peak usage over a period of 15 minutes per month. The digital meter also return that information but unfortunately, slimmemeter doesn't implement it. This is confirmed by looking at the raw data that the digital meter is sending. See

Via following hack, this information can also be returned.

During the process of creating new firmware (See), the ESP code is put on your computer. It's in .esphome\build\slimmelezer.piolibdeps\slimmelezer\Dsmr\src\dsmr next to your yaml configuration file.

In that folder there is a file fields.h

In that file, there is an entry for energy_returned_lux

Looking at https://esphome.io/components/sensor/dsmr.html energy_returned_lux says:

Luxembourg

  • energy_returned_lux (Optional): Energy Produced Luxembourg
    • name (Required, string): The name for the energy_returned_lux sensor.
    • id (Optional, ID): Set the ID of this sensor for use in lambdas.
    • All other options from Sensor.

Now I live in Belgium and I have no plans at all to move to Luxemburg so what I did was the following.

In fields.h there is:

/* Meter Reading electricity delivered by client (Special for Lux) in 0,001 kWh */

DEFINE_FIELD(energy_returned_lux, FixedValue, ObisId(1, 0, 2, 8, 0), FixedField, units::kWh, units::Wh);

I replaced it with:

/* Electricity Peak Current Month in kW */

DEFINE_FIELD(energy_returned_lux, TimestampedFixedValue, ObisId(1, 0, 1, 6, 0), TimestampedFixedField, units::kW, units::W);

then in the yaml configuration file I add the following:

    energy_returned_lux:
      name: "Electricity Peak Current Month"
      unit_of_measurement: "kW"

See for the complete yaml configuration file I use.

Generate the firmware and upload it (See) and bang, there it is! Unbelievable, but true.

Note that sometimes, building the firmware also refreshes the files under .esphome\build\slimmelezer.piolibdeps\slimmelezer\Dsmr\src\dsmr and then the change in fields.h is lost. So I created a batch file which automates the replacement in fields.h After doing a first build of the firmware, I run the batch file and then build the firmware again and then it is kept. The batch file is called fix.bat and can be found here

Btw, I am using energy_returned_lux which would be good for any country except Luxembourg but even that is not a big issue. People living there can use gas_returned_be instead.