WXforum.net
Web Weather => Weather Website PHP/AJAX scripting => Custom Website Templates => Topic started by: mexbound on April 05, 2021, 09:25:52 PM
-
First off, I am very new to all of this Saratoga templates, etc. I did implement the Saratoga World template using the VWS addon. Everything is working great. Because I am now in Mexico I would like to use the IMPERIAL/METRIC switch usually shown near the top of the index page. I have seen some scripts with the "WD" using this but I was wondering if anyone has done this with VWS. Can someone point me in the right direction to maybe let me implement the option in my Saratoga World base template?
Thanks so much for any help.
-
Alas, currently the alternative-dashboard (with the Imperial/Metric tabs) only works with WD testtags.php -- VWS doesn't produce enough weather tags to make that work. I do know that WeeWX has an extension that creates WD-style testtags.php, so it could be used with the alt-dashboard.
But.. I've not heard about a alt-dashboard that works with any other weather software than the two above. Sorry.
-
Thank you very much for the response. I may take a look at Weather-Display software to see how it works.
-
If you wait a bit, in less than one week, there will be a WeeWX plugin to the template that fully supports the alternative dashboard for Imperial/Metric
We're putting the finishing touches on it right now.
-
So I am a "Windows guy" and really do not know Linux, nor do I have a computer to run Linux on. Will WeeWX run on Windows?
-
Some intrepid souls have run WeeWX on Windows, but it's really for the *nix platform. It can run on a Raspberry Pi quite easily (I run one Pi with it now). If you want to stick with Windows, then the Windows version of Weather-Display will fit the bill and let you run the alternative dashboard in the Saratoga template for Imperial/Metric display)
-
I might be willing to try getting an R-Pi and give it a go. I'm retired and have lots of time. Is there somewhere you can point me to what R-Pi I should buy and instructions to install WeeWX on it? Just confirming it will connect to a Davis Weather logger to get the data?
-
As if you didn't already have enough to do, Ken, there is one flaw in the Alt-Dashboard Imperial/Metric switching scheme that I couldn't fix: The temperatures associated with the NWS forecast. These come from advforecast2.php and while I have been able to modify this script's display to my taste I didn't see how this script could be incorporated into the Imperial/Metric switching scheme. Crucial to any switching scheme is the appropriate modification of ajaxWDwx.js, or ajaxXXwx.js, along with the dashboard. My last mods there dealt with making firedangerWD.php a real-time graphic on my alt-dashboard (https://www.wxforum.net/index.php?topic=39732.msg408029#msg408029).
BTW, thanks for the revised wxnwsradar script set, Ken. It works great!
-
I might be willing to try getting an R-Pi and give it a go. I'm retired and have lots of time. Is there somewhere you can point me to what R-Pi I should buy and instructions to install WeeWX on it? Just confirming it will connect to a Davis Weather logger to get the data?
Yes, WeeWX will connect to a Davis logger (serial, USB or IP). I'd suggest buying a 'kit' of Raspberry Pi. A RPi3+ would do nicely, and Amazon has a variety of kits .. pick one with a case, power supply, HDMI cable, and 8 to 32Gb SD card. You'll need a USB keyboard, and a HDMI display. Install the 'lite' version of the operating system .. you'll just use command line entries (like Windows DOS/CMD commands) to install/configure the operating system, and WeeWX.
-
As if you didn't already have enough to do, Ken, there is one flaw in the Alt-Dashboard Imperial/Metric switching scheme that I couldn't fix: The temperatures associated with the NWS forecast. These come from advforecast2.php and while I have been able to modify this script's display to my taste I didn't see how this script could be incorporated into the Imperial/Metric switching scheme. Crucial to any switching scheme is the appropriate modification of ajaxWDwx.js, or ajaxXXwx.js, along with the dashboard. My last mods there dealt with making firedangerWD.php a real-time graphic on my alt-dashboard (https://www.wxforum.net/index.php?topic=39732.msg408029#msg408029).
Ahh.. challenge accepted :)
I'm readying an update to ajax-dashboard6.php V6.92d with support for WeeWX, so I thought I'd mess about with some Imperial/Metric foibles.
Fixed a bunch, and added support for all the Saratoga forecast scripts, and--enabled Imperial/Metric switching on the forecast temperatures.
See a sample at https://saratoga-weather.org/weewx/wxindex.php (and you can kick the tires on the work in progress at https://saratoga-weather.org/weewx/ajax-dashboard6.php?sce=view)
BTW, thanks for the revised wxnwsradar script set, Ken. It works great!
Glad it works.. thanks for letting me mangle your original script to function with the new images.
-
You never cease to amaze me, Ken! =D> Your mods to display the forecasted temps as Imperial/Metric are working just fine on your WeeWx testing dashboard. The function reformat_forecast_temp($intemp) is apparently the key, but everything appears to be commented out there. :?:
I'm eager to see the finished product. [tup]
-
Actually, the reformat_forecast_temp() function has a lot of comments (showing the values from various forecast programs), but does have the 'meat' code of
<?php
function reformat_forecast_temp($intemp) {
// change
// NWS: 'Hi <span style="color: #FF0000;">66 °F ↓</span>' to
// to 'Hi <span style="color: #FF0000;"><span class="convTemp>66 °F</span> ↓</span>'
// WXSIM '<span style="color: blue">Low: 43°</span>'
// to '<span style="color: blue">Low: <span class="convTemp">43°F</span></span>'
// WCFcst '<span style="color: #ff0000;">66°F</span>'
// to '<span style="color: #ff0000;"><span class="convTemp">66°F</span></span>'
// AWfcst '<span style="color: #ff0000;">18.9°C</span>'
// to '<span style="color: #ff0000;"><span class="convTemp">18.9°C</span></span>'
// DSfcst '<span style="color: #ff0000;">18°C</span><br/><span style="color: #0000ff;">6°C</span>'
// to '<span style="color: #ff0000;"><span class="convTemp">18°C</span></span><br/><span style="color: #0000ff;"><span class="convTemp">6°C</span></span>'
global $uomTemp;
$t = str_replace('°<',$uomTemp.'<',$intemp); // handle WXSIM w/no uom
$t = preg_replace_callback('!([\d]+)\s*°(F|C)!Us',
function ($M) {
return '<span class="convTemp">'.$M[1].'°'.$M[2].'</span>';
},
$t);
print "<!-- reformat_forecast\n in='$intemp'\nout='$t' -->\n";
return $t;
}
?>
the preg_replace_callback() function does the 'heavy lifting' by surrounding the actual temperature values (with units) in a
<span class="convTemp"></span> which ajaxWDwx3.js then handles the temperature conversion as needed. Only WXSIM temperatures (that have no units) needed a bit of special handling to put the $uomTemp unit in the HTML first, before the preg_replace_callback() does the <span> insertion. Fairly cool.. just two lines of operative code to handle getting it ready for the AJAX script to process as needed.
Then, for every <?php echo $forecasttemp[N]; ?>
now becomes <?php echo reformat_forecast_temp($forecasttemp[N]); ?>
to make the HTML.
-
I see, said the blind man! Very clever and parsimonious. And very ‘Ken’. =D>
-
I decided to modify my dashboard by incorporating your clever changes, Ken.
It works (https://www.gwwilkins.org)!!! All of the advforecast2-derived temps now switch METRIC<=>Imperial.
-
I discovered that my 'Daytime Records' and 'Nighttime Records' were hosed using your revised fix_record2() function. So I reverted to my original fix_record2() which fixed the problem.
Maybe due to my insistence on using$timeOnlyFormat = 'g:i A'; // h:mm [AM|PM];
rather than$timeOnlyFormat = 'g:ia'; // h:mm[am|pm];
to format the time?
-
Ok, I have my Raspberry PI setup and running WeeWx. Wasn't to difficult if you follow all the setup directions. In post #9 above you mentioned you were working on an update for the alt dashboard (ajax-dashboard6.php V6.92d with support for WeeWX). Just wondering how it is going.
-
Gary and I are still working on the weewx-saratoga plugin for WeeWX and Saratoga templates.
You can try a preliminary copy of the ajax-dashboard6.php V6.92d from here (https://saratoga-weather.org/weewx/ajax-dashboard6.php?sce=view) and the updated ajaxWDwx3.js from here (https://saratoga-weather.org/weewx/ajaxWDwx3.js) and see how it looks here (https://saratoga-weather.org/weewx/wxindex-alt.php).
When Gary says he's finished with the weewx-saratoga plugin for release, I'll package up the WEEWX-plugin/docs and Alternative dashboard for release. Should be soon now :)