Sensor Counter

Hi,

I have a sensor which gives me the number of burnt pellets from my stove since the beginning of its use.
entity_id: sensor.poele_pellet_qt_used
I would like to create a counter to trigger a notification when I approach the 15 kg burned.
I would also need a button to reset the counter when I refilled my stove

How can I make queries on history database or must I use InfluxDB?

Here is a draft (not functionnally)

automation:
  - alias: 'Current Conso'
    trigger:
      platform: state
      entity_id: sensor.poele_pellet_qt_used
    action:
      data_template:
        entity_id: sensor.poele_current_conso
        value: '{{ states.sensor.poele_current_conso.state }} | int + 1'
  - alias: 'Reset Current Conso'
    trigger:
      platform: state
      entity_id: switch.poele_reset_current_conso
    action:
      data_template:
        entity_id: sensor.poele_current_conso
        value: 0
  - alias: Send stove alert
    trigger:
      platform: numeric_state
      entity_id: sensor.poele_current_conso
      above: 15
    action:
      service: notify.pushbullet_notifier
      data:
        title: Home Assistant
        message: "Stove tank soon empty"  

how can I create entity_id: sensor.poele_current_conso sensor ?

Any ideas ?

…I think is best to create a component for the brand my stove

thks a lot

I found a solution with counter.py from https://github.com/Tommatheussen/Home-Assistant-Configuration/blob/master/custom_components/sensor/counter.py

thxs to @tmatheussen