Use of template for generation of uploadfile for HetWeerActueel

296 views
Skip to first unread message

Ton vanN

unread,
Mar 26, 2021, 5:00:19 AM3/26/21
to weewx-user
Novice to WeeWX.
Have the main progam as simulator up and running (= see files updating in folder public_html ).
Now trying to implement a template to generate an uploadfile for HetWeerActueel.
[has been discussed earlier in this forum, but that discussion apparently not ending with working solution]

Template [attached in zip-file] should generate a htm-file.
For activation of the template I inserted the following text in
/home/weewx/skins/Standard/skin.conf at the end of the section CheetahGenerator

    [[HWA]]
        # Report that generates an uploadfile for HetWeerActueel.
        [[[OWD]]]
            template = openweerdata_wx.htm.tmpl
 
Would expect the generated htm-file to appear in folder public_html
When running WeeWX no errors (which is OK), but also nowhere the expected htm-file:
what needs to be done to activate file-generation? 
openweerdata_wx1.zip

Ton vanN

unread,
Mar 26, 2021, 8:41:42 AM3/26/21
to weewx-user
Related syslog-segment from RPI_CLI obtained with PuttySSH

Op vrijdag 26 maart 2021 om 10:00:19 UTC+1 schreef Ton vanN:
RPI7WeeWx_syslog210314.txt

Ton vanN

unread,
Apr 27, 2021, 4:53:54 AM4/27/21
to weewx-user
Expecting the result-file in folders /var/weewx/reports and by alias in  /home/weewx/public_html, but nothing appears.

Studying skin.conf under /home/weewx/skins/Standard have feeling that the link in section [[ToDate]] should[?] be

    #    [[ToDate]]
            # added for generation of HWA-uploadfile
            [[[owd]]]
                template = openweerdata_wx.htm.tmpl

But still no output coming.

Is the above setup correct assumption and fill-in,  some subtle missing element, or completely on wrong track?
Hints much appreciated.          


Op vrijdag 26 maart 2021 om 13:41:42 UTC+1 schreef Ton vanN:

Tom Keffer

unread,
Apr 27, 2021, 7:21:12 AM4/27/21
to weewx-user
Please try again, but this time set debug=1 first. 

Stop weewx
Set debug=1 (in weewx.conf)
Restart weewx
Post the log from startup. 

-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/d6591a4a-09d9-41f7-8092-5e0fcbc113ccn%40googlegroups.com.

Ton vanN

unread,
Apr 28, 2021, 2:30:52 AM4/28/21
to weewx-user
As requested, attached is the repeating segment of the syslog with debug=1

Op dinsdag 27 april 2021 om 13:21:12 UTC+2 schreef tke...@gmail.com:
RPI8WeeWx_syslog20210428.txt

Ton vanN

unread,
Apr 28, 2021, 4:07:00 AM4/28/21
to weewx-user
Brainwave?
Aiming at a first, basic realisation the folder /home/weewx/skins/Standard seeming the 'obvious' place, the template for generation of the HWA-file was put in that folder.
Considering similarity with generation of other html-files the call to the HWA-template was put in skin.conf in same folder /home/weewx/skins/Standard

Looking in /home/weewx at the below setting in weewx.conf, starting to doubt that such choice is correct.

        [[StandardReport]]
            # This is the old "Standard" skin. By default, it is not enabled.
            skin = Standard
            enable = false
       [[basic]]
            skin = basic
            HTML_ROOT = /var/weewx/reports
            [[[Extras]]]
                current = INST_SKIN_ROOT/basic/current.inc
                hilo = INST_SKIN_ROOT/basic/hilo.inc

If enable=false, it looks as if  'Standard'will not be called and (as consequence no call to the HWA-template at it's present location).
But if that assumption is correct, where should I alternatively put the template and call to the HWA-template to stay in line with 'normal practise'?
[Or simple enabling of 'Standard'?]
Op woensdag 28 april 2021 om 08:30:52 UTC+2 schreef Ton vanN:

Tom Keffer

unread,
Apr 28, 2021, 9:32:19 AM4/28/21
to weewx-user
Yes, the skin has to be enabled for any of the templates in the skin's folder to be processed. So, if you put your "HWA" template in ./Standard, then the report StandardReport must be enabled.

Or, you can put HWA in your "./basic" folder, then enable your basic report.

Either way will work. 

Tom Keffer

unread,
Apr 28, 2021, 9:40:06 AM4/28/21
to weewx-user
I should add that the template must also be listed in the corresponding skin.conf, in the [[ToDate]] section.

Ton vanN

unread,
Apr 30, 2021, 5:00:29 AM4/30/21
to weewx-user
Tom,
Puzzled/baffled, because following the hints from you and taking into account also the hints from the much earlier discussion between you and Franklin Bockstael, but still no file openweerdata.htm appearing in folder /home/weewx/public_html.

Have attached the (probably) relevant setup-files:
- weewx.conf which in folder /home/weewx enables Standard-skin and sets the related HTML_Root to /home/weewx/public_html
(on purpose, to get a different output from 'basic' etc.)
- skin.conf which in folder /home/weewx/skins/Standard in the [ToDate]-segment at the first lines enables/sets the template for owd (and disables the 'later', other templates)
- the template openweerdata.htm.tmpl as located in /home/weewx/skins/Standard

The adapted conf-files seem OK, but now the nagging feeling that the template has an inhibiting error.
But that is contradicted by the fact that Franklin Bockstael has it in operation since long time without problems.

During testing not running WeeWx as daemon, but 'discrete start' by command ./bin/weexd

Do you see a solution?


Op woensdag 28 april 2021 om 15:40:06 UTC+2 schreef tke...@gmail.com:
WeeWX_Google20210430.zip

gjr80

unread,
Apr 30, 2021, 5:28:53 AM4/30/21
to weewx-user
The config files and template tell us what should be happening but the log will tell us what is actually happening. Have you looked in the log? Are there any errors? You already have debug = 1 in weewx.conf so you should be able to work out from the log what is being generated and what is not. Post at least 10 minutes of log here and we can see what is going on. 

Gary

Ton vanN

unread,
Apr 30, 2021, 10:56:43 AM4/30/21
to weewx-user
As requested.

Scanning the logging see repeated reporting of loading of StdReport, but no text clearly pointing to errors in execution of StandardReport, nor any results.
But as explained in the first message of this thread, have 'limited' experience with weewx ...

Op vrijdag 30 april 2021 om 11:28:53 UTC+2 schreef gjr80:
SysLog20210430.rar

Tom Keffer

unread,
Apr 30, 2021, 11:34:47 AM4/30/21
to weewx-user
You have many instances of weewxd all running simultaneously. Kill them all, then start one.

Ton vanN

unread,
May 1, 2021, 6:28:37 AM5/1/21
to weewx-user
As requested, a leaner realisation.
In attached file the results of 2 sequences executed:
- in both cases 'clean restart' of the raspberry to ensure that no unintended process running, followed by 1 direct switch-on of weewx
- the sequences differ in the way going to logging, as described in the file
- in sequence1 apparently oneshot run before weewx stops. Exit of logging is by keyboard break.
- in sequence2 stream of repeating logging info. Also terminated the logging by keyboard break.

Op vrijdag 30 april 2021 om 17:34:47 UTC+2 schreef tke...@gmail.com:
SysLog20210501.rar

Anton vanNwnhzn@GMail

unread,
May 1, 2021, 7:24:41 AM5/1/21
to weewx-user

Addition to description of Sequence1.

Once weewx has been started, at Putty's CLI appears the expected stream of print-out.
At the keyboard break that stream ends with an error report.
Perhaps that error report also provides some relevant info?
See below the last printout from the loop and the error report mentioned above.

LOOP:   2021-05-01 13:17:59 CEST (1619867879) altimeter: 31.165113295698216, appTemp: 28.451970776082117, barometer: 31.09999991633433, cloudbase: 1300.0558352360692,    consBatteryVoltage: 12.743352544782736, dateTime: 1619867879, dewpoint: 27.19647824994742, heatindex: 32.6713164908827, heatingVoltage: 11.71583632592742, humidex: 32.6713164908827, inDewpoint: 31.079532540856405, inHumidity: 29.99999665337326, inTemp: 63.00000167331337, inTempBatteryStatus: 0, maxSolarRad: 812.0133117257177, outHumidity: 79.99999749002984, outTemp: 32.6713164908827, outTempBatteryStatus: 0, pressure: 31.09999991633433, radiation: 888.7102401456455, rain: 0, rainBatteryStatus: 0, rainRate: 0.0, referenceVoltage: 12.0, rxCheckPercent: 45.10949739082836, supplyVoltage: 12.0, txBatteryStatus: 0, usUnits: 1, UV: 12.441943362039037, windBatteryStatus: 0, windchill: 32.6713164908827, windDir: 359.99998494017905, windGust: 5.019940321204786e-07, windGustDir: 359.99998494017905, windSpeed: 4.1832835950827985e-07
^CTraceback (most recent call last):
  File "./bin/weewxd", line 264, in <module>
    main()
  File "./bin/weewxd", line 157, in main
    engine.run()
  File "/home/weewx/bin/weewx/engine.py", line 208, in run
    for packet in self.console.genLoopPackets():
  File "/home/weewx/bin/weewx/drivers/simulator.py", line 162, in genLoopPackets
    time.sleep(sleep_time)
KeyboardInterrupt
pi@Raspberry8:/home/weewx $

Op 1-5-2021 om 12:28 schreef Ton vanN:
You received this message because you are subscribed to a topic in the Google Groups "weewx-user" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/weewx-user/_KTQ9XcGIRo/unsubscribe.
To unsubscribe from this group and all its topics, send an email to weewx-user+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/weewx-user/fc4aac6f-befe-48f5-b8c8-da7d757dcfd1n%40googlegroups.com.
-- 

===============================================================
Contactinfo voor Anton van Nieuwenhuijzen:
Email    = ton...@gmail.com
Fax2Mail = (+31/0)84.8397303 [ook Voice2Mail]   
===============================================================
Deze E-mail en eventuele aanhangende files zijn 
alleen bestemd voor de geadresseerde(n). 
Als je deze E-mail ten onrechte hebt ontvangen, 
dan aub verwijderen en de afzender informeren.

Tom Keffer

unread,
May 1, 2021, 2:02:10 PM5/1/21
to weewx-user
This is most likely being caused by the terminal session detaching from the process. This can happen when you ssh into a computer, start a process, then exit the ssh session.

Either run weewxd as a daemon, or keep the terminal window open.

That's the best I can come up with.



Ton vanN

unread,
May 2, 2021, 2:35:33 AM5/2/21
to weewx-user
Tom,
;-) That was a really good advice!
Turned to running WeeWX as daemon, started the logging and got a different read-out which now includes a reference to the HWA-template.
That confirms my 'nagging feeling' that something is not OK with the handling of that HWA-template: see time-segment 08:21:59
Next step is finding a soulution .....

Op zaterdag 1 mei 2021 om 20:02:10 UTC+2 schreef tke...@gmail.com:
SysLog20210502.rar
Message has been deleted
Message has been deleted

Tom Keffer

unread,
May 2, 2021, 11:26:42 AM5/2/21
to weewx-user
It looks like the example skin "basic" has a few issues. To get it to work, go into basic/index.html.tmpl and change this

      <div id='data_table'>
        #include $Extras.current
        <p>&nbsp;</p>
        #include $Extras.hilo
      </div>

to this

      <div id='data_table'>
        #include "current.inc"
        <p>&nbsp;</p>
        #include "hilo.inc"
      </div>

In the file current.inc, change this

#if $trend.windSpeed.formatted > 0
      &#8679;
#elif $trend.windSpeed.formatted < 0
      &#8681;
#end if

to this

#if $trend.windSpeed.raw > 0
      &#8679;
#elif $trend.windSpeed.raw < 0
      &#8681;
#end if

On Sun, May 2, 2021 at 12:45 AM Ton vanN <ton...@gmail.com> wrote:
Digging a bit deeper, the reason given for that errorreport is correct, because subfolder INST_SKIN_ROOT indeed does not exist
Reason: [Errno 2] Bestand of map bestaat niet: '/home/weewx/skins/basic/INST_SKIN_ROOT/basic/current.inc'
But why is WeeWx asking for it? This is standard configuration (besides my activation of StdReport and related mod of skin.conf).

Op zondag 2 mei 2021 om 09:27:56 UTC+2 schreef Ton vanN:
Perhaps related:
the error reported in time-segment 08:21:58 is strange, because the file index.html.tmpl is actually present at the indicated location.

Op zondag 2 mei 2021 om 08:35:33 UTC+2 schreef Ton vanN:

Ton vanN

unread,
May 2, 2021, 3:29:59 PM5/2/21
to weewx-user
That aspect of /home/weewx/skin/basic now solved.
Related question: solution also applicable for v4.5?

Now focus on finding solution for HWA-template.

Op zondag 2 mei 2021 om 17:26:42 UTC+2 schreef tke...@gmail.com:

Ton vanN

unread,
May 2, 2021, 4:45:47 PM5/2/21
to weewx-user
The error report for the HWA-template is like
 
       May  2 22:20:46 Raspberry8 weewx[2139] ERROR weewx.cheetahgenerator: **** Ignoring template /home/weewx/skins/Standard/openweerdata.htm.tmpl
        May  2 22:20:46 Raspberry8 weewx[2139] ERROR weewx.cheetahgenerator: **** Reason: '>' not supported between instances of 'str' and 'int'

That seems to point to the section in the template which determines barotrend
with first scriptlines

      #if $trend.barometer.formatted > 0
          \$barTrend = "Rising";
      #end if

Not [?] to the earlier section which translates windDir.raw into windDirection, because those scriptlines have 'real' values for comparison

      #if $current.windDir.raw >= 11.25 and $current.windDir.raw < 33.75
      \$windDirection = "NNO";

Apparently some tiny detail which differentiates a comparison with integer value and a comparison with real value:
or is the problem in the lefthandside of the comparison?
Op zondag 2 mei 2021 om 21:29:59 UTC+2 schreef Ton vanN:

p q

unread,
May 2, 2021, 5:06:42 PM5/2/21
to weewx...@googlegroups.com
Looks like that could be it. The .formatted is turning the barometer value into a string and comparing it against zero, which is an int. Might try 

$trend.barometer.raw > 0

I would have thought that Python would have cast the string into an int for you, but apparently not. 



--
Peter Quinn
(415)794-2264

Tom Keffer

unread,
May 2, 2021, 5:32:44 PM5/2/21
to weewx-user
You're confusing it with Javascript. ☺

Javascript has lots of oddities like this. Try concatenating two arrays:
[] + []
You get an empty string. 

Ton vanN

unread,
May 2, 2021, 5:33:32 PM5/2/21
to weewx-user
Peter, that was the hint required!
The HWA-template now has become active.

Speculation, but could this be an aspect of changing from Python2.x to Python3.x?


Op zondag 2 mei 2021 om 23:06:42 UTC+2 schreef peterq...@gmail.com:

Ton vanN

unread,
May 2, 2021, 5:47:55 PM5/2/21
to weewx-user
Reason for my speculation:
at the HWA-forum several people already using WeeWx for years with the original HWA-template, probably started & still operating with Python2.x, and never heard complaints about the template.

That triggers another aspect:
when issuing for the HWA-Forum this updated version of the template, some advice must be given that (backwards) application with Python2.x must be checked.
Best to give this template-version and also the older version a related, distinguishing name.

Op zondag 2 mei 2021 om 23:33:32 UTC+2 schreef Ton vanN:

p q

unread,
May 2, 2021, 5:56:41 PM5/2/21
to weewx...@googlegroups.com
Yes. 

I can't find the official documentation but See https://devopedia.org/python-2-vs-3
Although Python is strongly typed, Python 2 permits strange comparisons: None < 3 < "2"



--
Peter Quinn
(415)794-2264

gjr80

unread,
May 2, 2021, 6:55:23 PM5/2/21
to weewx-user
It's a bit of python 2v3 and poor coding. The first thing to remember is that in a WeeWX Cheetah template .formatted (now .formatted()) returns a string, .raw returns the raw value; typically an int or a float or None (though it could also be a string if the underlying field is a string but there are none of those in any of the WeeWX shipped schemas).

Under python2 you can compare strings to numerics (int and float) without error, that being said you will not get the correct answer but it won't raise an error. Try doing this:

gary@buster5:~$ python2
Python 2.7.16 (default, Oct 10 2019, 22:02:15)
[GCC 8.3.0] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> "5" > 4
True
>>> "3" > 4
True
>>>


Note that the second expression gives and incorrect answer. Python 3 is a little more picky, trying the same under python3 raises an error:

gary@buster5:~$ python3
Python 3.7.3 (default, Jan 22 2021, 20:04:44)
[GCC 8.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> "5" > 4

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: '>' not supported between instances of 'str' and 'int'


Then add into the mix the fact that a .raw could return the python value None. Python 2 will happily allow None in a comparison but python3 will not, it will raise a TypeError albeit with a different error message.

So getting back to the original comparison expression in the report. Under python2 it will operate without error, it may give the wrong result under certain conditions but it will not cause an error that will force the template generation to abort. Under python3 the expression will raise an error on every generation and the template will abort. The obvious solution is to change .format to .raw, that will work under most conditions but if $trend.barometer.raw is ever None (quite possible on startup or if there has been an interruption) it will fail. The solution is to either catch the error and deal with it or alter the conditional to check for None, eg (untested):

#if $trend.barometer.raw is not None and $trend.barometer.raw > 0
#do something
#end if

Gary

Ton vanN

unread,
May 4, 2021, 6:13:36 AM5/4/21
to weewx-user
New template now running without errors (on WeeWX4.4.0&Python3.x on Raspian_Buster) and the output-file checked to be compatible with the serversoftware of HetWeerActueel (version HWA2.0)
Backwards compatibility of this new template with older WeeWX-versions (using Python2.x, and now using the 'old' template) not checked!

Duplicate posting is not a good idea.
Also because the members of HetWeerActueel are >90% dutch-speaking, therefore the resulting solution is described (in  dutch) at https://www.hetweeractueel.nl/forum/viewtopic.php?p=73156#p73156

Would like to thank all contributors to my probing & trying:
your hints really assisted to keep me to move forward!

Op maandag 3 mei 2021 om 00:55:23 UTC+2 schreef gjr80:

Ton vanN

unread,
Dec 22, 2021, 7:29:25 AM12/22/21
to weewx-user
Improvement always possible, ;-) sometimes needed.

The setup with the HWA-template correctly produces the output-file, but the periodicity is unstable.
Any idea what could be the cause?

Op dinsdag 4 mei 2021 om 12:13:36 UTC+2 schreef Ton vanN:
Reply all
Reply to author
Forward
0 new messages