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.

There was a PR that looks like it would resolve this issue, but was closed as stale for sitting too long without attention: Fix derivative integration sample leave time window by FlorianOosterhof · Pull Request #110689 · home-assistant/core · GitHub

of course…

Hello, I’m also having this issue and it is really annoying to have a false instant consumption value when the indexes from which this is calculated do not increase (which means instant consumption should be 0)

FlorianOosterhof apparently you made some work on this in your commit that was closed, could you resubmit it if it works ?

Or if it works we could use it as a custom integration to replace the faulty built-in integration.

I’m amazed that this is still an issue after all this time. And apparently if someone submitted a fix for it.

There was an architecture change to add a last_reported property and state_reported event, and so the devs are likely waiting for a PR which utilizes that property. It would be essentially identical to the PR that was just merged in 2024.7 to do the same thing for the Riemann Sum integration.

I think Florian’s PR may have addressed some other issues also, so he’d have to modify that PR to utilize the new event while keeping his other improvements.

Edit: there was also another PR merged in 2024.7 for the Riemann sum integration to add the max_sub_interval configuration option. We need that change as well for the derivative integration.

I have exactly this same issue

  • platform: derivative
    source: sensor.water_l_izar
    name: “Water flow (L/min) Izar”
    unit_time: min
    unit: “L/min”
    round: 2
    time_window: “00:05:00”

The water meter stops and the sensor still shows the water flow .

This has been solved. The PR in the post right before yours was merged. The docs describe how to use max_sub_interval:

Thanks.
And 3 months ago I wouldn’t have been able to do anything about it :slight_smile:

it still doesn’t work properly

  - platform: derivative
    source: sensor.water_l_izar
    name: "Water Flow (L/min) Izar"
    unit_time: min
    unit: "L/min"
    round: 2
    time_window: "00:10:00"
    max_sub_interval: "00:01:00"

Take a look at your post again:

  • How is anyone supposed to know what your screenshot is showing? What are the two entities that were graphed, and what is the y-axis scale for each?
  • Can you describe what you expected instead of “it isn’t working”?
  • Can you describe what you’ve done after changing the YAML? Did you reload the integration entities, or reboot HA?
  • What version of HA are you using, and do you have any errors in the logs that are relevant?

I use HA 2025.9.3
Full restart after change config yaml.

Upper chart shows the water meter
Lower chart is water flow (for this senor derivative)

Not working = does’t go down to 0 when the water meter does not move for a long time.
Water flow changes only when water meter is works.

The values ​​on the Y axis don’t matter much. You can see that it doesn’t go down to 0.