Display METAR Data in Seasons 4.6.2

325 views
Skip to first unread message

storm...@gmail.com

unread,
Mar 1, 2022, 6:39:56 PM3/1/22
to weewx-user

1         Download copy of weewx-metar from  https://github.com/danimaciasperea/weewx-metar.

2         Copy file into /home/weewx/bin/user/

3         Add the following to the skin.conf:

[CheetahGenerator]

                                 # Possible encodings include 'html_entities', 'strict_ascii', 'normalized_ascii',

                                # as well as those listed in https://docs.python.org/3/library/codecs.html#standard-encodings

                                 encoding = html_entities

                                  search_list_extensions = user.metargenerator.MyMetarSearch

…..

[MetarReport] 

                                                refresh_interval = 5        # Obtain every X minutes            

                                                # Metar Airports to generate                                    

                                                [[KCLE]]                   # Create a new Cheetah tag which will have a _metar suffix: $KCLE_metar

                                                [[KCGF]]

 

4  Create an “inc” file. Example “metar.inc”.  Add the following to the file

<table>

<tr>

<td class="widget_contents"> $KCLE_metar </td>

<td class="widget_contents"> $KCGF_metar </td>

</tr>

</table>

 

5  In the index.html.tmpl file add the following:

#include "metar.inc"

Place this wherever you would like the data to appear.

6. Restart Weewx

METARdata.png

MikeQ

unread,
Jun 1, 2023, 11:21:59 PM6/1/23
to weewx-user
I am in the process of upgrading my WeeWX installation and switching to the Belchertown skin.  Since you posted the steps for adding METARs to the Seasons skin, I will post them for those using the Belchertown skin and both will be here for anyone who searches the forum for "metar".

Augment Weewx station data with Metar reports obtained from aviationweather.gov
Works with WeeWX v4.10.2 & Belchertown skin v1.3.1 on Raspbian Bullseye (weewx package install)

1. Download a copy of weewx-metar from github
       $ wget -c https://github.com/danimaciasperea/weewx-metar/archive/refs/heads/master.zip -O weewx-metar.zip

2. Unzip it and:
       $ sudo cp metargenerator.py /usr/share/weewx/user

3. Add the following to weewx.conf under [StdReport] [[Belchertown]]

       [[[CheetahGenerator]]]
         search_list_extensions = user.belchertown.getData,user.metargenerator.MyMetarSearch

       [[[MetarReport]]]
         refresh_interval = 5
         [[[[KBOI]]]]
         [[[[KONO]]]]
         [[[[KEUL]]]]
         [[[[KMEV]]]]

4. Create a .inc file in /etc/weewx/skin/Belchertown depending on where you want to display the METARS on the main page
   (see https://github.com/poblabs/weewx-belchertown#add-custom-content-to-the-front-page):
        $ sudo nano /etc/weewx/skins/Belchertown/index_hook_after_forecast.inc

        <p style="font-size:24px">METARs</p>
        <table>
          <tr>
            <td style="padding:10px;vertical-align:top">$KONO_metar</td>
            <td style="padding:10px;vertical-align:top">$KEUL_metar</td>
          </tr>
          <tr>
            <td style="padding:10px;vertical-align:top">$KBOI_metar</td>
            <td style="padding:10px;vertical-align:top">$KMEV_metar</td>
          </tr>
        </table>

5. If you do not want to display TAFs along with the METARs, then edit metargenerator.py and change this line:
        url = "https://www.aviationweather.gov/adds/metars?station_ids=%s+&std_trans=translated&chk_metars=on&hoursStr=most+recent+only&chk_tafs=on&submitmet=Get+Weather" % (airport)
   to tafs=off instead of tafs=on

Nate Bargmann

unread,
Jun 2, 2023, 8:37:45 AM6/2/23
to weewx...@googlegroups.com
I just added this extension and while I added it to my Standard skin, I
don't think that is where the problem lies. I see the following from
the logs:

Jun 02 07:25:29 wxbox weewxd[5488]: metargenerator.py: request URL - https://www.aviationweather.gov/adds/metars?station_ids=KMYZ+&std_trans=translated&chk_metars=on&hoursStr=most+recent+only&chk_tafs=on&submitmet=Get+Weather
Jun 02 07:25:29 wxbox weewxd[5488]: metargenerator.py: error: Cannot get Metar Report (KMYZ_metar). Recovering the last file saved.
Jun 02 07:25:29 wxbox weewxd[5488]: metargenerator.py: error: There could not be found an older Metar Report. Skipping!
Jun 02 07:25:29 wxbox weewxd[5488]: metargenerator.py: request URL - https://www.aviationweather.gov/adds/metars?station_ids=KBIE+&std_trans=translated&chk_metars=on&hoursStr=most+recent+only&chk_tafs=on&submitmet=Get+Weather
Jun 02 07:25:29 wxbox weewxd[5488]: metargenerator.py: error: Cannot get Metar Report (KBIE_metar). Recovering the last file saved.
Jun 02 07:25:29 wxbox weewxd[5488]: metargenerator.py: error: There could not be found an older Metar Report. Skipping!
Jun 02 07:25:29 wxbox weewxd[5488]: metargenerator.py: Generated 0 metar tables in 0.01 seconds

When I open either URL as shown in the log I get a valid METAR Web page
(see attached screen shots), yet I am getting "Error - No METAR
available" in the generated Web page.

I am using the latest metargenerator.py from the Git clone of the
referenced repository. Perhaps I need to open an issue on GitHub for
this extension?

- Nate

--
"The optimist proclaims that we live in the best of all
possible worlds. The pessimist fears this is true."
Web: https://www.n0nb.us
Projects: https://github.com/N0NB
GPG fingerprint: 82D6 4F6B 0E67 CD41 F689 BBA6 FB2C 5130 D55A 8819

Screenshot from 2023-06-02 07-36-40.png
Screenshot from 2023-06-02 07-36-55.png
signature.asc

MikeQ

unread,
Jun 2, 2023, 1:35:40 PM6/2/23
to weewx-user
Did you test the URL from the box running WeeWX?  I'm wondering if you have a DNS or some other connectivity problem on that box.  You could try running:


and see if you get the html response for the page.

Nate Bargmann

unread,
Jun 2, 2023, 1:53:20 PM6/2/23
to weewx...@googlegroups.com
* On 2023 02 Jun 12:36 -0500, MikeQ wrote:
> Did you test the URL from the box running WeeWX? I'm wondering if you have
> a DNS or some other connectivity problem on that box. You could try
> running:
>
> curl
> -s https://www.aviationweather.gov/adds/metars?station_ids=KBIE+&std_trans=translated&chk_metars=on&hoursStr=most+recent+only&chk_tafs=on&submitmet=Get+Weather
>
> and see if you get the html response for the page.

I had to quote the URL to keep the shell from interpreting the special
characters and once I did that, I did get the HTML page. This is from
the computer running Weewx.


Here is the output:


----------------------------8<--------------------------------------

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd">
<HTML>
<HEAD>
<TITLE>ADDS - METARS form results</TITLE>
<!-- LINK REL="StyleSheet" type="text/css" HREF="/layout/awc/mystyle.css"-->
</HEAD>
<BODY BGCOLOR="#FFFFFF">
<TABLE SUMMARY="This table is used for formatting purposes only" BORDER=0 CELLPADDING=3 CELLSPACING=0>
<TR VALIGN="top">
<TD ALIGN="left" COLSPAN="2">
<H2>Aviation Digital Data Service (ADDS)</H2>
Output produced by METARs form (1746&#160;UTC&nbsp;02 June 2023)<BR>
found at <A HREF="http://www.aviationweather.gov/metar/data/"> http://www.aviationweather.gov/metar/data/</A><BR>&#160;<BR>
</TD>
</TR>
<TR VALIGN="top">
<TD ALIGN="left" COLSPAN="2">
<TR VALIGN="top">
<TD ALIGN="right">
<FONT COLOR="#9999CC"><STRONG>METAR text:</STRONG></FONT>
</TD>
<TD ALIGN="left" BGCOLOR="#CDCDCD">
<STRONG>KMYZ 021735Z AUTO 15003KT 10SM SCT110 27/20 A3000 RMK AO2
LTG DSNT W</STRONG>
</TD>
</TR>
<TR VALIGN="top">
<TD ALIGN="right">
<FONT COLOR="#9999CC"><STRONG>Conditions at:</STRONG></FONT>
</TD>
<TD ALIGN="left">
KMYZ
(MARYSVILLE , KS, US) observed 1735&#160;UTC&#160;02 June 2023
</TD>
</TR>
<TR VALIGN="top">
<TD ALIGN="right">
<FONT COLOR="#9999CC"><STRONG>Temperature:</STRONG></FONT>
</TD>
<TD ALIGN="left">
27&#46;0&deg;C (81&deg;F)
</TD>
</TR>
<TR VALIGN="top">
<TD ALIGN="right">
<FONT COLOR="#9999CC"><STRONG>Dewpoint:</STRONG></FONT>
</TD>
<TD ALIGN="left">
20&#46;0&deg;C (68&deg;F) [RH&#160;=&#160;66&#37;]
</TD>
</TR>
<TR VALIGN="top">
<TD ALIGN="right">
<FONT COLOR="#9999CC"><STRONG>Pressure (altimeter):</STRONG></FONT>
</TD>
<TD ALIGN="left">
30&#46;00&#160inches&#160;Hg (1016&#46;0&#160;mb)
</TD>
</TR>
<TR VALIGN="top">
<TD ALIGN="right">
<FONT COLOR="#9999CC"><STRONG>Winds:</STRONG></FONT>
</TD>
<TD ALIGN="left">
from the SSE (150&#160;degrees) at 3&#160;MPH (3&#160;knots; 1.5&#160;m&#47;s)
</TD>
</TR>
<TR VALIGN="top">
<TD ALIGN="right">
<FONT COLOR="#9999CC"><STRONG>Visibility:</STRONG></FONT>
</TD>
<TD ALIGN="left">
10 or more&#160;miles&#160;(16+&#160;km)
</TD>
</TR>
<TR VALIGN="top">
<TD ALIGN="right">
<FONT COLOR="#9999CC"><STRONG>Ceiling:</STRONG></FONT>
</TD>
<TD ALIGN="left">
at least 12,000 feet AGL
</TD>
</TR>
<TR VALIGN="top">
<TD ALIGN="right">
<FONT COLOR="#9999CC"><STRONG>Clouds:</STRONG></FONT>
</TD>
<TD ALIGN="left">
scattered clouds at 11000 feet AGL
</TD>
</TR>
<TR VALIGN="top">
<TD ALIGN="right">
<FONT COLOR="#9999CC"><STRONG>Weather:</STRONG></FONT>
</TD>
<TD ALIGN="left">
automated observation with no human augmentation;<BR>there may or may not be significant weather present at this time
</TD>
</TR>
<TR VALIGN="middle">
<TD ALIGN="left" COLSPAN="2">
<HR WIDTH="65%">
</TD>
</TR>
</TABLE>
</BODY>
</HTML>

---------------------------->8--------------------------------------


Perhaps the next step is that I need to look at the extension code and
try to figure out where it is failing. Sigh...
signature.asc

MikeQ

unread,
Jun 2, 2023, 2:31:05 PM6/2/23
to weewx-user
One more thought - what version of Python are you running?  The original weewx-metar code was written in 2018 for Python2 and was re-written 2 years ago for Python3.  The current version in master on github is the Python3 version.

Nate Bargmann

unread,
Jun 2, 2023, 2:58:21 PM6/2/23
to weewx...@googlegroups.com
* On 2023 02 Jun 13:31 -0500, MikeQ wrote:
> One more thought - what version of Python are you running? The original
> weewx-metar code was written in 2018 for Python2 and was re-written 2 years
> ago for Python3. The current version in master on github is the Python3
> version.

I am running on Amrbian (Debian) Bullseye which has Python 3.9.2. Would
the extension benefit from running Weewx with debug mode enabled?
signature.asc

MikeQ

unread,
Jun 2, 2023, 3:15:14 PM6/2/23
to weewx-user
I'm running the same thing.  I don't think you will find anything in debug mode since metargenerator.py seems to be running and it logs to syslog directly.  I am not a python programmer, but I think you will need to add some additional "syslog.syslog(syslog.LOG_INFO,......." code to find out exactly what is happening in def statsHTMLTable(self, airport): when it tries to get the metar.

Michael Bruski

unread,
Jun 2, 2023, 4:07:24 PM6/2/23
to weewx-user
I actually did the python3 rewrite and provided it to the original author to post on github.   I may have changed my local copy sometime later to fix a problem with the URL but can't say for sure.  I have about 7 lines in my generator that are commented out.  I know I didn't post further updates to the author.   I could post my current code block for statsHTMLTable() here but don't know how to go about getting it formatted correctly.
Either that or send me your email address and I'll send it to you the file.

I also created a tafgenerator based on the metargenerator so that I can post that separately from the METAR blocks.

Michael Bruski

unread,
Jun 2, 2023, 4:47:47 PM6/2/23
to weewx-user
Attached is a diff file for my current changes.  Note that this also disables the request for TAF data as I request that separately using tafgenerator.py.
In Seasons/skin.conf just tack another couple lines at the end for example:

[TafReport]
  [[kbwi]]

and append ", user.tafgenerator.MyTafSearch" to the search_list_extensions in the same file.

I'll submit another pull request on github to get these changes in.

My taf.inc for the Seasons skin is also attached.
tafgenerator.py
metargenerator.diff
taf.inc

Nate Bargmann

unread,
Jun 2, 2023, 6:44:12 PM6/2/23
to weewx...@googlegroups.com
* On 2023 02 Jun 15:48 -0500, Michael Bruski wrote:
> Attached is a diff file for my current changes. Note that this also
> disables the request for TAF data as I request that separately using
> tafgenerator.py.

I've no need to separate the two so I just modified line 101 in the
original file as that seemed to be the only substantive change and I
still get the same failure so I've shelved this idea until such time as
it is fixed.
signature.asc

Michael Bruski

unread,
Jun 2, 2023, 7:44:06 PM6/2/23
to weewx-user
In reviewing the steps provided by MikeQ above, I see an issue with step 3.  The search_list_extensions under the [[[CheetahGenerator]]] section should not be modified in weewx.conf but in skin.conf.  If you don't find the search_list_extensions line in that section, just add it.  The original author made it clear in his write-up that the METAR data will not be found by the skin unless you call the user.metargenerator.MyMetarSearch function from within the skin.  Also, the [MetarReport] block is appended at the end of the skin.conf file.  Notice single square bracket.  Your list of airports will be encapsulated in double square brackets following the section heading.  For example:

[MetarReport]
  refresh_interval = 5
  [[KBOI]]
  [[KONO]]
  ...

Nate Bargmann

unread,
Jun 2, 2023, 8:02:32 PM6/2/23
to weewx...@googlegroups.com
* On 2023 02 Jun 18:44 -0500, Michael Bruski wrote:
> In reviewing the steps provided by MikeQ above, I see an issue with step
> 3. The search_list_extensions under the [[[CheetahGenerator]]] section
> should not be modified in weewx.conf but in skin.conf. If you don't find
> the search_list_extensions line in that section, just add it. The original
> author made it clear in his write-up that the METAR data will not be found
> by the skin unless you call the user.metargenerator.MyMetarSearch function
> from within the skin.


I was indeed adding the extension line in the skin.conf as I already
have an extension for extended statistics in use.

> Also, the [MetarReport] block is appended at the end
> of the skin.conf file. Notice single square bracket. Your list of
> airports will be encapsulated in double square brackets following the
> section heading. For example:
>
> [MetarReport]
> refresh_interval = 5
> [[KBOI]]
> [[KONO]]
> ...

That mirrors what I have near the end of the skin.conf file, after the
ImageGenerator and before the Generators sections.

I think everything in the skin files was working, the errors originally
seemed to come from some module being called from within
metargenerator.py as the text of the error messages are slightly
different from what is in that file to be sent to syslog.
signature.asc

MikeQ

unread,
Jun 2, 2023, 8:42:32 PM6/2/23
to weewx-user
In the Customization Guide (https://www.weewx.com/docs/customizing.htm) it explains the use of skin.conf vs weewx.conf.
See Customizing reports | Options | Processing order

Here is the recommendation:

"Although it is possible to modify the options at any level, as the user of a skin, it is usually best to keep your modifications in the WeeWX configuration file (weewx.conf) if you can. That way you can apply any fixes or changes when the skin author updates the skin, and your customizations will not be overwritten."

I do all my skin.conf additions in weewx.conf so they are not overwritten when the skin or weewx itself is upgraded.  I also like having all my modifications in one place instead of scattered around the weewx directory structure.  There is a note just above the recommendation that explains the hierarchy differences between the .conf files, specifically "options specified in weewx.conf must use two extra sets of brackets" which is why my example above has more brackets than the original author's example.

Nate Bargmann

unread,
Jun 3, 2023, 11:36:53 AM6/3/23
to weewx...@googlegroups.com
Thanks to a tip from Michael Bruski, after installation of the
python3-requests package, all is working with the current
metargenerator.py file from Dani's GitHub repository.

Mike sent me a copy of his file which moved the "import requests" line
to the top of the file and then I could see the traceback that the
"requests" module was not found. I assumed that this was a module
private to weewx as I did not see the traceback with the original file.
I can only guess that the traceback message wasn't being sent up the
chain to be logged and that is what puzzled me.

Regardless, make a note that the python3-requests module is a dependency
for this extension.

I've attached another screenshot showing the METAR data for the nearby
airports.
Screenshot from 2023-06-03 10-21-35.png
signature.asc
Reply all
Reply to author
Forward
0 new messages