Help with Derivative Sensor

I’m working on an automation that grabs the temperature of a room sensor, then waits 45 minutes and pulls the temperature again. I want to see if the temperature is Rising, Falling, or hasn’t changed (within that time period) then take certain actions based on the result.

Someone suggested a derivative sensor/helper which I setup, but I’m not confident on how to use it… or if there’s an even easier solution I’m open to test with another method.

Suggestions for me?
//Brew

Are you having a specific issue or question? A derivative sensor seems like a great fit and is what I would try first.

The derivative sensor will report a value that is the rate of change of the temperature sensor you selected. During the setup if you chose no metric prefix and a time unit of hours, then the derivative sensor’s value will be “degrees per hour”. So if the derivative value is positive, the room temperature is rising. If it’s negative, it’s getting colder. If it’s zero, it’s not changing.

I’m not sure if the “bug” has been fixed yet but the last I knew the derivative sensor as implemented in HA will never be zero.

The issue has been 50% resolved. If the source sensor continues to report the same value, the derivative sensor will now report a zero value. This was changed about two months ago with the
state_reported PR.

If the source sensor stops reporting when it is not changing, the derivative sensor won’t update and hence won’t report zero. This will be fixed if the
max_sub_interval PR gets completed and merged.

1 Like

With 45 minutes in between measurements, you’ll have very little measurements for the derivative though. The temperature could have risen, fallen and stayed the same, all of them in that period.

Does the sensor really have this little updates and changes, or were you just planning to look for changes very infrequently? Imagine fictive temperature changes like a sine wave. If you take two random points on the wave, and look for the difference between those points, would it give a true representation of rise or fall? It would not. So unless the thing you are measuring has very, very slow temperature changes, 45 mins between measurements won’t tell you a thing.

If you open a window in a room, temperature changes could go quickly. Same if you turn on the heat, or the sun pops in.

So after reading all of this… The derivative sensor is calculating constantly using the temperature entity I configure it for… The derivative sensor itself doesn’t have a “time frame”. If the value is positive, the room is warning, if it’s negative, the temp is falling. That’s really just good enough for me at this point.

Correct?

Yes. And since room temperatures usually fluctuate enough, you don’t have to worry about any bugs/shortcomings of the derivative sensor. It will work fine on any decent room temperature sensor.