Having yesterday's rain listed right under Rain Rate, Rain Today in the Current Conditions section

99 views
Skip to first unread message

Dale Reid

unread,
Jun 14, 2020, 4:04:32 PM6/14/20
to weewx-user
While yesterday's rain total isn't exactly a current condition, I would like to have the display page show the amount of rain from yesterday.

I know there are different ideas on when rain totals should zero out, but I'm asking for something slightly different, and for me, would add to the usefulness.

I'm thinking of the situation that often occurs when a storm series moves through, with say 1/2" or so of rain before midnight, then even more after midnight, say 1/4" in the new day.

It is really all the same storm, and not worth the logic to have it done automatically, but to glance at the summary page and see today's rain is 1/4", when the storm total is 3/4" would really work better to list what yesterday's rain was right after today's total so far.

I don't know how the inner structure of WeeWx works, so one way would be, if the variable is available, to have today's rain total saved at midnight to a new variable called YesterdayRain, then zero the today's rain variable.  It seems simple,but I don't know if the ordinary user would have the ability to modify WeeWx to make this work.

Is there already this Yesterday's Rain value available, and if so by what name?

Can we add a display line to the skin that generates the standard page, or not?

Another way to do it would be have the database total up yesterdays rain with a date range but this seems to be a lot of work, involve accessing the data base for no added reason, if one just had the YesterdaysRain already stored.

Just some thoughts. So far this is the only tweak I've thought of that WeeWx doesn't seem to already do.  Python is really beyond my current skills, and while I know some might whip this together in short order with their programming knowledge, I don't know how to find the stored variables already, or fiddle around with it and screw something up.

Dale


(There are no error logs, there is nothing to submit, other than my idea).


Message has been deleted

Jeff A. D.

unread,
Jun 14, 2020, 7:24:47 PM6/14/20
to weewx-user
I haven't tried it, but form the docs, http://www.weewx.com/docs/customizing.htm#general_aggregation_periods, I would think something like this would work.  If you were using the Seasons skin I would add it to "current.inc".
   <tr>
       <td class="label">$obs.label.Rainfall Yesterday</td>
        <td class="data">$$day($days_ago=1).rain.sum</td>
</tr>

Paul McGeorge

unread,
Jun 14, 2020, 7:43:59 PM6/14/20
to weewx-user
In addition to the $day($days_ago=1).rain.sum you can also use $yesterday.rain.sum if you just want yesterdays rain

or perhaps you really want to know if it rained while you were asleep and would prefer the last 24 hours in which case you can use the Span function like this  $span($hour_delta=24).rain.sum  where delta is the number of hours...

Since Weewx stores everything in a Database lots of presentations are possible...

Dale Reid

unread,
Jun 14, 2020, 10:24:55 PM6/14/20
to weewx-user
Thank you for the examples and ways to accomplish this.

I assume that by trying it, it will not corrupt the data base, since this is a 'read' type function, correct?  If I screw it up, then no harm done, just remove this code or whatever I insert and then restart WeeWx?

Secondly, just for my generation of old timers, I assume that this code will trigger an aggregation from the data base, for instance, by going through all the records for yesterday, totaling the rain, but doing so every time WeeWx generates those HTML images to post to my server?  I am from an era where CPU cycles were expensive and slow.  Knuth suggested if there were a string that wouldn't change in a loop, to calculate it outside the loop and save it as a constant value and reference that.  And on those installs of WeeWx running on RaspPi machines, there is the suggestion that hitting the database a lot will shorten the life of the SD cards which serve as their mass storage.

Hence my initial suggestion to take the value of the rain, save it, and just call in that number (which will remain unchanged into the future) instead of accessing the database, and totalling the rain each and every time.

If I can get the suggested way working, I'll be grinning a lot.  The next would be to figure out the total rain and save that, but is that level of monkeying around with WeeWx permitted, or is the summary of yesterday's rain the only way to accomplish this, even if it does mean all the access and work each time?  Just curious. 

And thank you all for the suggestions.
Dale

Paul McGeorge

unread,
Jun 15, 2020, 7:47:21 AM6/15/20
to weewx-user

Correct just reading from the database won't hurt anything.  The code will trigger a Data base read and in this case a sum of the data for yesterday.  From a CPU perspective it seems to have little effect on the Rpi 3 I use, I actually pull rain for the last 24 hours, last week, and last month.

As for the SD Card life I can't say much since I use an old spinning USB Hard drive to store my data, but data reads are not very hard on an SD it is the writes I believe are the issue.  If you search through the posts I think you'll find info on SD card life, plus ways to minimize the writes.

It may be possible to run a query on the DB at say 5 past midnight and save the data to a text file or a DB record and then not have to run the query every report cycle, but it beyond what I have done....


Dale Reid

unread,
Jun 22, 2020, 10:42:04 PM6/22/20
to weewx-user

Just a follow up note to thank Paul and others for information and after I added the two lines of instructions, plus had rain two days in a row, found things work very well.  Thanks.  Dale

Reply all
Reply to author
Forward
0 new messages