weewx-historical

409 views
Skip to first unread message

Thomas Keffer

unread,
Mar 30, 2020, 7:36:33 PM3/30/20
to weewx-development
This is a new extension that nicely shows the power of the new XTypes extensions in V4.0.


It creates new aggregation types that allows you to use tags such as

<p>Max temperature for this day: $day.outTemp.historical_max in $day.outTemp.historical_maxtime.format("%Y")</p>

This would result in something like:

Max temperature for this day: 64.8°F in 2013

Probably only useful if your database covers many years. 

Tested on sqlite only. In theory, it should work on MySQL/MariaDB.

My intention is to eventually extend it so it will work for plots as well.



gjr80

unread,
Mar 30, 2020, 11:46:08 PM3/30/20
to weewx-development
Not sure I like where this whole Xtypes thing is going. I have a perfectly good SLE that does half as much as this with 50% more lines of code that I will now have to retire. :)

Gary

Thomas Keffer

unread,
Mar 31, 2020, 6:42:33 AM3/31/20
to weewx-development
On Mon, Mar 30, 2020 at 9:27 PM Praveen Chandrasekaran <pravee...@gmail.com> wrote:
Hi,

Can it also be used to give historical highs/lows for a month?

Regards,
Praveen

Not as written, but it would not be very hard to add that feature.

-tk

Thomas Keffer

unread,
Mar 31, 2020, 1:51:58 PM3/31/20
to weewx-development
I had forgotten that, in the absence of anything else, XType plot aggregations leverage individual scalar aggregations. So, to plot historical highs and lows, I didn't have to write any code, just get the skin.conf spec right. Using this:

[[[yearhilow]]]
  image_width = 800
  image_height = 500
  [[[[hi]]]]
    data_type = outTemp
    aggregate_type = max
    label = High
  [[[[low]]]]
    data_type = outTemp
    aggregate_type = min
    label = Low
  [[[[hist_hi]]]]
    data_type = outTemp
    aggregate_type =
historical_max
    marker_type = cross
    line_type = none
    label = Historical High
  [[[[hist_lo]]]]
    data_type = outTemp
    aggregate_type =
historical_min
    marker_type = cross
    line_type = none
    label = Historical Low Temperature

yields this. This is for 12 years of data.

image.png

On Mon, Mar 30, 2020 at 8:46 PM gjr80 <gjrod...@gmail.com> wrote:
Not sure I like where this whole Xtypes thing is going. I have a perfectly good SLE that does half as much as this with 50% more lines of code that I will now have to retire. :)

Gary

--
You received this message because you are subscribed to the Google Groups "weewx-development" group.
To unsubscribe from this group and stop receiving emails from it, send an email to weewx-developm...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/weewx-development/5f4aa21e-997c-4486-9ddc-cffb9b6433d7%40googlegroups.com.

Vince Skahan

unread,
Mar 31, 2020, 2:48:34 PM3/31/20
to weewx-development
On Tuesday, March 31, 2020 at 10:51:58 AM UTC-7, Tom Keffer wrote:
I had forgotten that, in the absence of anything else, XType plot aggregations leverage individual scalar aggregations. So, to plot historical highs and lows, I didn't have to write any code, just get the skin.conf spec right. Using this:
...

yields this. This is for 12 years of data.


You need to buy that guy who developed weewx a beer or two :-)

Very cool.  Can't wait to do the same with my data.

Hartmut Schweidler

unread,
Apr 4, 2020, 6:23:09 AM4/4/20
to weewx-development
Hallo Tom,

Today I installed the

Historical extension, 

the extension does not work with a MYSQL database.
my Weewx version 4.0.0b18

   <tr>
   
<td class="stats_label">Max Temp <br />&nbsp;</td>
   
<td class="stats_data">$day.outTemp.historical_max
         im Jahre $day.outTemp.historical_maxtime.format("%Y")
</td>
   
</tr>
an in syslog

Apr  4 12:21:12 wetter weewx-weewx[10525] DEBUG user.xrainno: MyXRainNo SLE executed in 1.774 seconds
Apr  4 12:21:12 wetter weewx-weewx[10525] ERROR weewx.cheetahgenerator: Generate failed with exception '<class 'weedb.DatabaseError'>'
Apr  4 12:21:12 wetter weewx-weewx[10525] ERROR weewx.cheetahgenerator: **** Ignoring template /home/weewx/skins/Basics/trend.html.tmpl
Apr  4 12:21:12 wetter weewx-weewx[10525] ERROR weewx.cheetahgenerator: **** Reason: not enough arguments for format string
Apr  4 12:21:12 wetter weewx-weewx[10525] ERROR weewx.cheetahgenerator: ****  Traceback (most recent call last):
Apr  4 12:21:12 wetter weewx-weewx[10525] ERROR weewx.cheetahgenerator: ****    File "/usr/lib/python3/dist-packages/MySQLdb/cursors.py", line 238, in execute
Apr  4 12:21:12 wetter weewx-weewx[10525] ERROR weewx.cheetahgenerator: ****      query = query % args
Apr  4 12:21:12 wetter weewx-weewx[10525] ERROR weewx.cheetahgenerator: ****  TypeError: not enough arguments for format string
Apr  4 12:21:12 wetter weewx-weewx[10525] ERROR weewx.cheetahgenerator: ****  
Apr  4 12:21:12 wetter weewx-weewx[10525] ERROR weewx.cheetahgenerator: ****  During handling of the above exception, another exception occurred:
Apr  4 12:21:12 wetter weewx-weewx[10525] ERROR weewx.cheetahgenerator: ****  
Apr  4 12:21:12 wetter weewx-weewx[10525] ERROR weewx.cheetahgenerator: ****  Traceback (most recent call last):
Apr  4 12:21:12 wetter weewx-weewx[10525] ERROR weewx.cheetahgenerator: ****    File "/home/weewx/bin/weedb/mysql.py", line 52, in guarded_fn
Apr  4 12:21:12 wetter weewx-weewx[10525] ERROR weewx.cheetahgenerator: ****      return fn(*args, **kwargs)
Apr  4 12:21:12 wetter weewx-weewx[10525] ERROR weewx.cheetahgenerator: ****    File "/home/weewx/bin/weedb/mysql.py", line 262, in execute
Apr  4 12:21:12 wetter weewx-weewx[10525] ERROR weewx.cheetahgenerator: ****      self.cursor.execute(mysql_string, tuple(sql_tuple))
Apr  4 12:21:12 wetter weewx-weewx[10525] ERROR weewx.cheetahgenerator: ****    File "/usr/lib/python3/dist-packages/MySQLdb/cursors.py", line 240, in execute
Apr  4 12:21:12 wetter weewx-weewx[10525] ERROR weewx.cheetahgenerator: ****      self.errorhandler(self, ProgrammingError, str(m))
Apr  4 12:21:12 wetter weewx-weewx[10525] ERROR weewx.cheetahgenerator: ****    File "/usr/lib/python3/dist-packages/MySQLdb/connections.py", line 52, in defaulterrorhandler
Apr  4 12:21:12 wetter weewx-weewx[10525] ERROR weewx.cheetahgenerator: ****      raise errorclass(errorvalue)
Apr  4 12:21:12 wetter weewx-weewx[10525] ERROR weewx.cheetahgenerator: ****  _mysql_exceptions.ProgrammingError: not enough arguments for format string
Apr  4 12:21:12 wetter weewx-weewx[10525] ERROR weewx.cheetahgenerator: ****  
Apr  4 12:21:12 wetter weewx-weewx[10525] ERROR weewx.cheetahgenerator: ****  During handling of the above exception, another exception occurred:
Apr  4 12:21:12 wetter weewx-weewx[10525] ERROR weewx.cheetahgenerator: ****  
Apr  4 12:21:12 wetter weewx-weewx[10525] ERROR weewx.cheetahgenerator: ****  Traceback (most recent call last):
Apr  4 12:21:12 wetter weewx-weewx[10525] ERROR weewx.cheetahgenerator: ****    File "/home/weewx/bin/weewx/cheetahgenerator.py", line 323, in generate
Apr  4 12:21:12 wetter weewx-weewx[10525] ERROR weewx.cheetahgenerator: ****      unicode_string = compiled_template.respond()
Apr  4 12:21:12 wetter weewx-weewx[10525] ERROR weewx.cheetahgenerator: ****    File "_home_weewx_skins_Basics_trend_html_tmpl.py", line 422, in respond
Apr  4 12:21:12 wetter weewx-weewx[10525] ERROR weewx.cheetahgenerator: ****    File "/usr/lib/python3/dist-packages/Cheetah/Template.py", line 1707, in _handleCheetahInclude
Apr  4 12:21:12 wetter weewx-weewx[10525] ERROR weewx.cheetahgenerator: ****      self._CHEETAH__cheetahIncludes[_includeID].respond(trans)
Apr  4 12:21:12 wetter weewx-weewx[10525] ERROR weewx.cheetahgenerator: ****    File "cheetah__home_weewx_skins_Standard_hes_current_inc_1585994730_8648148_88513.py", line 114, in respond
Apr  4 12:21:12 wetter weewx-weewx[10525] ERROR weewx.cheetahgenerator: ****    File "/home/weewx/bin/weewx/tags.py", line 347, in __getattr__
Apr  4 12:21:12 wetter weewx-weewx[10525] ERROR weewx.cheetahgenerator: ****      return self._do_query(aggregate_type)
Apr  4 12:21:12 wetter weewx-weewx[10525] ERROR weewx.cheetahgenerator: ****    File "/home/weewx/bin/weewx/tags.py", line 364, in _do_query
Apr  4 12:21:12 wetter weewx-weewx[10525] ERROR weewx.cheetahgenerator: ****      db_manager, val=val, **self.option_dict)
Apr  4 12:21:12 wetter weewx-weewx[10525] ERROR weewx.cheetahgenerator: ****    File "/home/weewx/bin/weewx/xtypes.py", line 102, in get_aggregate
Apr  4 12:21:12 wetter weewx-weewx[10525] ERROR weewx.cheetahgenerator: ****      **option_dict)
Apr  4 12:21:12 wetter weewx-weewx[10525] ERROR weewx.cheetahgenerator: ****    File "/home/weewx/bin/user/historical.py", line 75, in get_aggregate
Apr  4 12:21:12 wetter weewx-weewx[10525] ERROR weewx.cheetahgenerator: ****      row = db_manager.getSql(sql_stmt)
Apr  4 12:21:12 wetter weewx-weewx[10525] ERROR weewx.cheetahgenerator: ****    File "/home/weewx/bin/weewx/manager.py", line 419, in getSql
Apr  4 12:21:12 wetter weewx-weewx[10525] ERROR weewx.cheetahgenerator: ****      _cursor.execute(sql, sqlargs)
Apr  4 12:21:12 wetter weewx-weewx[10525] ERROR weewx.cheetahgenerator: ****    File "/home/weewx/bin/weedb/mysql.py", line 61, in guarded_fn
Apr  4 12:21:12 wetter weewx-weewx[10525] ERROR weewx.cheetahgenerator: ****      raise klass(e)
Apr  4 12:21:12 wetter weewx-weewx[10525] ERROR weewx.cheetahgenerator: ****  weedb.DatabaseError: not enough arguments for format string
Apr  4 12:21:12 wetter weewx-weewx[10525] INFO weewx.cheetahgenerator: Generated 0 files for report BasicReport in 31.83 seconds




Thomas Keffer

unread,
Apr 4, 2020, 7:38:33 AM4/4/20
to weewx-development
Silly me. I don't know what made me think this would work with MySQL --- it does not have an equivalent of strftime(). 

Let me see what I can do.

-tk

--
You received this message because you are subscribed to the Google Groups "weewx-development" group.
To unsubscribe from this group and stop receiving emails from it, send an email to weewx-developm...@googlegroups.com.

Vince Skahan

unread,
Apr 5, 2020, 1:37:43 PM4/5/20
to weewx-development
Finally got around to installing this - too fun !

Possible bug report - my historical max day as reported by the extention is off by a day in the extension vs. the NOAA report.

Look at  https://www.skahan.net/weewx/index.html in the Current Conditions section of the table for the Historical high and compare it with the NOAA reports for that month.   The extension reports things as 79.0 F today (April 5) when the NOAA report has that for April 6.   Off by one error or a timezone anomaly perhaps ?

Thomas Keffer

unread,
Apr 5, 2020, 4:02:54 PM4/5/20
to Vince Skahan, weewx-development
can you try the query directly?

select date(dateTime,'unixepoch','localtime'), `max` from archive_day_outTemp where strftime("%m-%d", dateTime,'unixepoch','localtime')='04-05';

This will tell us the max for each year on 5 April.

-tk

--
You received this message because you are subscribed to the Google Groups "weewx-development" group.
To unsubscribe from this group and stop receiving emails from it, send an email to weewx-developm...@googlegroups.com.

Vince Skahan

unread,
Apr 5, 2020, 4:09:39 PM4/5/20
to Thomas Keffer, weewx-development
2007-04-05|79.0
2008-04-05|51.3
2009-04-05|71.199997
2010-04-05|52.400002
2011-04-05|47.7
2012-04-05|55.0
2013-04-05|53.7
2014-04-05|58.4
2015-04-05|57.6
2016-04-05|65.9
2017-04-05|59.6
2018-04-05|68.3
2019-04-05|55.5
2020-04-05|56.6

--
-----  vince...@gmail.com ----

Thomas Keffer

unread,
Apr 5, 2020, 6:20:17 PM4/5/20
to Vince Skahan, weewx-development
OK, that matches what the historical extension is giving.

A few more selects to try

select date(dateTime,'unixepoch','localtime'), datetime(`maxtime`,'unixepoch','localtime'),`max` from archive_day_outTemp where strftime("%m-%d", dateTime,'unixepoch','localtime')='04-05';
select datetime(dateTime,'unixepoch','localtime'),outTemp from archive where dateTime >1175756400 and dateTime<=1175842800 order by outTemp desc limit 1;
select datetime(dateTime,'unixepoch','localtime'),outTemp from archive where dateTime >1175842800 and dateTime<=1175929200 order by outTemp desc limit 1;



Vince Skahan

unread,
Apr 5, 2020, 6:23:38 PM4/5/20
to weewx-development
On Sunday, April 5, 2020 at 3:20:17 PM UTC-7, Tom Keffer wrote:
OK, that matches what the historical extension is giving.

A few more selects to try



root@debian:/home/weewx/archive# sqlite3 weewx.sdb
SQLite version 3.7.13 2012-06-11 02:05:22
Enter ".help" for instructions
Enter SQL statements terminated with a ";"
sqlite> select date(dateTime,'unixepoch','localtime'), datetime(`maxtime`,'unixepoch','localtime'),`max` from archive_day_outTemp where strftime("%m-%d", dateTime,'unixepoch','localtime')='04-05';
2007-04-05|2007-04-06 16:34:00|79.0
2008-04-05|2008-04-06 11:29:00|51.3
2009-04-05|2009-04-06 17:00:00|71.199997
2010-04-05|2010-04-06 14:05:00|52.400002
2011-04-05|2011-04-05 17:50:00|47.7
2012-04-05|2012-04-06 16:20:00|55.0
2013-04-05|2013-04-05 17:05:00|53.7
2014-04-05|2014-04-06 16:45:00|58.4
2015-04-05|2015-04-06 16:50:00|57.6
2016-04-05|2016-04-06 16:10:00|65.9
2017-04-05|2017-04-06 16:25:00|59.6
2018-04-05|2018-04-06 16:25:00|68.3
2019-04-05|2019-04-06 16:15:00|55.5
2020-04-05|2020-04-05 12:22:41|56.6
sqlite> select datetime(dateTime,'unixepoch','localtime'),outTemp from archive where dateTime >1175756400 and dateTime<=1175842800 order by outTemp desc limit 1;
2007-04-05 17:14:00|72.5
sqlite> select datetime(dateTime,'unixepoch','localtime'),outTemp from archive where dateTime >1175842800 and dateTime<=1175929200 order by outTemp desc limit 1;
2007-04-06 16:34:00|79.0
sqlite> 
 

Thomas Keffer

unread,
Apr 5, 2020, 6:40:41 PM4/5/20
to Vince Skahan, weewx-development
OK, there's the problem. For whatever reason, the column `maxtime` in the daily summaries for 5-Apr-2007 has the high temperature for the next day, 6-Apr-2007. 

This pattern seems to occur sporadically for many other years. 

Do you suppose that your computer was running UTC when the daily summaries were rebuilt?

Was your weather station vacationing in Miami in 2007? A high of 79 for April has got to be very unusual for Seattle! :-)

-tk


-tk

--
You received this message because you are subscribed to the Google Groups "weewx-development" group.
To unsubscribe from this group and stop receiving emails from it, send an email to weewx-developm...@googlegroups.com.

Vince Skahan

unread,
Apr 5, 2020, 6:47:02 PM4/5/20
to Thomas Keffer, weewx-development
Actually looks possible.


Pre jan 2009 I had a LaCrosse that tended to read a few degrees hot in the sun, so yes I could see that date being 75+ here.

Vince Skahan

unread,
Apr 5, 2020, 6:52:48 PM4/5/20
to Thomas Keffer, weewx-development
It probably more than likely that when I ran rebuild daily after extending my schema for v4 that the vm I did that on was utc and running off old archive data that was in PDT. 

Given the UTC-8 here, if the high was after 4pm local (not unusual) wouldn't that be a day offset?  Or would it be the other day off ? Darn timezones...

Thomas Keffer

unread,
Apr 5, 2020, 7:33:24 PM4/5/20
to Vince Skahan, weewx-development
That's what I'm thinking. It recorded the high for UTC day 6-Apr-2007, not local day.

Thomas Keffer

unread,
Apr 5, 2020, 8:21:06 PM4/5/20
to weewx-development
OK, I've updated the extension to work with MySQL.


-tk

Hartmut Schweidler

unread,
Apr 6, 2020, 12:38:02 AM4/6/20
to weewx-development
Good morning from Germany,

it works with a mysql database

Thank you
To unsubscribe from this group and stop receiving emails from it, send an email to weewx-de...@googlegroups.com.

Vince Skahan

unread,
Apr 6, 2020, 8:38:01 PM4/6/20
to weewx-development

I can confirm this is what was happening....
Set my VM to PDT and rebuilt daily and the right results are coming out now.
Thanks Tom !

Thomas Keffer

unread,
Apr 6, 2020, 8:49:42 PM4/6/20
to weewx-development
Relief! I was hoping there wasn't something subtle that I was missing.

--
You received this message because you are subscribed to the Google Groups "weewx-development" group.
To unsubscribe from this group and stop receiving emails from it, send an email to weewx-developm...@googlegroups.com.

Paul Anderson

unread,
Apr 8, 2020, 2:18:59 PM4/8/20
to weewx-development
This is great I love it!
Wondering if you would consider extending it slightly with 2 additional tags?

historical_min_avg
historical_max_avg

As mentioned earlier Probably only useful if your database covers many years.
I have done so on my local copy and like it because I can now produce output like this:

Today's Climatological Summary
Climatological Period 2006 To 2019
Normal High Temp 52.7°F
Normal Low Temp 35.6°F
Normal Avg Temp 43.9°F
Record High Temp 66.0°F in 2013
Record Low Temp 26.1°F in 2011

Attached are my changes.
Please note I have tested it with sqlite , it seems to produce sane expected results. Not test with mysql.

Thanks,
Paul


On Monday, April 6, 2020 at 8:49:42 PM UTC-4, Tom Keffer wrote:
Relief! I was hoping there wasn't something subtle that I was missing.

On Mon, Apr 6, 2020 at 5:38 PM Vince Skahan <vince...@gmail.com> wrote:

I can confirm this is what was happening....
Set my VM to PDT and rebuilt daily and the right results are coming out now.
Thanks Tom !

On Sunday, April 5, 2020 at 4:33:24 PM UTC-7, Tom Keffer wrote:
That's what I'm thinking. It recorded the high for UTC day 6-Apr-2007, not local day.

On Sun, Apr 5, 2020 at 3:52 PM Vince Skahan <vince...@gmail.com> wrote:
It probably more than likely that when I ran rebuild daily after extending my schema for v4 that the vm I did that on was utc and running off old archive data that was in PDT. 

Given the UTC-8 here, if the high was after 4pm local (not unusual) wouldn't that be a day offset?  Or would it be the other day off ? Darn timezones...

--
You received this message because you are subscribed to the Google Groups "weewx-development" group.
To unsubscribe from this group and stop receiving emails from it, send an email to weewx-de...@googlegroups.com.
historical.py

Thomas Keffer

unread,
Apr 8, 2020, 7:23:59 PM4/8/20
to Paul Anderson, weewx-development
Good idea. Thanks, Paul!

Commit 5441bec


To unsubscribe from this group and stop receiving emails from it, send an email to weewx-developm...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/weewx-development/8cbeb74f-0de9-455f-87e2-6dd99b5c1971%40googlegroups.com.

rich T

unread,
Apr 23, 2020, 9:36:15 PM4/23/20
to weewx-development
Just so I'm clear, the historical data also contains data for today. If that is true and I want get the data from the beginning of the database to the current day in the previous year, I would change the following:

historical_avg': "SELECT SUM(`wsum`), SUM(`sumtime`) FROM {table}_day_{obs_type} "
                              "WHERE STRFTIME('%m-%d', dateTime,'unixepoch','localtime','-1 year') = '{month:02d}-{day:02d}';"

Reason I'm asking, if I take my previous 10 years of data minus current daily temperature average I can determine if the current day temperature is above or below normal for my station. 

Thanks for all the time and efforts that everyone puts into this great software.



Tom Keffer

unread,
Apr 24, 2020, 7:06:35 AM4/24/20
to weewx-development
I think that would give the same answer as the unmodified version. You probably want something like

SELECT SUM(`wsum`), SUM(`sumtime`) FROM {table}_day_{obs_type} "
    "WHERE STRFTIME('%m-%d', dateTime, 'unixepoch','localtime') = '{month:02d}-{day:02d}' "
    "AND STRFTIME('%Y', dateTime, 'unixepoch','localtime') < {year:04d};"


where "year" is the present year. Alternatively, you could compute the unix epoch time of a year ago (in Python), then use

SELECT SUM(`wsum`), SUM(`sumtime`) FROM {table}_day_{obs_type} "
    "WHERE STRFTIME('%m-%d', dateTime, 'unixepoch','localtime') = '{month:02d}-{day:02d}' "
    "AND dateTime <= {time_a_year_ago};"

where "time_a_year_ago" is the unix epoch time a year ago. This has the advantage that the second WHERE clause can use the fact that dateTime is indexed.

Needless to say, none of this has been tested!

-tk





--
You received this message because you are subscribed to the Google Groups "weewx-development" group.
To unsubscribe from this group and stop receiving emails from it, send an email to weewx-developm...@googlegroups.com.

rich T

unread,
Apr 24, 2020, 7:40:25 PM4/24/20
to weewx-development
Thanks for looking into this and know it was an untested solution. 

The following statement gives me this error:
"SELECT SUM(`wsum`), SUM(`sumtime`) FROM {table}_day_{obs_type} "
    "WHERE STRFTIME('%m-%d', dateTime, 'unixepoch','localtime') = '{month:02d}-{day:02d}' "
    "AND STRFTIME('%Y', dateTime, 'unixepoch','localtime') < {year:04d};"

Apr 24 19:11:17 raspberrypi weewx[1224] INFO weewx.manager: Added record 2020-04-24 19:10:00 EDT (1587769800) to database 'weewx.sdb'
Apr 24 19:11:17 raspberrypi weewx[1224] INFO weewx.manager: Added record 2020-04-24 19:10:00 EDT (1587769800) to daily summary in 'weewx.sdb'
Apr 24 19:11:17 raspberrypi weewx[1224] DEBUG weewx.reportengine: reportengine: Running reports for latest time in the database.
Apr 24 19:11:17 raspberrypi weewx[1224] DEBUG weewx.reportengine: reportengine: Running report 'SeasonsReport'
Apr 24 19:11:18 raspberrypi weewx[1224] DEBUG weewx.reportengine: reportengine: Found configuration file /home/weewx/skins/Seasons/skin.conf for report 'SeasonsReport'
Apr 24 19:11:18 raspberrypi weewx[1224] DEBUG weewx.cheetahgenerator: Using search list ['weewx.cheetahgenerator.Almanac', 'weewx.cheetahgenerator.Station', 'weewx.cheetahgenerator.Current', 'weewx.cheetahgenerator.Stats', 'weewx.cheetahgenerator.UnitInfo', 'weewx.cheetahgenerator.Extras']
Apr 24 19:11:18 raspberrypi weewx[1224] DEBUG weewx.manager: Daily summary version is 2.0
Apr 24 19:11:22 raspberrypi weewx[1224] ERROR weewx.cheetahgenerator: Generate failed with exception '<class 'KeyError'>'
Apr 24 19:11:22 raspberrypi weewx[1224] ERROR weewx.cheetahgenerator: **** Ignoring template /home/weewx/skins/Seasons/index.html.tmpl
Apr 24 19:11:22 raspberrypi weewx[1224] ERROR weewx.cheetahgenerator: **** Reason: 'year'
Apr 24 19:11:22 raspberrypi weewx[1224] ERROR weewx.cheetahgenerator: ****  Traceback (most recent call last):
Apr 24 19:11:22 raspberrypi weewx[1224] ERROR weewx.cheetahgenerator: ****    File "/home/weewx/bin/weewx/cheetahgenerator.py", line 322, in generate
Apr 24 19:11:22 raspberrypi weewx[1224] ERROR weewx.cheetahgenerator: ****      unicode_string = compiled_template.respond()
Apr 24 19:11:22 raspberrypi weewx[1224] ERROR weewx.cheetahgenerator: ****    File "_home_weewx_skins_Seasons_index_html_tmpl.py", line 225, in respond
Apr 24 19:11:22 raspberrypi weewx[1224] ERROR weewx.cheetahgenerator: ****    File "/usr/lib/python3/dist-packages/Cheetah/Template.py", line 1707, in _handleCheetahInclude
Apr 24 19:11:22 raspberrypi weewx[1224] ERROR weewx.cheetahgenerator: ****      self._CHEETAH__cheetahIncludes[_includeID].respond(trans)
Apr 24 19:11:22 raspberrypi weewx[1224] ERROR weewx.cheetahgenerator: ****    File "_home_weewx_skins_Seasons_historical_statistics_inc.py", line 338, in respond
Apr 24 19:11:22 raspberrypi weewx[1224] ERROR weewx.cheetahgenerator: ****    File "/home/weewx/bin/weewx/tags.py", line 347, in __getattr__
Apr 24 19:11:22 raspberrypi weewx[1224] ERROR weewx.cheetahgenerator: ****      return self._do_query(aggregate_type)
Apr 24 19:11:22 raspberrypi weewx[1224] ERROR weewx.cheetahgenerator: ****    File "/home/weewx/bin/weewx/tags.py", line 364, in _do_query
Apr 24 19:11:22 raspberrypi weewx[1224] ERROR weewx.cheetahgenerator: ****      db_manager, val=val, **self.option_dict)
Apr 24 19:11:22 raspberrypi weewx[1224] ERROR weewx.cheetahgenerator: ****    File "/home/weewx/bin/weewx/xtypes.py", line 102, in get_aggregate
Apr 24 19:11:22 raspberrypi weewx[1224] ERROR weewx.cheetahgenerator: ****      **option_dict)
Apr 24 19:11:22 raspberrypi weewx[1224] ERROR weewx.cheetahgenerator: ****    File "/home/weewx/bin/user/historical.py", line 99, in get_aggregate
Apr 24 19:11:22 raspberrypi weewx[1224] ERROR weewx.cheetahgenerator: ****      sql_stmt = Historical.sql_stmts[dbtype][aggregate_type].format(**interp_dict)
Apr 24 19:11:22 raspberrypi weewx[1224] ERROR weewx.cheetahgenerator: ****  KeyError: 'year'
Apr 24 19:11:24 raspberrypi weewx[1224] INFO weewx.cheetahgenerator: Generated 7 files for report SeasonsReport in 5.92 secondsEnter code here...

The following statement gives me this error:

Apr 24 19:30:28 raspberrypi weewx[2847] DEBUG weewx.manager: Daily summary version is 2.0
Apr 24 19:30:30 raspberrypi weewx[2847] ERROR weewx.cheetahgenerator: Generate failed with exception '<class 'KeyError'>'
Apr 24 19:30:30 raspberrypi weewx[2847] ERROR weewx.cheetahgenerator: **** Ignoring template /home/weewx/skins/Seasons/index.html.tmpl
Apr 24 19:30:30 raspberrypi weewx[2847] ERROR weewx.cheetahgenerator: **** Reason: 'time_a_year_ago'
Apr 24 19:30:30 raspberrypi weewx[2847] ERROR weewx.cheetahgenerator: ****  Traceback (most recent call last):
Apr 24 19:30:30 raspberrypi weewx[2847] ERROR weewx.cheetahgenerator: ****    File "/home/weewx/bin/weewx/cheetahgenerator.py", line 322, in generate
Apr 24 19:30:30 raspberrypi weewx[2847] ERROR weewx.cheetahgenerator: ****      unicode_string = compiled_template.respond()
Apr 24 19:30:30 raspberrypi weewx[2847] ERROR weewx.cheetahgenerator: ****    File "_home_weewx_skins_Seasons_index_html_tmpl.py", line 225, in respond
Apr 24 19:30:30 raspberrypi weewx[2847] ERROR weewx.cheetahgenerator: ****    File "/usr/lib/python3/dist-packages/Cheetah/Template.py", line 1707, in _handleCheetahInclude
Apr 24 19:30:30 raspberrypi weewx[2847] ERROR weewx.cheetahgenerator: ****      self._CHEETAH__cheetahIncludes[_includeID].respond(trans)
Apr 24 19:30:30 raspberrypi weewx[2847] ERROR weewx.cheetahgenerator: ****    File "_home_weewx_skins_Seasons_historical_statistics_inc.py", line 338, in respond
Apr 24 19:30:30 raspberrypi weewx[2847] ERROR weewx.cheetahgenerator: ****    File "/home/weewx/bin/weewx/tags.py", line 347, in __getattr__
Apr 24 19:30:30 raspberrypi weewx[2847] ERROR weewx.cheetahgenerator: ****      return self._do_query(aggregate_type)
Apr 24 19:30:30 raspberrypi weewx[2847] ERROR weewx.cheetahgenerator: ****    File "/home/weewx/bin/weewx/tags.py", line 364, in _do_query
Apr 24 19:30:30 raspberrypi weewx[2847] ERROR weewx.cheetahgenerator: ****      db_manager, val=val, **self.option_dict)
Apr 24 19:30:30 raspberrypi weewx[2847] ERROR weewx.cheetahgenerator: ****    File "/home/weewx/bin/weewx/xtypes.py", line 102, in get_aggregate
Apr 24 19:30:30 raspberrypi weewx[2847] ERROR weewx.cheetahgenerator: ****      **option_dict)
Apr 24 19:30:30 raspberrypi weewx[2847] ERROR weewx.cheetahgenerator: ****    File "/home/weewx/bin/user/historical.py", line 99, in get_aggregate
Apr 24 19:30:30 raspberrypi weewx[2847] ERROR weewx.cheetahgenerator: ****      sql_stmt = Historical.sql_stmts[dbtype][aggregate_type].format(**interp_dict)
Apr 24 19:30:30 raspberrypi weewx[2847] ERROR weewx.cheetahgenerator: ****  KeyError: 'time_a_year_ago'Enter code here...

Rich

Tom Keffer

unread,
Apr 24, 2020, 7:49:46 PM4/24/20
to rich T, weewx-development
Just like 'month' and 'day', you have to supply a value for 'year' in the interpolation dictionary on line 90.

Or, alternatively, you have to supply 'time_a_year_ago'.

--
You received this message because you are subscribed to the Google Groups "weewx-development" group.
To unsubscribe from this group and stop receiving emails from it, send an email to weewx-developm...@googlegroups.com.

rich T

unread,
Apr 24, 2020, 8:59:45 PM4/24/20
to weewx-development
Added the Key into the interpolation dictionary to both of the statements (one at a time of  course) which corrected the error, but generated a different error.  

Apr 24 20:25:26 raspberrypi weewx[11504] ERROR weewx.cheetahgenerator: Generate failed with exception '<class 'sqlite3.Warning'>'
Apr 24 20:25:26 raspberrypi weewx[11504] ERROR weewx.cheetahgenerator: **** Ignoring template /home/weewx/skins/Seasons/index.html.tmpl
Apr 24 20:25:26 raspberrypi weewx[11504] ERROR weewx.cheetahgenerator: **** Reason: You can only execute one statement at a time.
Apr 24 20:25:26 raspberrypi weewx[11504] ERROR weewx.cheetahgenerator: ****  Traceback (most recent call last):
Apr 24 20:25:26 raspberrypi weewx[11504] ERROR weewx.cheetahgenerator: ****    File "/home/weewx/bin/weewx/cheetahgenerator.py", line 322, in generate
Apr 24 20:25:26 raspberrypi weewx[11504] ERROR weewx.cheetahgenerator: ****      unicode_string = compiled_template.respond()
Apr 24 20:25:26 raspberrypi weewx[11504] ERROR weewx.cheetahgenerator: ****    File "_home_weewx_skins_Seasons_index_html_tmpl.py", line 225, in respond
Apr 24 20:25:26 raspberrypi weewx[11504] ERROR weewx.cheetahgenerator: ****    File "/usr/lib/python3/dist-packages/Cheetah/Template.py", line 1707, in _handleCheetahInclude
Apr 24 20:25:26 raspberrypi weewx[11504] ERROR weewx.cheetahgenerator: ****      self._CHEETAH__cheetahIncludes[_includeID].respond(trans)
Apr 24 20:25:26 raspberrypi weewx[11504] ERROR weewx.cheetahgenerator: ****    File "_home_weewx_skins_Seasons_historical_statistics_inc.py", line 377, in respond
Apr 24 20:25:26 raspberrypi weewx[11504] ERROR weewx.cheetahgenerator: ****    File "_home_weewx_skins_Seasons_historical_statistics_inc.py", line 127, in __errorCatcher9
Apr 24 20:25:26 raspberrypi weewx[11504] ERROR weewx.cheetahgenerator: ****    File "<string>", line 1, in <module>
Apr 24 20:25:26 raspberrypi weewx[11504] ERROR weewx.cheetahgenerator: ****    File "/home/weewx/bin/weewx/tags.py", line 347, in __getattr__
Apr 24 20:25:26 raspberrypi weewx[11504] ERROR weewx.cheetahgenerator: ****      return self._do_query(aggregate_type)
Apr 24 20:25:26 raspberrypi weewx[11504] ERROR weewx.cheetahgenerator: ****    File "/home/weewx/bin/weewx/tags.py", line 364, in _do_query
Apr 24 20:25:26 raspberrypi weewx[11504] ERROR weewx.cheetahgenerator: ****      db_manager, val=val, **self.option_dict)
Apr 24 20:25:26 raspberrypi weewx[11504] ERROR weewx.cheetahgenerator: ****    File "/home/weewx/bin/weewx/xtypes.py", line 102, in get_aggregate
Apr 24 20:25:26 raspberrypi weewx[11504] ERROR weewx.cheetahgenerator: ****      **option_dict)
Apr 24 20:25:26 raspberrypi weewx[11504] ERROR weewx.cheetahgenerator: ****    File "/home/weewx/bin/user/historical.py", line 104, in get_aggregate
Apr 24 20:25:26 raspberrypi weewx[11504] ERROR weewx.cheetahgenerator: ****      row = db_manager.getSql(sql_stmt)
Apr 24 20:25:26 raspberrypi weewx[11504] ERROR weewx.cheetahgenerator: ****    File "/home/weewx/bin/weewx/manager.py", line 419, in getSql
Apr 24 20:25:26 raspberrypi weewx[11504] ERROR weewx.cheetahgenerator: ****      _cursor.execute(sql, sqlargs)
Apr 24 20:25:26 raspberrypi weewx[11504] ERROR weewx.cheetahgenerator: ****    File "/home/weewx/bin/weedb/sqlite.py", line 29, in guarded_fn
Apr 24 20:25:26 raspberrypi weewx[11504] ERROR weewx.cheetahgenerator: ****      return fn(*args, **kwargs)
Apr 24 20:25:26 raspberrypi weewx[11504] ERROR weewx.cheetahgenerator: ****    File "/home/weewx/bin/weedb/sqlite.py", line 211, in execute
Apr 24 20:25:26 raspberrypi weewx[11504] ERROR weewx.cheetahgenerator: ****      return sqlite3.Cursor.execute(self, *args, **kwargs)
Apr 24 20:25:26 raspberrypi weewx[11504] ERROR weewx.cheetahgenerator: ****  sqlite3.Warning: You can only execute one statement at a time.


I backed out all the changes that were made to the historical.py file and works it works fine.  I would not worry to much about this because it is not an actual issue. Again thanks for you time to look into what I was trying.

Rich

Praveen Chandrasekaran

unread,
May 1, 2020, 4:41:16 AM5/1/20
to rich T, weewx-development
I would like to add 24hr difference of temperature to my webpage like how my console shows. Is that possible with weeex historical? In its current form I guess no?

--
You received this message because you are subscribed to the Google Groups "weewx-development" group.
To unsubscribe from this group and stop receiving emails from it, send an email to weewx-developm...@googlegroups.com.

Tom Keffer

unread,
May 1, 2020, 11:36:15 AM5/1/20
to Praveen Chandrasekaran, rich T, weewx-development
I don't know what your console is showing. Do you mean the present temperature vs 24 hours ago? That can be done with the $trend tag:

$trend($time_delta=86400).outTemp

-tk

Reply all
Reply to author
Forward
0 new messages