ESP32 Pulse Sensor to Energy Dashboard

Hi,

I have been monitoring energy usage through home assistant for several years on a Supervised setup but have converted over to HAOS. I have everything else pretty much set up again with the exception of Energy Monitor. Also as it has been several years since I did it I have misplaced my source code for the ESP32 which counts pulses on my energy meters which equates to 1Wh / pulse.

The ESP transfers this data to Home Assistant via MQTT (/PowerESP32/GridImport) and sends the numerical value of how many Wh have been used in the past 5 minutes (AKA since the last transfer).

I have got the data getting into Home Assistant as sensor via adding the MQTT section to the base of my configuration.yaml.

A key issue which is causing me grief that I can’t resolve is that for example it may transfer 23, 26, 27, 2, 15, 19, 10 for example. It appears that in this case it will record my usage as 23,3,1,2,13, 4, 10 etc. as it only records readings that are lower then the previous as the full reading and otherwise just thinks the reading is what the increase is from the previous reading.

Like I said I have lost my previous code etc from both the home assistant and the ESP32 side and this ESP also does far more than just power monitoring.

In essense I believe my issue is that the data it is receiving via MQTT is a single 5 minute snapshot which starts at zero again each time a transmission is done}.

:crossed_fingers: I may have worked it out. Seems I needed to enable a Delta feature on the utility meter. Won’t know for sure until start to get more data tomorrow

I have definitely made progress with changing the utility meter to Delta values but still out by about 11% over a 5 hour window in comparison to PVOutput (which the ESP32 also sends data to).

In digging through the data in Home Assistant and also in PVOutput as output by output it is clear that I have lost

  • 1 entry out of 60 to PVOutput. Not hugely an issue and can see in my Internet uptime in my router that co-incides with an interruption so that is all good
  • 8 of 60 is missing out of the dataset to Home Assistant (and for clarity it got the value that PVOutput missed due to internet interruption).

So unsure why MQTT is dropping / not accepting data intermittently as it wasn’t an issue previously (well at least not noticeable when I did intermittent comparisons of data it would vary normally about 1% or less. Will dig further into this to see what I can work out.

Interestingly the data it is missing is instances is (in this data at least) where the usage is the same in Wh as the previous 5 minute time window. Seems it doesn’t like to accept repeat data as a new datapoint

Alternatively I may need to change my ESP32 over and make a new one dedicated to this one purpose (and leaving PVOutput on the other. Then instead of it sending 5 minute data of usage solely in that time window having it do that with a running total instead and having it set to periodically reset. That way if it then misses a entry it will just be added to the next one, whilst not ideal it gives more accurate data in the overall dataset

Data back to looking I feel clean. Think the solution was few issues

  1. Needed to set utility meter to Delta Value
  2. Also needed to adjust the mqtt value to have the argument “force_update: true” which enables multiple values of the same value to be recognised as individual values instead of just a single value.

Will reassess in a few days but think its working now as expected.