Need help calculating the difference for a sensor compared with an older value for the sensor

Hi!
I have a sensor (shows total precipitation, rain) that is increasing over time as it rains.
I would like to calculate the rain for today. E.g. current value minus the value at midnight. Is this possible to do in Ha and if so how do I go about it?

Appreciate all tips and pointers on how to do it or where to get more information!

/Anders Ripa

That is done with a template. Make a triggered template sensor to store the number just before midnight. then you can use that in another template later.

No need for trigger based template sensors and extra helpers. A utility meter helper does exactly that. It is not just for energy, it can be used on any total.

1 Like