Formatting stats.py extension

50 views
Skip to first unread message

Mike Revitt

unread,
Mar 16, 2020, 10:35:10 AM3/16/20
to weewx-user
I am successfully running the stats.py extension as detailed here http://www.weewx.com/docs/customizing.htm#defining_new_tags and am now trying to format the output.


The output is displayed in statistics.html using the syntax shown below

<table>
    <tr>
        <td>Maximum temperature to date: </td>
        <td>$alltime.outTemp.max</td>
    </tr>
    <tr>
        <td>Minimum temperature to date: </td>
        <td>$alltime.outTemp.min
    </tr>
    <tr>
        <td>Rain over the last seven days: </td>
        <td>$seven_day.rain.sum
    </tr>
</table>

and I created 2 new tags in weewx.conf expecting this to change the format as shown below

            [[[[TimeFormats]]]]
                
                hour        = %H:%M
                day         = %H:%M
                seven_day   = %H:%M on %a
                week        = %H:%M on %a
                month       = %a %d %H:%M
                year        = %a %d-%b %H:%M
                rainyear    = %d-%b-%Y %H:%M
                alltime     = %A %d-%b-%Y %H:%M
                current     = %a %d-%b-%Y %H:%M
                ephem_day   = %H:%M
                ephem_year  = %d-%b-%Y %H:%M


However whilst the day, week and year tags are being used seven_day and alltime are being ignored. The output that is using used is the current format.

Anyone know what I am doing wrong?

Thomas Keffer

unread,
Mar 16, 2020, 11:13:26 AM3/16/20
to weewx-user
For this to work, you would need to specify your new 'contexts' in the constructor to TimespanBinder. Something like this (NOT TESTED):

        # First, create TimespanBinder object for all time. This one is easy
        # because the object timespan already holds all valid times to be
        # used in the report.
        all_stats = TimespanBinder(timespan,
                                   db_lookup,
                                   context='alltime',
                                   formatter=self.generator.formatter,
                                   converter=self.generator.converter,
                                   skin_dict=self.generator.skin_dict)       # 4

See if that helps.

-tk



--
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+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/weewx-user/9ec3620f-4154-4506-9194-4b880a318776%40googlegroups.com.

Mike Revitt

unread,
Mar 16, 2020, 11:43:24 AM3/16/20
to weewx-user
That works perfectly thanks Thomas, now I just need to get the cron job working properly
To unsubscribe from this group and stop receiving emails from it, send an email to weewx...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages