How to create total increasing from binary_sensor

hello there,
I’ve got a binary_sensor which indicates my oilheating is on. The burner consumes 2.84 liters per hour on.
So I can find the time the burner is on today via history stats.

  - platform: history_stats
    name: "Brennerlaufzeit heute"
    entity_id: binary_sensor.brennerstatus
    state: 'on'
    type: time
    start: '{{ now().replace(hour=0).replace(minute=0).replace(second=0) }}'
    end: '{{ now() }}'

and from this i can do the amount oli consumed today:

      oelverbrauch_heute:
        friendly_name: "Ölverbrauch Heute"
        unit_of_measurement: 'l'
        value_template: "{{ states('sensor.brennerlaufzeit_heute') | float * 2.84}}" 

What I wanted to do now is a total_increasing sensor. I tried by finding the total time the burner is running, but i can’t figure out a good way. at he moment I’m putting the value of oil burned at the end of any day into a variable, and then adding this to the daily value, but this causes values jumping around midnight. Something smooth would be nice. And next Up I’d like to be able to manually reset this every about 2 years… but then again most likely the heating will be changed to a heatpump in the next three years anyways.
Here’s what i tried:

automation:

- id: set_total_Oil
  alias: set total oil
  description: ''
  trigger:
    platform: time
    at: "23:59:59"
  action:
    - service: input_number.set_value
      data:
        value: "{{(states('sensor.oelverbrauch_heute')) | float }}"
      target:
        entity_id: input_number.oil_today
    - service: input_number.set_value
      data:
        value: "{{ (states('input_number.oil_running_total')) | float + (states('input_number.oil_today')) | float }}"
      target:
        entity_id: input_number.oil_running_total
    - service: input_number.set_value
      data:
        value: "0"
      target:
        entity_id: input_number.oil_today

Would appreciate any help
Thanx

Any Ideas here, vor hints were I could search?

This might help maybe? You can ignore the part about breaking out a sensor.
I am only tracking the sensor over 12 hours, but it’s my understanding that you should be able to track for longer.

Couldn’t you just create a trigger based template sensor with a constant value of 2.82, when the heating is on, and 0 when it’s not?
Then you could create a Riemann integral Sensor based on this to calculate the amount of oil used.

Just make sure that you add time pattern trigger and an attribute like a “timestamp” to the template, that changes regularly to force updates of the Riemann sensor.

Hello @blubbel42,
have you found a solution to this issue?
I face the same challenge as you and have no plan :wink:

hello,
no, i never really found a good solution. Though i must say that i have not been working much on this lately. Too much other things in life going on.