Calculate value only after another value changed

Hi all,

I like to calculate the current power usage, it works now but there is one value that only changes every +/- 5 minutes. The other value in that calculation changes constantly and that gives an unreliable and unlogic result.
So I like to change the calculation in such way that when the value that changes about every 5 minutes that at that moment a new value is shown in the dashboard.

Sensor p1_total_h6 and p1_total_h2_4 are the values that only change every +/- 5 minutes.
sensor.p1_meter_5c2faf09694a_active_power and sensor.p1_meter_5c2faf0af64c_active_power are about real time.

Is there a way to do this?


  - name: "p1_total_h6"
    unit_of_measurement: 'kWh'
    state: '{{ states("sensor.p1_meter_5c2faf09694a_active_power") |float(0) | round(0) + states("sensor.h6_pv_now ") |float(0) | round(0) }}'
  - name: "p1_total_h2_4"
    unit_of_measurement: 'kWh'
    state: '{{ states("sensor.p1_meter_5c2faf0af64c_active_power") |float(0) | round(0) + states("sensor.h2_4_pv_now ") |float(0) | round(0) }}'

Believe you want “trigger based template sensors”