Wrong data on energy

… or whatever recorder purge_keep_days is set to.

If you wanted to fix the error for the Energy dashboard, it should be fixed now.
If you wanted to fix regular History Graph cards on your custom dashboards, I don’t think that’s currently possible without manually changing the database. However, as Tom wrote, these graphs can only show the last 10 days by default.

I’m guessing they are using the default. They don’t seem the type to set it to 40000 days, as I was horrified to see on the forum recently.

1 Like

I just thought that explaining why the state history would be removed after 10 days might help with understanding the whole system, especially the difference between history and long-term statistics.

Let me guess. The person who set it to 40000 days complained about database size in the hundreds of GB, or worse, database corruption…

1 Like

Backups were failing.

I would like to correct this data, but honestly I don’t know what to do. the data are few because I have recently mounted the system and the purge is not yet set (I’m afraid of losing the energy data)

  1. The purge interval is 10 days by default, so if you have not set it, that is what it is set to.
  2. Energy data is part of LTS (long term statistics). LTS are kept forever.

That is why a tool is needed to edit bad statistics. But the state data will eventually purge so you don’t need to worry about it.

1 Like

at this point I wait for the automatic purge and everything settles by itself

Sorry im confiused. i explane my cfg:

i have an inverter goodwe em series and expose the data of battery, solar panel and more in watt, when battery is in discharged mode the valui is positive, when in charged mode the value is negative an this for all sensor.

now i converte de w in kWh with rienmann integration:

#######FOTOVOLTAICO
 #BATTERIA
  - platform: integration
    source: sensor.battery_power ###sensor from inverter
    name: FV batteria power
    unit_prefix: k
    round: 2
    method: left
#PANNELLI
  - platform: integration
    source: sensor.pv_power ###sensor from inverter
    name: FV pannelli
    unit_prefix: k
    round: 2
    method: left

  - platform: integration
    source: sensor.on_grid_export_power ###sensor from inverter
    name: FV energie
    unit_prefix: k
    round: 2
    method: left
    
  - platform: integration
    source: sensor.house_consumption ###sensor from inverter
    name: FV consumo casa
    unit_prefix: k
    round: 2
    method: left

and the i create a template for converting valui for energy dashboard

  - name: FV batteria scarica ####discharged mode
    state: >
          {% if states ('sensor.fv_batteria_power') | float > 0 %}
          {{ (states('sensor.fv_batteria_power') | float) *1 }}
          {% else %}
            {{0}}
          {% endif %}
    unit_of_measurement: 'kWh'
    device_class: energy
    state_class: total_increasing

  - name: FV batteria ricarica ###charged mode
    state: >
          {% if states ('sensor.fv_batteria_power') | float < 0 %}
          {{ (states('sensor.fv_batteria_power') | float) *-1 }}
          {% else %}
            {{0}}
          {% endif %}
    unit_of_measurement: 'kWh'
    device_class: energy
    state_class: total_increasing
  
  - name: FV prelievo  ###buy energie
    state: >
          {% if states ('sensor.fv_energie') | float < 0 %}
          {{ (states('sensor.fv_energie') | float) *-1 }}
          {% else %}
            {{0}}
          {% endif %}
    unit_of_measurement: 'kWh'
    device_class: energy
    state_class: total_increasing

  - name: FV immissione ##sell energie
    state: >
          {% if states ('sensor.fv_energie') | float > 0 %}
          {{ states('sensor.fv_energie') | float}}
          {% else %}
            {{0}}
          {% endif %} 
    unit_of_measurement: 'kWh'
    device_class: energy
    state_class: total_increasing

now i see in the dashboard the energy use from battery in 0, but last 3 hours i use them.

my doubt is, being kwh and maybe it passes the value from positive to negative I don’t actually know how much it is doing, I imagine that I produced 3kwh of these 1 I consume and 2 it takes from the battery (here I have a negative sensor) in the next hour I don’t produce anything and I take 2 from the battery, the sensor converted into kwh theoretically goes to 0 because I have the -2 of the recharge and 2 that I have consumed. at this point it is let’s say not very useful, do you think it would be better to take the raw sensor in watts from the inverter via template and convert the template into kwh and not the inverter sensor?