Rain for last x days

Because through the day when it is raining the total rain value keeps changing. Lets say it goes 1, 2, 3. The statistics TOTAL which is what I am interested in would be 6 (3+2+1 with a count of 3) when I actually want it to be 3. So I wait until just before midnight, which is when my weather station rain fall amount resets, and update input_number.rain_today_holder which then causes a single change to be recorded by the statistics sensor. I am thus attempting to have the statistics sensor only get one value per day and have a max days of 4 thus giving me total of last four days.

If there is a better way to do this I am all ears! :slight_smile:

There’s a max_value attribute of the statistics sensor that will show you the total rainfall for the sample period. The only issue is that the statistics sensor will give you stats for the last 4 days before now, not calendar days (i.e.if it is 3pm now the stats will extend to 3pm four days ago). No it wont. Because the sensor resets at midnight.

So your way is best.

The statisitics sensor updates whenever the monitored entity updates. Unfortunately that includes restarts.

I tried a bunch of ways to get this working, and ultimately i found the best way was to write the data to a database (mysql) outside of HA, and then using an sql sensor present the data to HA.

Originally i rolled my own code to monitor the MQTT topics coming out of weewx, but I have since moved it to a NodeRed flow.

Means the database is always up to date, data persists across reboots etc.

OK thanks. I will just have to put up with it then, As my system matures I am restarting less and I just this minute read how to get the advanced options for reloading without restarting so that will help!

Thanks. I am using MariaDb as part of Home Assistant so might be able to use that if my current approach remains problematic.

I think this, when developed, should be called the Eeyore sensor :slight_smile:

This is how I am attempting to do it. I’m only really interested if it rained heavily the day before, so I just have an input Boolean in Home Assistant ( automations/helpers/add helper/toggle) for yesterday’s rain, and one for today.

It checks just before midnight to see if it’s been raining that day, and again in the morning just before the irrigation comes on.

EdIT: there was a flaw in my logic in the deleted post, but this seems to work well.

This is some code from my own project which calculates a weighted total for rain and a 5 day moving temperature average. From here it determines a percentage increase or decrease for the irrigation time. Uses data from wunderground.com which is from my own PWS, pushed and retrieved by the wunderground integration. However, have since moved on to a new PWS which can push to my own NAS. Here it feeds a mysql db and with the sql integration creates the equivalent sensors in HA.