Template sensor get reset twice a day

Hello,

I hope someone can help me with my problem. I have created a template that sum up three sensors for my energy dashboard (see template below).
Now I have the problem that this sensor (group) gets a reset twice a day and my energy dashboard jumps from 0 to the latest value. Happens every day between 8PM-9PM and 4AM-6AM. I than manually remove this values in the statistics and everything is fine till the next day or evening.

I tried the ‘availability’ option of the template in different ways but without success. Did someone have the same problem and a solution for it?

Here are the templates which I used without success.

  - sensor:         
      - name: pv_production_total
        unique_id: "PVProductionTotal(kwh)"
        state_class: 'total_increasing'
        unit_of_measurement: 'kWh'
        device_class: 'energy'
        state: >
          {% set l1 = states('sensor.victron_pvinverter_l1_energy_forward_total_20') | float %}
          {% set l2 = states('sensor.victron_pvinverter_l2_energy_forward_total_20') | float %}
          {% set l3 = states('sensor.victron_pvinverter_l3_energy_forward_total_20') | float %}
          {{ (l1 + l2 + l3) | round(1, default=0) }}
        availability: >
          {{ states ('sensor.victron_pvinverter_l1_energy_forward_total_20') not in ['unknown', 'unavailable', 'None']
               and
             states ('sensor.victron_pvinverter_l2_energy_forward_total_20') not in ['unknown', 'unavailable', 'None'] 
               and
             states ('sensor.victron_pvinverter_l3_energy_forward_total_20') not in ['unknown', 'unavailable', 'None'] }}

and some other availability part

        availability: >
          {{ states ('sensor.victron_pvinverter_l1_energy_forward_total_20')| is_number and 
             states ('sensor.victron_pvinverter_l2_energy_forward_total_20')| is_number and 
             states ('sensor.victron_pvinverter_l3_energy_forward_total_20')| is_number }}

I also tried to add all three sensors separately to the energy dashboard but the presentation is not really good.

Thanks for your help

Can you show the history graph for the reset of one of the source sensors?

You mean this?

Yes exactly that. They are resetting to 0 in one step, so this availability template should fix it:

        availability: >
          {{ states ('sensor.victron_pvinverter_l1_energy_forward_total_20')|float(0) != 0 and 
             states ('sensor.victron_pvinverter_l2_energy_forward_total_20')|float(0) != 0 and
             states ('sensor.victron_pvinverter_l3_energy_forward_total_20')|float(0) != 0 }}

Thanks a lot for the quick help Tom.Looks like I was very close to solving the problem. by my self :smiley: .
I will test your template. Hopefully it works.

Will let you know tomorrow is the fix is working :slight_smile: