Update "number" helper when no update since 2 minutes

Hello,

So I have a “number” helper that gets incremented by 10 everytime I get an action from sensor (1clic = 10L gas).

That works, I have a nice graph showing the “index” increase throughout the day.

The helper gets updated only when there’s an action from the sensor though…

I want to see the instantaneous usage using a derivative sensor, but since the helper does not get updated when the boiler stops it shows the last usage until the boiler restarts.

I tried to create an automation that would update the helper with the same value every 2 minutes if the last action was more than 2 minutes ago… but the helper does not update (edit: if the value is exactly the same) even if I do it manually…

Since a picture is worth 1000 words :

alias: Ikea-gaz_counter-2
description: ""
trigger:
  - platform: time_pattern
    hours: "*"
    minutes: /1
    seconds: "0"
condition:
  - condition: template
    value_template: >-

      {{ as_timestamp(now()) -
      as_timestamp(states.input_number.gaz_counter.last_updated) > 120 }}
action:
  - service: input_number.set_value
    data:
      value: "{{ states('input_number.gaz_counter') | int + 0 | int }}"
    entity_id: input_number.gaz_counter
mode: single

I tried with value: "{{ states('input_number.gaz_counter') }}" first but it did not work either that’s why i added the int + 0 hopping it would work…

Any idea would be great !

Thanks in advance !

PLs add your automation…

I edited the post with it

Try the homeassistant.update_entity service instead.

I doubt it will work as the value has not changed, but worth trying to make sure.

action:
  - service: homeassistant.update_entity
    entity_id: input_number.gaz_counter

I already tried before, and retried again just in case, and it does indeed not work.
Thanks anyways.

I also tried using a counter and resting it to 0, but the derivative goes negative (as it should) when it happens…

I nearly suggested adding a small random number periodically, but you can’t do that to a counter.

You could make a triggered template sensor that does this (periodically adds a small random number to the counter value) and use that in your derivative.