On this date

301 views
Skip to first unread message

Robin

unread,
May 11, 2019, 9:30:47 AM5/11/19
to weewx-user
I apologise if this has been asked before or if there is a simple and obvious way to do this, but I can't see it.

I want to display the temperature (min,max) for today's date for each year since we started keeping records.

Can somebody point me in the right direction?

Thanks people.

p q

unread,
May 11, 2019, 11:00:19 AM5/11/19
to weewx-user
I want to do the same. I asked a couple of weeks ago and got no reply. I'm going to figure it out when I have time. When I do I'll post it here.

jose riaño

unread,
May 11, 2019, 11:40:26 AM5/11/19
to weewx-user
amigo creería que eso es ya tratamientos de los registros en que los estas mostrando en un servidor web o en que ??

Leon Shaner

unread,
May 11, 2019, 11:48:01 AM5/11/19
to weewx-user
Hey, Robin!

I just posted a reply to the group (via e-mail), but didn't echo it back to my inbox.
I think it must have been eaten by the AEther. :-(
Then I tried a more simple message and it didn't post, either.
So now I am trying from the web interface to google groups.
Something seems to be wrong with the alias, or is it just me?

Leon Shaner

unread,
May 11, 2019, 11:50:08 AM5/11/19
to weewx-user
Posting from the web interface did get echoed to my inbox. So whatever is wrong is on the e-mail reply side.
Here is my original reply. Hopefully we don't get a duplicate whenever Google fixes whatever is wrong with the e-mail interface to the Group. :-/

FWD:

Hey, Robin,

I don't know the weewx way, but here is a sql way that may lead some smart person to a better solution. :-/
I used the system date command up front to get the month-day, which is to avoid asking SQLite to do that computation for every row within the query.

$ today=$(date +%\m-%\d); sqlite3 -header /var/lib/weewx/weewx.sdb "select date(dateTime, 'unixepoch', 'localtime') as day, min, max from archive_day_outTemp where strftime('%m-%d', day)='$today' group by day;"
day|min|max
2017-05-11|46.9|70.0
2018-05-11|43.5|54.9
2019-05-11|39.02|52.7

Oh, and in case outTemp is not the name of your sensor per archive_day_outTemp, above, you can glean the table you need from here:

$ sqlite3 /var/lib/weewx/weewx.sdb ".tables"

And of course to see the column names available, it's:

$ sqlite3 /var/lib/weewx/weewx.sdb ".schema archive_day_outTemp"
CREATE TABLE archive_day_outTemp (dateTime INTEGER NOT NULL UNIQUE PRIMARY KEY, min REAL, mintime INTEGER, max REAL, maxtime INTEGER, sum REAL, count INTEGER, wsum REAL, sumtime INTEGER);

Or the more human readable way:

$ sqlite3 -header /var/lib/weewx/weewx.sdb "select * from archive_day_outTemp limit 1;"
dateTime|min|mintime|max|maxtime|sum|count|wsum|sumtime
1325394000|||||0.0|0|0.0|0

HTH. =D

Regards,
\Leon
--
Leon Shaner :: Dearborn, Michigan (iPad Pro)

gjr80

unread,
May 13, 2019, 3:40:37 AM5/13/19
to weewx-user
I've put together a search list extension that should do what you want. You will find the code here. The SLE is based on the existing WeeWX tag machinery that enables iteration over periods. So with the SLE installed you can do something like:

#for $day in this_span.this
$day
.outTemp.max at $day.outTemp.maxtime
#end for

to display the maximum daily temperature and the time it occurred on this day in all years in the archive. The output would be something like:

24.5°C at 11 May 2017 12:51:00
26.7°C at 11 May 2018 13:31:00
23.4°C at 11 May 2019 13:15:00

There are various parameters that can be set against $this_span to limit the period covered (the default is all records but you can limit it to the last x years, months etc as with the existing $span tag). There are various parameters that can be applied to .this to set the day to be used, for example, .this($period='week') and .this($period='month') will provide stats for this week and this month respectively over all years. There are many variations and permutations, I have tried to capture a variety of use cases in the up front comment in this.py.

To install/use:

1. Download the file this.py to the WeeWX machine and save to the $BIN_ROOT/user directory:

    for a setup.py install:
   
    otherwise:


2.  Add the following line to the skin config file [CheetahGenerator] stanza for the skin in which the SLE is to be used:
   
search_list_extensions = user.this.ThisSLE

    if the search_list_extensions config option already exists add user.this.ThisSLE to the end of the option using a comma as a separator, eg:
   
search_list_extensions = user,another.SLE, user.this.ThisSLE

3.  Add the required $this_span.this code to the template concerned.

4.  After the next report cycle is complete confirm there are no errors in the log and the report has been generated as expected.

Gary
Message has been deleted

Robin

unread,
May 13, 2019, 3:56:01 AM5/13/19
to weewx-user
Gary,

Thank you, you are a star. That is exactly what I was looking for.

I'm going to go away and play. I'm so excited!

Robin

p q

unread,
May 13, 2019, 9:07:59 AM5/13/19
to weewx...@googlegroups.com
Thank you. I was starting to look at SLE as a way to do this but I didn't get very far yesterday. I'll give this a try too.

--
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/c0f51b2e-7a8b-4a05-9552-f146afbd9bfe%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


--
Peter Quinn
(415)794-2264

Leon Shaner

unread,
May 13, 2019, 11:19:01 AM5/13/19
to weewx...@googlegroups.com
Hey, Robin,

I don't know the weewx way, but here is a sql way that may lead some smart person to a better solution.  :-/
I used the system date command up front to get the month-day, which is to avoid asking SQLite to do that computation for every row within the query.

$ today=$(date +%\m-%\d); sqlite3 -header /var/lib/weewx/weewx.sdb "select date(dateTime, 'unixepoch', 'localtime') as day, min, max from archive_day_outTemp where strftime('%m-%d', day)='$today' group by day;"
day|min|max
2017-05-11|46.9|70.0
2018-05-11|43.5|54.9
2019-05-11|39.02|52.7

Oh, and in case outTemp is not the name of your sensor per archive_day_outTemp, above, you can glean the table you need from here:

$ sqlite3 /var/lib/weewx/weewx.sdb ".tables"

And of course to see the column names available, it's:

$ sqlite3 /var/lib/weewx/weewx.sdb ".schema archive_day_outTemp"
CREATE TABLE archive_day_outTemp (dateTime INTEGER NOT NULL UNIQUE PRIMARY KEY, min REAL, mintime INTEGER, max REAL, maxtime INTEGER, sum REAL, count INTEGER, wsum REAL, sumtime INTEGER);

Or the more human readable way:

$ sqlite3 -header /var/lib/weewx/weewx.sdb "select * from archive_day_outTemp limit 1;"
dateTime|min|mintime|max|maxtime|sum|count|wsum|sumtime
1325394000|||||0.0|0|0.0|0

HTH.  =D

Regards,
\Leon
--
Leon Shaner :: Dearborn, Michigan (iPad Pro)
--
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.

Leon Shaner

unread,
May 13, 2019, 11:19:01 AM5/13/19
to weewx...@googlegroups.com
Hey, Robin!

I just posted a reply, but the alias didn't echo it back to my inbox.
I think it must have been eaten by the AEther.  :-(
If it doesn't show up soon, I'll try posting it via the web interface to googlegroups.com


Regards,
\Leon
--
Leon Shaner :: Dearborn, Michigan (iPad Pro)

On May 11, 2019, at 9:30 AM, Robin <robin....@otenet.gr> wrote:

--

gjr80

unread,
May 14, 2019, 8:37:55 PM5/14/19
to weewx-user
I should have given this a little more thought before publishing. I have since made a slight change to the tag name to make it a little more logical and consistent with the other iterative tags that WeeWX supports (and to remove a 'this'). The tag now uses .periods in lieu of .this; for example, you would now use the $this_span tag as follows:

#for $day in this_span.periods

$day
.outTemp.max at $day.outTemp.maxtime
#end for

Any existing template code will work fine with the current version with just the need to change '.this' to '.periods'.

I have also created a page in the wiki of the repo containing the this search list extension code that explains the installation and usage of the this search list extension. Hopefully this is a little more user friendly and easier to read than comments in the code.

Gary

V. Kelly Bellis

unread,
May 15, 2019, 10:03:35 AM5/15/19
to weewx-user
Thanks for doing this Gary. I'm too new to all of this stuff to have anything to look back on, but it's very cool to see what can be done with weewx.
- Kelly

p q

unread,
May 18, 2019, 1:15:15 PM5/18/19
to weewx-user
This is great. I implemented it on my site this morning. I added it to the bottom of the Since Midnight table at the bottom. Does exactly what I was looking for.

The only issue I'm having is that I want to display the rain total only if it's not zero. I live in an area where there's typically no rain from May to October so I want to skip the line for the rain when it's 0. I tried an if statement but it's not effective. Any hints?

Here's the template code: 
              <tr>
                <td class="stats_label">
                  On This Day<br/>
                  $day.dateTime.format("%b %d")
                </td>
                <td class="stats_data">
                #for $day in $this_span.periods
                   $day.dateTime.format("%Y")<br/>
                   &nbsp; H: $day.outTemp.max &nbsp;&nbspL: $day.outTemp.min<br/>
                   #if $day.rain.sum > 0
                      &nbsp Rain: $day.rain.sum<br/>
                   #end if
                #end for
                </td>
              </tr>

Andrew Milner

unread,
May 18, 2019, 1:21:22 PM5/18/19
to weewx-user
wouldnt it just be day.rain.raw > 0 ???

p q

unread,
May 18, 2019, 2:53:04 PM5/18/19
to weewx-user
Nope. I get a KeyError when I switch to $day.rain.raw. No errors with $day.rain.sum. 

I tried
$day.rain.sum >0
$day.rain.sum >0.0
$day.rain.sum >0.00
$day.rain.sum

Same deal. Is there a string/real conversion problem? Can I force it to a number?

p q

unread,
May 18, 2019, 2:59:27 PM5/18/19
to weewx-user
Oh wait. I it's outputting "0.0 in"
I do need to do .raw, but as
$day.rain.sum.raw >0

Thank you. That was it.


On Saturday, May 11, 2019 at 6:30:47 AM UTC-7, Robin wrote:

Nick

unread,
May 21, 2019, 5:50:13 AM5/21/19
to weewx...@googlegroups.com
Good morning all,

A little help if you please.

I am running the latest version of wseewx on a centos 7 system

uname -a provides

<code>
Linux bragi 4.4.108-1.el7.elrepo.x86_64 #1 SMP Mon Dec 25 09:55:39 EST
2017 x86_64 x86_64 x86_64 GNU/Linux
</code>

The install is in /bin/weewxd

I have a d-link DUB-H7 to which the w/s is connected.

It hangs ... :-( but the error is not quite that in the wiki - I don't
see the
"could not detach kernel driver from interface 0: No data available"

I do get:

<code>
May 20 07:02:50 bragi weewx[26340]: fousb: get_observations failed:
[Errno 110] Operation timed out
May 20 07:03:35 bragi weewx[26340]: fousb: get_observations failed:
[Errno 110] Operation timed out
May 20 07:04:20 bragi weewx[26340]: fousb: get_observations failed:
[Errno 110] Operation timed out
May 20 07:05:05 bragi weewx[26340]: fousb: get_observations failed:
[Errno 110] Operation timed out
May 20 07:05:05 bragi weewx[26340]: engine: Main loop exiting. Shutting
engine down.
May 20 07:05:05 bragi weewx[26340]: engine: Shutting down StdReport thread
May 20 07:05:05 bragi weewx[26340]: engine: Caught WeeWxIOError: Max
retries exceeded while fetching observations
May 20 07:05:05 bragi weewx[26340]: **** Waiting 60 seconds then
retrying...
May 20 07:05:34 bragi systemd: Started Multi-router Traffic Grapher.
May 20 07:06:05 bragi weewx[26340]: engine: retrying...
May 20 07:06:05 bragi weewx[26340]: engine: Using configuration file
/etc/weewx/weewx.conf
May 20 07:06:05 bragi weewx[26340]: engine: Loading station type
FineOffsetUSB (weewx.drivers.fousb)
May 20 07:06:05 bragi weewx[26340]: fousb: driver version is 1.9
May 20 07:06:05 bragi weewx[26340]: fousb: power cycling enabled for
port 4 on hub 001:006
May 20 07:06:05 bragi weewx[26340]: fousb: polling mode is PERIODIC
May 20 07:06:05 bragi weewx[26340]: fousb: polling interval is 60
May 20 07:06:05 bragi weewx[26340]: fousb: found station on USB bus= device=
May 20 07:06:05 bragi weewx[26340]: engine: StdConvert target unit is 0x1
May 20 07:06:05 bragi weewx[26340]: wxcalculate: The following values
will be calculated: barometer=software, windchill=software,
dewpoint=software, appTemp=prefer_hardware, rainRate=prefer_hardware,
windrun=prefer_hardware, heatindex=prefer_hardware,
maxSolarRad=prefer_hardware, humidex=prefer_hardware,
pressure=prefer_hardware, inDewpoint=prefer_hardware,
ET=prefer_hardware, altimeter=prefer_hardware, cloudbase=prefer_hardware
May 20 07:06:05 bragi weewx[26340]: wxcalculate: The following
algorithms will be used for calculations: altimeter=aaNOAA, maxSolarRad=RS
May 20 07:06:05 bragi weewx[26340]: engine: Archive will use data
binding wx_binding
May 20 07:06:05 bragi weewx[26340]: engine: Record generation will be
attempted in 'software'
May 20 07:06:05 bragi weewx[26340]: engine: Using archive interval of
300 seconds (software record generation)
May 20 07:06:05 bragi weewx[26340]: engine: Using binding 'wx_binding'
to database 'weewx.sdb'
May 20 07:06:05 bragi weewx[26340]: manager: Starting backfill of daily
summaries
May 20 07:06:05 bragi weewx[26340]: restx: StationRegistry: Station will
be registered.
May 20 07:06:05 bragi weewx[26340]: restx: Wunderground-PWS: Data for
station INORFOLK21 will be posted
May 20 07:06:05 bragi weewx[26340]: restx: PWSweather: Posting not enabled.
May 20 07:06:05 bragi weewx[26340]: restx: CWOP: Posting not enabled.
May 20 07:06:05 bragi weewx[26340]: restx: WOW: Posting not enabled.
May 20 07:06:05 bragi weewx[26340]: restx: AWEKAS: Posting not enabled.
May 20 07:06:05 bragi weewx[26340]: engine: Starting up weewx version 3.9.1
May 20 07:06:20 bragi weewx[26340]: fousb: get_records failed: [Errno
110] Operation timed out
May 20 07:07:05 bragi weewx[26340]: fousb: get_records failed: [Errno
110] Operation timed out
May 20 07:07:50 bragi weewx[26340]: fousb: get_records failed: [Errno
110] Operation timed out
May 20 07:08:35 bragi weewx[26340]: fousb: get_records failed: [Errno
110] Operation timed out
May 20 07:08:35 bragi weewx[26340]: engine: Main loop exiting. Shutting
engine down.
May 20 07:08:35 bragi weewx[26340]: engine: Caught WeeWxIOError: Max
retries exceeded while fetching records
May 20 07:08:35 bragi weewx[26340]: **** Waiting 60 seconds then
retrying...
May 20 07:09:35 bragi weewx[26340]: engine: retrying...


...
</code>

There is no mention of trying to power cycle the hub/port, and it fails
to restore the function.

If I use the uhubctl I can turn ports on & off at will, but the python
version I get a type error ... ?

<code>
./usb_control-0.6.py
Traceback (most recent call last):
File "./usb_control-0.6.py", line 191, in <module>
main()
File "./usb_control-0.6.py", line 188, in main
scan()
File "./usb_control-0.6.py", line 73, in scan
print "device at %s:%03d" % (bus.dirname, dev.devnum)
TypeError: %d format: a number is required, not NoneType

</code>

The default python version is 2.7 (yum fails under any other version -
another issue to fix ? - I 'hate' centos but it is what works with the
Wx satellite Rx stuff).

Ideas?

If you need more infor - ask

Regards

Nick
M0HGU
--
What your soldier wants
-- really, really wants -- is no-one shooting
back at him.
(alt.fan.pratchett)
10:35:01 up 23 days, 13:54, 10 users, load average: 0.42, 0.49, 0.55

signature.asc

gjr80

unread,
May 21, 2019, 8:36:10 PM5/21/19
to weewx-user
Hi,

Can't help with your power cycle/port problem but probably best if you start a new thread; your problem has nothing to do with the subject of this thread.

Gary

Robin

unread,
May 27, 2019, 6:33:22 AM5/27/19
to weewx-user


Gary,

Thank you for the search list extension. It is very useful. 

I'm sorry to be a pest, I have one more question. I have been trying to see if I can exclude the current year so that I get only historic records. I have looked at the code to try and understand how it all works, but that simply reminds me that I don't understand code.

Is there a way to exclude the current year?

Thank you again.

Robin 

p q

unread,
May 27, 2019, 9:58:08 AM5/27/19
to weewx...@googlegroups.com
Pretty simple. I've been meaning to do that for myself by hadn't gotten around to it yet. 

You need a if statement just inside the loop like
#if $day.dateTime.format("%Y")<>$year.dateTime.format("%Y")

This compares the year returned by the loop to the current year, formatted the same. If they are different output as normal.
You need to close the if with an #end if just before the #end for

Here's my code:
                #for $day in $this_span.periods
                   #if $day.dateTime.format("%Y")<>$year.dateTime.format("%Y")

                      $day.dateTime.format("%Y")<br/>
                      &nbsp; H: $day.outTemp.max &nbsp;&nbspL: $day.outTemp.min<br/>
                      #if $day.rain.sum.raw >0.0

                         &nbsp Rain: $day.rain.sum<br/>
                      #end if
                   #end if
                #end for


I have an extra #if to not print out rain if it's zero. If you get rain throughout the year, you might want to remove the second #if line and first #end if.

Good luck.

--
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.

For more options, visit https://groups.google.com/d/optout.


--
Peter Quinn
(415)794-2264

Robin

unread,
May 28, 2019, 5:01:15 AM5/28/19
to weewx-user

Peter,

Thank you. This has finally started to sink in, I am now producing tables that show what I want and make sense!

Thank you to everyone that has had input here, you are all superstars.

Regards to all
Robin
Reply all
Reply to author
Forward
0 new messages