Odd behavior of statistics when summing up two sensors

Hi, I have two sensors providing peak and off-peak values
When I set them out in a statistics graph they exactly show as it is
However, if I add them up then statistics do (imo) odd things…does anyone maybe have an explanation?

Sensor 1

Sensor 2 looks the same only different kWh values

Individual stats graph
image

I created a sum of both

      - name: "Linky Energy Total"
        unique_id: Linky Energy Total
        device_class: energy
        unit_of_measurement: kWh
        state_class: total_increasing
        state: "{{ states('sensor.linky_bbrhcjb')|float(0) + states('sensor.linky_bbrhpjb')|float(0) }}"
        availability: "{{ is_number(states('sensor.linky_bbrhcjb')|float(0) + states('sensor.linky_bbrhpjb')|float(0)) }}"

and this looks like:
image

What it seems to do is to pick the meter value at points and then continues (as expected) with total increase and then jumps again…but not every day

Change this:

availability: "{{ is_number(states('sensor.linky_bbrhcjb')|float(0) + states('sensor.linky_bbrhpjb')|float(0)) }}"

To this:

availability: "{{ states('sensor.linky_bbrhcjb')|is_number and states('sensor.linky_bbrhpjb')|is_number }}"

Or, preferably, this:

availability: "{{ has_value('sensor.linky_bbrhcjb') and has_value('sensor.linky_bbrhpjb') }}"

Thanks, will try this out a bit, additional info…the 2 jumps you see are at around13:00 and around 20:00 …and I restart HA ervy dat at 01:00 …without jumps…hence I find this odd, might it be that the entity gets disconnected from the meter?

Not sure, your template sensor should update whenever either of the source sensors (linky_bbrhcjb or linky_bbrhpjb) updates.