Derivative sensor doesnt update when no value change

Hi,
I created a derivative sensor which derives my water counter sensor to see immediate water consumption in m3/hour.

It works,except one significant detail. Derivative sensor doesnt update when there is no update in the source sensor (which is expected behavior).
The result is the derivative never shows zero value. And this is a problem.

So my problem is that I need to update the source sensor periodically to trigger derivative sensor recalculation. I tried the trick with adding an attribute to the source/template sensor, but it does not trigger update.

Any suggestions appreciated, David


Your attribute template only generates values between 0 and 5 so might this be the problem? I do know this works as I’m using this successfully in several places (not with derivative but with integration though).

Why not just use “{{ now() }}”?

Edit: wait! Do you have a trigger on your template-sensor? Won’t update otherwise. You should be able to see the result of you efforts in the “last_updated” attribute of your template-sensor in devtools.

I am having a similar issue with the derivative sensor that i have for my gas meter. Keen to know how to resolve this.

There has been a change to this. I’ve had my gas consumption meter set up like this for a few years and it broke some time ago:

- platform: derivative
  name: Hourly Gas Consumption
  source: sensor.gas_consumption
  time_window: '1:00:00'

This is either a known issue or an intended behavior, depending on your perspective.