Hi,

What you really need to do is to create some new tags that you can use in 
your report template. This can be done in a number of ways, for simple 
cases, such as 'what is the current air density' you could do this with 
some in-line python code in the template. For more advanced cases, for 
example those where you need to query the database, this is usually best 
done through a Search List Extension (SLE). SLEs are the mechanism 
available for user's to extend the search list that is used by weeWX and 
the Cheetah template engine to produce reports. You can read about some of 
the basics of SLEs in the defining new tags 
<http://weewx.com/docs/customizing.htm#defining_new_tags> section of the 
Customization 
Guide <http://weewx.com/docs/customizing.htm>.

Assuming you are keen to go down this path, the example SLE in the above 
link should give you most of what you need to know/do, where you will 
depart from the example is the calculation of the timespan on which to base 
your stats for your day last year. To develop an SLE that will make 
accessible statistics for this day last year one approach might be to:

   1. Calculate timestamps for the start and end of the day one year ago. 
   In an SLE timespan.stop will hold the timestamp of the report so that 
   effectively gives you 'now', so you just need to go back a year and get a 
   start of day and end of day timestamps. Hint, have a look at 
   archiveDaySpan() in weeutil.py. Remember you will need to cater for 
   February 29 in your calculations.
   2. Once you have start and end of day timestamps you can create a 
   TimeSpan object from them (refer to weeutil.py again).
   3. Then you can get a TimeSpanBinder object based on your newly created 
   TimeSpan object. If you are keen, look through tags.py to learn how a 
   TimeSpanBinder works.
   4. Then just 'return' your TimeSpanBinder object in a list of 
   dictionaries (look at #8 and #9). If you use a contruct like:
   
today_last_year = TimeSpanBinder(.....)

search_list_extension = {todaylastyear: 'today_last_year'}

then in your template you will be able to use

$todaylastyear.outTemp.max

to display the maximum temperature on this day last year.

That is the hard bit done, the rest is just making sure you new tags are 
available to your template and then using them in your template. Everything 
you need for this you will find in the defining new tags 
<http://weewx.com/docs/customizing.htm#defining_new_tags> section of the 
Customization 
Guide <http://weewx.com/docs/customizing.htm>.

Have a good read of the defining new tags 
<http://weewx.com/docs/customizing.htm#defining_new_tags> section of the 
Customization 
Guide <http://weewx.com/docs/customizing.htm>, in fact having a look at the 
Customizing 
templates <http://weewx.com/docs/customizing.htm#customizing_templates> 
section would probably help too. Also have a look through the pieces of 
code/files I mentioned and give it a go. Don't be afraid of coming back if 
you run into issues, trust me, the first one is the hardest and they get 
easier after that!

Gary


On Thursday, 2 February 2017 12:05:29 UTC+10, Thomas Carlin wrote:
>
> First I would like to thank TK and everyone else who has contributed to 
> this project.  It is a fantastic project, and great to see an active 
> community.  
>
> I have been playing with modifying the reports to fit my wants, and one 
> thing that I would like to do is be able to display historical records on 
> the reports.  On the daily, High's and lows this day last year, the 
> monthly, maybe averages from this month last year, etc.  I have spent some 
> time searching the Group and the docs, but have not come up with much on 
> the topic.  
> Could someone point me in the right direction?
>
> For those who are interested, a little back story on my project:
> I have a Vantage Pro2, that I have cobbled together a wireless serial 
> relay using an ESP8266 chip (Look Ma, No wires!).  I didn't want my station 
> to be tied to a computer, and those Raspberry Pi's are so clunky!
> Largely, I used the information that was compiled by DeKay, using his USB 
> method, I simply adapted it to run over IP instead.  The project is still 
> in its infancy, but I hope to put some lipstick on this pig, and post my 
> progress somewhere that others may benefit from it.  
>
> It has only been running for a week or so at this point, but my station 
> can be seen here http://carlincomputing.duckdns.org/weewx/index.html
>

-- 
You received this message because you are subscribed to the Google Groups 
"weewx-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to weewx-user+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to