New problem with derivative sensor - always shows zero

Hello, I had configured derivative sensor and it worked fine until short time ago. Now it shows only zero. But I also have trigger defined on it and it works! By closer analysis I discovered that value of derivative sensor is updated correctly when value of base sensor changes, but then derivative sensor value immeditely drops to zero. It looks like derivative sensor is trying to read source sensor again and because it reads exactly same value, then it calculates that change is zero.

Source sensor is mqtt sensor that sends value once in 4 hours and sleeps in the meantime, so it does not send same value twice. Here is mqtt log:

Received 3:35:26 AM
QoS: 0
Payload: 151
Received 7:42:07 AM
QoS: 0
Payload: 150
Received 11:48:42 AM
QoS: 0
Payload: 385
Received 3:55:20 PM
QoS: 0
Payload: 218

Looking at values in influx they seem to be correct, so I suspect that problem is displaying the sensor in frontend.
image

What could be wrong?

Nothing. The derivative of a steady state is zero.

That is strange because it worked before. If state changes once in 4 hours, then the derivative sensor shown the difference for whole 4 hours until next state change. Now it jumps to difference momentarily and then drops to zero for 4 hours.

There may have been a bug fix applied recently. I do remember someone taking about this in the last couple of months.

I suggest you have a look at the GitHub repository for this integration to see what changes were made recently. Unfortunately I have no access to GitHub at the moment.

There’s a link to the source on the documentation page for this integration.

Very strange thing. The derivative sensor started to work after I made change in source sensor. It is esphome mqtt sensor that sends measurement and then sleeps for 4 hours. I removed this statement from the sensor definiton and now derivative sensor shows difference all the time:

I removed force_update: true and it is now working well