Author Topic: Saratoga template using weewx-wd / issue when update  (Read 586 times)

0 Members and 1 Guest are viewing this topic.

Offline jeanphi500

  • Member
  • *
  • Posts: 18
Saratoga template using weewx-wd / issue when update
« on: February 03, 2021, 04:30:14 PM »
I started a topic in the weewx section but now that part is ok and only the Saratoga part is not yet in order.

To quickly summarize, I've been using the Saratoga templates since 2012 I think, I was running wview at that time.
It worked like a charm. But I had to replace the weather station (an Oregon WMRS200) due to issues with the sensors.

My new station is a fine offset WH2650 clone. I switched from wview to weewx.
Weewx is now working flawlessly on it.

I installed the weewx-wd driver that is generating Weather-Display data and the necessary files to work with the Saratoga templates.
It's mostly working but some things are not yet ok.

I see that some of the data fields are  incorrect. The strange thing is that if I press Ctrl-F5 (force a refresh of the page) the fields are fine. But as soon as auto update kicks in (text turns to green) some of the values change and are wrong.
I wonder if there is not a parsing issue somewhere.
For example, I've seen that instead of the date in the message "last updated @ [DATE]" I'm getting the cloud height. I looked in the raw text file (the one that gets parsed) and realized that the date is right next to the cloud height. SO I wonder if there is not an offset somewhere.

The problem can be seen here:
Weewx output -> http://jalhay.info/meteo2/index.html
Saratoga output -> http://jalhay.info/meteo2/wxindex.php

Thanks for the help!
(I used the latest version of all scripts)

On top of that issue, it seems some french characters do not get through correctly (is that an issue with unicode ?)
« Last Edit: February 03, 2021, 04:35:05 PM by jeanphi500 »

Offline saratogaWX

  • Administrator
  • Forecaster
  • *****
  • Posts: 8307
  • Saratoga, CA, USA Weather - free PHP scripts
    • Saratoga-Weather.org
Re: Saratoga template using weewx-wd / issue when update
« Reply #1 on: February 04, 2021, 01:38:22 PM »
The Saratoga templates do not use UTF-8 natively -- for French, the default is ISO-8859-1 (Latin) for display.  If you edit your files with Unicode enabled, it will show odd characters when displayed on the webpage.

You can check your site's clientraw*.txt values versus the expected native WD set by using the WD-parser.

It looks like there may be an extra _ (underscore) in one of the variables, which may be throwing off the split-on-space so your date field #74 is not being picked up.

48   Current Condition Icon   Icon   --- ()
49   Weather Desc   Label   
50   Baro Trend last hour   hPa   ---_ hPa

Maybe it's an extra space emitted for #49 (weather description) .. so it would be in the WeeWx template for clientraw.txt

That area should appear as

48   Current Condition Icon   Icon   0 (Sunny)
49   Weather Desc   Label   Sunny/Dry
50   Baro Trend last hour   hPa   -0.3 hPa = -0.01 inHg
Ken True/Saratoga, CA, USA main site: saratoga-weather.org
Davis VP1+ FARS, Boltek-PCI/NexStorm, microSferics ToA, Blitzortung RED, GRLevel3, WD, WL, VWS, Cumulus, Meteobridge/hub
Free weather PHP scripts/website templates - update notifications on Twitter saratogaWXPHP

Offline jeanphi500

  • Member
  • *
  • Posts: 18
Re: Saratoga template using weewx-wd / issue when update
« Reply #2 on: February 04, 2021, 02:31:58 PM »
Wow that parser is handy!

You're right there is most probably a space too much somewhere.
I will have a look in the Python that generates the WD files (weewx-wd).

I'll report here!

Thanks!

Offline jeanphi500

  • Member
  • *
  • Posts: 18
Re: Saratoga template using weewx-wd / issue when update
« Reply #3 on: February 04, 2021, 03:52:36 PM »
OK I have found a work around..
The clientraw.txt file comes from a template. I forced the 2 values for the current condition icon (#48)and the Weather Desc (#49) to "--- "

Now the parser is working fine and all values correspond.. thanks a lot for that  [tup]

I will now look at the Unicode issue.

There is still one thing that does not seem to be 100% ok. That's the moon cycle and picture. Not sure if that's a field that comes from WD too or if it's computed locally.
And I will also try the wxgraphs2.php that you once shared on this forum... It would be good to get the graphs from weewx instead of the non existent graphs from WD :)

Offline jeanphi500

  • Member
  • *
  • Posts: 18
Re: Saratoga template using weewx-wd / issue when update
« Reply #4 on: February 04, 2021, 04:26:55 PM »
OK I updated the Settings.php file and it's now reading it fine.
Only the fastest wind gust seems still to read "février" wrongly.. I'm not sure where that text comes from...

Another question I had was if I could set the refresh rate of the page. I have a refresh rate of 5 minutes on weewx and I don't need the page to refresh faster than that  :-)

Offline saratogaWX

  • Administrator
  • Forecaster
  • *****
  • Posts: 8307
  • Saratoga, CA, USA Weather - free PHP scripts
    • Saratoga-Weather.org
Re: Saratoga template using weewx-wd / issue when update
« Reply #5 on: February 04, 2021, 05:06:56 PM »
OK I have found a work around..
The clientraw.txt file comes from a template. I forced the 2 values for the current condition icon (#48)and the Weather Desc (#49) to "--- "

Now the parser is working fine and all values correspond.. thanks a lot for that  [tup]

I will now look at the Unicode issue.

There is still one thing that does not seem to be 100% ok. That's the moon cycle and picture. Not sure if that's a field that comes from WD too or if it's computed locally.
And I will also try the wxgraphs2.php that you once shared on this forum... It would be good to get the graphs from weewx instead of the non existent graphs from WD :)
Yes, when WD is the Weather station software type, then the following tags are used for astronomy (in the home page and wxastronomy).
Your testtags.php?sce=view shows
Code: [Select]
// General or Non-Weather Specific Sun/Moon
// ----------------------------------------
$time = '22:55';
$date = '04/02/2021';
$sunrise = '08:09';
$time_minute = '55';
$time_hour = '22';
$date_day = '04';
$date_month = '02';
$date_year = '2021';
$monthname = 'février';    // Current month name
$dayname = 'jeudi';    // Current day name
$sunset = '17:30';// sunset time
$moonrisedate = '   N/A';// moon rise date
$moonrise = '   N/A';// moon rise time
$moonsetdate = '   N/A';// moon set date
$moonset = '   N/A';// moon set time
$moonage = '   N/A';// current age of the moon (days since new moon)
$moonphase = '50%';// Moon phase %
$moonphasename = 'Last quarter'; // 10.36z addition
$marchequinox = '   N/A';// March equinox date
$junesolstice = '   N/A';// June solstice date
$sepequinox = '   N/A';// September equinox date
$decsolstice = '   N/A';// December solstice date
$newmoon = '   N/A';// Date/time of the previous new moon
$nextnewmoon = '   N/A';// Date/time of the next new moon for next month
$firstquarter = '   N/A';// Date/time of the next/last first quarter moon
$lastquarter = '   N/A';// Date/time of the next/last last quarter moon
$fullmoon = '   N/A';// Date/time of the next/last full moon
$fullmoondate = '   N/A';// Date of the next/last full moon (date only)
(note the missing values).

You can force the use of the internal calculations for the needed numbers by changing ajax-dashboard.php
Code: [Select]
// --- end of settings -------------------

if($SITE['WXsoftware'] == 'WD') {
to
Code: [Select]
// --- end of settings -------------------

if(false and $SITE['WXsoftware'] == 'WD') {

and wxastronomy.php from
Code: [Select]
if(isset($SITE['WXsoftware']) and $SITE['WXsoftware'] == 'WD') {
to
Code: [Select]
if(false and isset($SITE['WXsoftware']) and $SITE['WXsoftware'] == 'WD') {
and those should fix the missing sun/moon/season times on the home and wxastronomy.php pages.
Ken True/Saratoga, CA, USA main site: saratoga-weather.org
Davis VP1+ FARS, Boltek-PCI/NexStorm, microSferics ToA, Blitzortung RED, GRLevel3, WD, WL, VWS, Cumulus, Meteobridge/hub
Free weather PHP scripts/website templates - update notifications on Twitter saratogaWXPHP

Offline saratogaWX

  • Administrator
  • Forecaster
  • *****
  • Posts: 8307
  • Saratoga, CA, USA Weather - free PHP scripts
    • Saratoga-Weather.org
Re: Saratoga template using weewx-wd / issue when update
« Reply #6 on: February 04, 2021, 05:22:05 PM »
OK I updated the Settings.php file and it's now reading it fine.
Only the fastest wind gust seems still to read "février" wrongly.. I'm not sure where that text comes from...
There are two sources for translations -- the main language-fr.txt and language-fr.js  -- one (or maybe both) may have UTF-8 characters in them and should be replaced with the corresponding ISO-8859-1 characters.  Notepad++ has a easy convert from UTF8 to ANSI text function.
Also, Settings.php has an entry
Code: [Select]
$SITE['monthNames'] = array(  // for wxastronomy page .. replace with month names in your language
'January','February','March','April','May','June',
'July','August','September','October','November','December'
);
which should be changed (if your system running Weewx/WDskin) is using French locale to have
Code: [Select]
$SITE['monthNames'] = array(  // for wxastronomy page .. replace with month names in your language
"janvier","février","mars","avril","mai","juin",
"juillet","août","septembre","octobre","novembre","décembre"
);
so the months can come back correctly.
Quote
Another question I had was if I could set the refresh rate of the page. I have a refresh rate of 5 minutes on weewx and I don't need the page to refresh faster than that  :-)
The default in the saratoga template set is to NOT refresh the page itself -- you can add a <meta http-equiv="Refresh" content="300" /> to the top.php (<head> section) to force the browser to reload the page every 5 minutes.  The AJAX updates to some of the displayed variables are loaded from clientraw.txt at the interval and number of reloads specified in ajaxWDwx.js
Code: [Select]
var reloadTime = 10000;       // reload AJAX conditions every 5 seconds (= 5000 ms)
var maxupdates = 12;          // Maxium Number of updates allowed (set to zero for unlimited)
                             // maxupdates * reloadTime / 1000 = number of seconds to update
and those settings result in updates every 10 seconds for a maximum of 12 times (after which, the automatic updates cease until the page is reloaded).
Ken True/Saratoga, CA, USA main site: saratoga-weather.org
Davis VP1+ FARS, Boltek-PCI/NexStorm, microSferics ToA, Blitzortung RED, GRLevel3, WD, WL, VWS, Cumulus, Meteobridge/hub
Free weather PHP scripts/website templates - update notifications on Twitter saratogaWXPHP

Offline jeanphi500

  • Member
  • *
  • Posts: 18
Re: Saratoga template using weewx-wd / issue when update
« Reply #7 on: February 04, 2021, 06:01:03 PM »
Wowww what a service !  [tup] [tup] [tup]

It fixed most of the stuff!
Only the wxastronomy is not yet ok.. For the current conditions it's fine but for future moon phases and events they are stuck to epoch time 0 :)

Anyway I'm really pleased with the result ! Thanks again Ken !
I will continue tomorrow to customize the menus but most of the stuff is in place now  =D&gt;

Offline saratogaWX

  • Administrator
  • Forecaster
  • *****
  • Posts: 8307
  • Saratoga, CA, USA Weather - free PHP scripts
    • Saratoga-Weather.org
Re: Saratoga template using weewx-wd / issue when update
« Reply #8 on: February 04, 2021, 07:01:39 PM »
You're welcome!

You may have to use
Code: [Select]
sudo raspi-config and select Locale as fr_BE.ISO-8859-1 to get the best results for date.  Also, change your webserver default to not include charset=UTF-8 in the header.

The wxastronomy.php page is still trying to use the (non existent) moon and season dates from testtags.php.

Change wxastronomy.php
Code: [Select]
if(isset($SITE['WXsoftware']) and $SITE['WXsoftware'] == 'WD') {
to
Code: [Select]
if(false and isset($SITE['WXsoftware']) and $SITE['WXsoftware'] == 'WD') {
to force the internal calculations to be used instead.
« Last Edit: February 04, 2021, 07:04:53 PM by saratogaWX »
Ken True/Saratoga, CA, USA main site: saratoga-weather.org
Davis VP1+ FARS, Boltek-PCI/NexStorm, microSferics ToA, Blitzortung RED, GRLevel3, WD, WL, VWS, Cumulus, Meteobridge/hub
Free weather PHP scripts/website templates - update notifications on Twitter saratogaWXPHP

Offline jeanphi500

  • Member
  • *
  • Posts: 18
Re: Saratoga template using weewx-wd / issue when update
« Reply #9 on: February 05, 2021, 05:25:42 AM »
OK I worked around the issue in wxastronomy.
Adding false was not sufficient. It seems the global variables were still set somewhere and picked up by the isset function.
I unset them all and now it picks up the Saratoga generated ones  [tup]

For the locale, you're right. The field is read from testtags that is not encoded properly. I manually edited the file and uploaded that one and it shows correctly.
So it means as you say that I need to change that in the Raspberry config... Will try!

Offline jeanphi500

  • Member
  • *
  • Posts: 18
Re: Saratoga template using weewx-wd / issue when update
« Reply #10 on: February 05, 2021, 07:25:02 AM »
I tried changing the locale on the Pi but that does not seem to work. I think there is a setting in the skin.conf of weewx-wd that seems to set the encoding (utf8 by default). The comment says:
Code: [Select]
# Possible encoding are 'html_entities', 'utf8', or 'strict_ascii'

Another option would then be to add some code to detect and replace the bad character. After testtags gets evaluated and before it gets displayed.. Would that work?
« Last Edit: February 05, 2021, 07:36:01 AM by jeanphi500 »

Offline jeanphi500

  • Member
  • *
  • Posts: 18
Re: Saratoga template using weewx-wd / issue when update
« Reply #11 on: February 05, 2021, 07:35:26 AM »
OK I read in the weewx user guide about those encoding options.
I switched to this one :
Code: [Select]
html_entities Non 7-bit characters will be represented as HTML entities (e.g., the degree sign will be represented as &#176;)
And that is working  [tup]

Yup yup, now everything is fine!

Offline jeanphi500

  • Member
  • *
  • Posts: 18
Re: Saratoga template using weewx-wd / issue when update
« Reply #12 on: February 10, 2021, 08:40:35 AM »
Hi Ken

I have a last question...
Is it possible to have the NOAA reports displayed as they were with wview?
The format of the NOAA from weewx is the same as wview.

As I'm setting Weather-Display as provider for the templates data, it seems NOAA reports display gets disabled (there is a page wxhistory.php but that one is empty).

I tried updating flyout_menu.xml to add a link to wxnoaaclimatereports, and copy pasting the noaa php pages from my other website but that does not yet work.
I think it's partly because those files are also customized in function of the data provider. And if that reads WD it won't recognize it. I tried forcing it to "WV" but that's also not working...

Any idea what would be needed in terms of updates to make it work?
Thx!

BTW: my station address moved to jalhay.info/meteo

Offline saratogaWX

  • Administrator
  • Forecaster
  • *****
  • Posts: 8307
  • Saratoga, CA, USA Weather - free PHP scripts
    • Saratoga-Weather.org
Re: Saratoga template using weewx-wd / issue when update
« Reply #13 on: February 10, 2021, 11:25:34 AM »
You might try 'tricking' the page to think another weather software is running.

On wxnoaaclimatereports.php try changing
Code: [Select]
<?php include_once("include-NOAA-reports.php"?> to
Code: [Select]
<?php 
$SITE
['WXsoftware']     = 'WV';  
include_once(
"include-NOAA-reports.php"?>

and see if that allows the page to display.

I assume that you have include-NOAA-reports.php installed from the WV-plugin.zip for this to work.
Ken True/Saratoga, CA, USA main site: saratoga-weather.org
Davis VP1+ FARS, Boltek-PCI/NexStorm, microSferics ToA, Blitzortung RED, GRLevel3, WD, WL, VWS, Cumulus, Meteobridge/hub
Free weather PHP scripts/website templates - update notifications on Twitter saratogaWXPHP

Offline jeanphi500

  • Member
  • *
  • Posts: 18
Re: Saratoga template using weewx-wd / issue when update
« Reply #14 on: February 10, 2021, 05:40:41 PM »
Hi Ken

I did some more debugging and found out that I was missing
Code: [Select]
$SITE['NOAAdir' ] = '../weather/NOAA';on top of the 'tricking ' you proposed

Added it, then struggled a bit more with locales and finally got it to work fine!

Thx once again  [tup]

Offline saratogaWX

  • Administrator
  • Forecaster
  • *****
  • Posts: 8307
  • Saratoga, CA, USA Weather - free PHP scripts
    • Saratoga-Weather.org
Re: Saratoga template using weewx-wd / issue when update
« Reply #15 on: February 10, 2021, 11:50:46 PM »
Ahh.. sorry I'd forgotten that setting.  Glad you sorted it out! 
Ken True/Saratoga, CA, USA main site: saratoga-weather.org
Davis VP1+ FARS, Boltek-PCI/NexStorm, microSferics ToA, Blitzortung RED, GRLevel3, WD, WL, VWS, Cumulus, Meteobridge/hub
Free weather PHP scripts/website templates - update notifications on Twitter saratogaWXPHP

 

anything