Calculate rain volume during past 12 or 24 hours

I have a Popp rain sensor which displays the accumulated rain volume since it was included in the system. I have included the sensor in the recorder and I can see a history chart of the value by clicking the sensor.

What I would like is to extract is the accumulated rain volume during the last 12 or 24 hours, i.e. rain_volume(now) - rain_volume(now - 12 hours).

How do I achieve this in Home Assistant?

have a look at the stats sensor


then you can create a template sensor that does just what you want:
rain_volume(now) - rain_volume(min)

Thanks, I’ll try that!

I would just use the history component and look up the state in the past.

http://192.168.0.150:8123/api/history/period/2018-09-10T00:00:00?filter_entity_id=sensor.3rd_floor_thermostat_target

https://developers.home-assistant.io/docs/en/external_api_rest.html

That’s what the statistics sensor does without all the work.

1 Like

Except I think the max_age of the stats sensor is broken.

I was getting odd values when trying to find the maximum value of one of my sensors over the last 8 hours. Then I found this: https://github.com/home-assistant/home-assistant/issues/11801 looks like a fix has fallen off the end of the to-do list.

Yes I’ve been using the history stats sensor to count the number of times a door/window sensor is activated with the idea that I can (eventually) have an idea of when the batteries will run out. I found it unreliable and I was using count.

I’m now resorting to incrementing an input_boolean for every sensor and a bit of a kludge (which I haven’t quite got working - see Increment an input_boolean depending on trigger.entity_id? if you’re interested)

The history statistics sensor is a different component than the statistics sensor.

Sorry, yes I meant the statistics sensor. :roll_eyes:

I love when an old post helps me solve a problem. I’ve been trying to figure this out for weeks. Thanks to @lolouk44 for your helpful idea!