Yaml victron total energy

Hello everyone, for a long time I have been using various counters with esp32. that monitor the energy and various parameters in my victors. In the past the total energy meter has always worked, but now it randomly resets itself and I don’t understand why.

- platform: integration
    name: "Solar Energy Produced"
    sensor: pv_power
    unit_of_measurement: "Wh"
    time_unit: h 
    accuracy_decimals: 2
    state_class: total_increasing
    device_class: energy

pv_power is not an entity id. Should be source: sensor.pv_power

See: https://www.home-assistant.io/integrations/integration/#source

Thanks Tom, so you say to replace pw_power with sensor.pv_power ?

And the option should be

Ok I m retry

INFO ESPHome 2025.3.3
INFO Reading configuration /config/esphome/victron20.yaml...
Failed config

sensor.integration: [source /config/esphome/victron20.yaml:87]
  platform: integration
  name: Solar Energy Produced
  
  IDs must only consist of upper/lowercase characters, the underscorecharacter and numbers. The character '.' cannot be used.
  sensor: sensor.pv_power
  unit_of_measurement: Wh
  time_unit: h
  accuracy_decimals: 2
  state_class: total_increasing
  device_class: energy

I’m probably wrong, but I seem to have understood that I only had to varysensor: sensor.pv_power

Ignore everything I said and go back to your original config. I missed that this was the ESPHome component and assumed it was the home assistant integral component as you placed your post in the forum configuration category and I did not read close enough.

Moved to ESPHome category.

It looks like this sensor doesn’t automatically save to flash.

restore (Optional, boolean): Whether to store the intermediate result on the device so that the value can be restored upon power cycle or reboot. Warning: this option can wear out your flash. Defaults to false.

I will guess that your device is “randomly” resetting and that is causing the value to reset. Logs will tell you if there is a correlation with reset of the sensor and device restart.

Thanks Neel, then I can tell you that the sensor that displays the history of the accumulated energy sometimes behaves as you say. During the 24 hours the meters restart and unfortunately sometimes this too. I have two victors and the behavior is the same. I find the yaml file on git and in the coming months I could define it more stable. Furthermore , I wonder , given that in the victron the basic meter relating to the energy produced in life is always correct , was there a directive that goes to the reading of that value ? Ex. if it is reset it would be enough for HA with esp32 to read the total value of energy produced by the victron since it was first put into production.
Try looking at the attachment to see an example of what happened!

is the reference for restore, which is likely required to preserve the value over a reboot

Have you added the uptime sensor?

I use it to track when my device restart.

Yes, I have not changed this parameter, however it is what I have been looking for a long time, that is, a parameter that does not allow zeroing. In the specific case of accumulated energy, bringing it to zero.

So to be able to intervene only on the total energy meter, I would have to modify only the ESP file and with which directive. ?

I am very confused by your responses. They do not seem to answer the questions I asked. So let’s try again.

  1. Did you add an uptime sensor? (yes or no)
  2. Does the uptime sensor show the device restarted (uptime resets to zero)? (yes or no)
  3. Are the times the energy total resets the same as when the uptime resets? (yes or no)

1No I didn’t add an uptime

2 no sensor.

3 I notice that the meter is sometimes reset together with the meter of the daily energy produced, but this does not always happen. Sometimes the total energy remains unchanged and is therefore added up the next day.
To make you understand today, for example, he did not reset the total counter but the daily one.


I apologize for the translation, and especially for your patience.

add the uptime sensor

see if there is a correlation with uptime being reset and the Integration sensor being reset

1 Like

ok Neel , thank you . At the moment on the fly I installed uptime sensor on another esp32 device for testing and it appears as in the image. So as soon as I change the esp32 of the victron, so if you reset the total counter as it sometimes does, what value should I read on uptime? Thank you very much at the moment.

The uptime sensor shows how long it has been since the device restarted.

I suspect that the issue you are seeing with the total counter resetting is because the device is restarting (unexpectedly) and you do not have the integration sensor configured to save its value. So, when the device restarts your counter resets. The uptime sensor will either show what I said is likely or that it is not correct. Without the data, it is just a guess/hunch.

Thanks Neel, but if as you say why the meter of the energy produced “today” does not reset but only the total accumulated one?
To make you understand how you can see from today’s graph at about 11 AM this happened, but the meter of the energy produced today continues to work, while the accumulated total has returned to zero.

It is a theory. It needs data to prove it one way or the other. You have data that suggests the theory is incorrect. You might be correct about that, in which case it will still be a mystery why the total sensor is resetting and someone will need to come up with a new theory.

Or, the uptime sensor might show (as the theory suggests) that the reset is causing the total sensor to reset. Then, a reasonable question might be why doesn’t the daily sensor reset. But, as long as it doesn’t, you might be happy enough never knowing.

Hi Neel, I have the first data and I think you were right. Look at the graphs


I think one of the two esp32 has restarted. I have a doubt, the two esp32 are fixed next to each other, so is it possible that being too close and having the wifi active they can be disturbed causing a reset?