Welcome to the Cumulus Support forum.

Latest Cumulus MX V3 release 3.28.6 (build 3283) - 21 March 2024

Cumulus MX V4 beta test release 4.0.0 (build 4018) - 28 March 2024

Legacy Cumulus 1 release v1.9.4 (build 1099) - 28 November 2014 (a patch is available for 1.9.4 build 1099 that extends the date range of drop-down menus to 2030)

Download the Software (Cumulus MX / Cumulus 1 and other related items) from the Wiki

BT's Sager PHP Script V2 - For Cumulus

Other discussion about creating web sites for Cumulus that doesn't have a specific subforum

Moderator: daj

Post Reply
User avatar
beteljuice
Posts: 3292
Joined: Tue 09 Dec 2008 1:37 pm
Weather Station: None !
Operating System: W10 - Threadripper 16core, etc
Location: Dudley, West Midlands, UK

BT's Sager PHP Script V2 - For Cumulus

Post by beteljuice »

As there was a little confusion recently when there was a url change, and as there has been no activity from BTJ for some time, plus his links don't work anymore ...

Edit: 13 Dec 2020 - BTJ is back on board and has a new release available on the original topic (link lower down)
BTJ wrote:Version 2020-12-12 is now live. It is attached to the bottom of the first post in this thread.
I have no idea if there is any compatibility beteween the versions - It would be best to assume not !!!

The beteljuice has done a little 'house-keeping'

It would be a great shame for this excellent piece of work to fade away and it really does deserve a wider audience.

So the beteljuice has updated the the METAR urls, improved error handing and reporting, and .....
this version now has separate 'language' files and is compatible with most of your favourite templates.

I must stress that these are really minor changes and the logic and base code for the logic are unchanged and for installation / set up you should refer to the original article: viewtopic.php?f=14&t=9901

Update: fix to sager_test, and a few small debug tweaks to bt-sager-wc.php - 17th March 2019
Update: bt-sager-wc.php - original cURL rewritten 19th March 2019

bt-sagerV2.zip

From the readme ...

The zip should contain:

bt-sager-wc.php (The main program)
bt-sager-cu.php (A file to be processed by and uploaded by Cumulus)
bt-sager-en.php (English 'language' file)
sager_test.php (Optional test / debug page)
this README.txt


bt-sager-wc.php
If you are already using bt-sager this is a REPLACEMENT file.

bt-sager-cu.php
This is unchanged and if you are already using bt-sager
you do NOT need to change your existing file.

bt-sager-en.php
This is a NEW file - there is a minimum requirement of
one 'language' file !

sager_test.php
This is a renamed bt-sager.php to reflect it's true function.
There are a couple of very small changes, but you may keep
your original if you wish.


DIFFERENCES in set up to original.

If your site language is NOT 'en' English AND / OR you want more languages ....

1/ Change line #35 in bt-sager-wc.php

$sager_default_lang = 'en'; // 'look-up' array to use if not passed or defined elsewhere

Please use ISO code for language required !

2/ If no one has posted a suitable 'language' file ..

Make a copy of bt-sager-en.php - DO NOT REMOVE OR EDIT THIS FILE !

Name your copy bt-sager-??.php where ?? is the ISO code for the country.

Modify the content to suit and upload to your webspace.
PLEASE post it on the forum for others !!

That's it !!!!!

Notes on language selection ...

If you are using Saratoga templates the default language will be the one
defined in the $SITE file.

A change of language can be achieved by POST php?lang= OR php?langue=
This makes the page compatable with Saratoa and WeatherByYou templates and
several others.

You may of course create your own drop-down list to do the same thing.

Sequence:
First of all looks for any POSTED option and if it exists.

... upon failure it will look for your 'default' language.

If that fails .... It tries looking for 'en' English file.


You can use the test page or the page that contains the forecast
to see whats going on by 'view source' and looking for a group of
<!-- comment lines -->

eg.

<!-- bt-sager-wc loaded -->
<!-- server running PHP ver 5.3.28 -->
<!-- cURL is installed OK -->
<!-- Loading bt-sager-cu > success -->
<!-- Looking for language info -->
<!-- Trying to load bt-sager-en.php -->
<!-- Language file loaded .... -->
<!-- getting METAR for YSCB -->
<!-- METAR OK -->

regards - the beteljuice
You do not have the required permissions to view the files attached to this post.
Last edited by beteljuice on Sun 13 Dec 2020 1:30 am, edited 8 times in total.
Image
......................Imagine, what you will KNOW tomorrow !
User avatar
beteljuice
Posts: 3292
Joined: Tue 09 Dec 2008 1:37 pm
Weather Station: None !
Operating System: W10 - Threadripper 16core, etc
Location: Dudley, West Midlands, UK

Re: BT's Sager PHP Script V2 - For Cumulus

Post by beteljuice »

B*gg*r - found a glitch already.

Please wait .............................
Image
......................Imagine, what you will KNOW tomorrow !
User avatar
PaulMy
Posts: 3777
Joined: Sun 28 Sep 2008 11:54 pm
Weather Station: Davis VP2 Plus 24-Hour FARS
Operating System: Windows8 and Windows10
Location: Komoka, ON Canada
Contact:

Re: BT's Sager PHP Script V2 - For Cumulus

Post by PaulMy »

I had downloaded but not yet installed it. I'll wait...

Enjoy,
Paul
Davis Vantage Pro2+
C1 www.komokaweather.com/komokaweather-ca
MX www.komokaweather.com/cumulusmx/index.htm /index.html /index.php
MX www.komokaweather.com/cumulusmxwll/index.htm /index.html /index.php
MX www. komokaweather.com/cumulusmx4/index.htm

Image
User avatar
beteljuice
Posts: 3292
Joined: Tue 09 Dec 2008 1:37 pm
Weather Station: None !
Operating System: W10 - Threadripper 16core, etc
Location: Dudley, West Midlands, UK

Re: BT's Sager PHP Script V2 - For Cumulus

Post by beteljuice »

Actually it seems to only apply to the test page if you turn error reporting off.

Just switching between two computers and doing full back-up with new software (Old one froze me out after the vets took some stuff out of the start up).

I'll be back later .....
Image
......................Imagine, what you will KNOW tomorrow !
User avatar
beteljuice
Posts: 3292
Joined: Tue 09 Dec 2008 1:37 pm
Weather Station: None !
Operating System: W10 - Threadripper 16core, etc
Location: Dudley, West Midlands, UK

Re: BT's Sager PHP Script V2 - For Cumulus

Post by beteljuice »

All good !

It was a small bug in a debug :lol: - which only showed in the 'test' page

Edit: Please download again to ensure everyone is using the same hymn sheet ..
Last edited by beteljuice on Tue 19 Feb 2019 9:46 pm, edited 1 time in total.
Image
......................Imagine, what you will KNOW tomorrow !
User avatar
beteljuice
Posts: 3292
Joined: Tue 09 Dec 2008 1:37 pm
Weather Station: None !
Operating System: W10 - Threadripper 16core, etc
Location: Dudley, West Midlands, UK

Re: BT's Sager PHP Script V2 - For Cumulus

Post by beteljuice »

paulmy wrote:@beteljuice, why the difference between the previous BT-Justice and the new beteljuice version?

Cumulus1 /weather/bt-sager-wc.php
document.write ('Unsettled and warmer; Diminishing, or moderating somewhat if current winds are of fresh to strong velocity. Southwest or West winds.');

CumulusMX /cumulusmx/bt-sager/bt-sager-wc.php
document.write ('Unsettled and warmer; Diminishing, or moderating somewhat if current winds are of fresh to strong velocity. West or Southwest winds.');
Simple ....
The way the original Sager decode was written was 'going around the clock' in a logic fashion rather than the way we actually describe compass points.

ie. Major ordinals first, then sub-ordinals, then ...

... also it shows that with a seperate language file it is relatively easy to make things more understandable for your target audience :ugeek:
Image
......................Imagine, what you will KNOW tomorrow !
uncle_bob
Posts: 505
Joined: Wed 17 Aug 2011 2:58 pm
Weather Station: WeatherDuino Pro2
Operating System: 2008
Location: Canberra

Re: BT's Sager PHP Script V2 - For Cumulus

Post by uncle_bob »

In an attempt to get my forecaster going I've tried everything. Now I've even loaded the BeTlejuice version too, still without any luck.
Any ideas BetelJuice?

Code: Select all

<!-- bt-sager-wc loaded -->
<!-- Loading bt-sager-cu > success -->
<!-- Looking for language info -->
<!-- Trying to load bt-sager-en.php -->
<!-- Language file loaded .... -->
<!-- getting METAR for YSCB  -->
<!-- METAR FAIL or corrupted  -->
document.write ('Forecast Unavailable');
Interested in building your own Weather Station? Maybe check out the WeatherDuino Pro Project Here
Conder, Canberra Weather
Image
User avatar
beteljuice
Posts: 3292
Joined: Tue 09 Dec 2008 1:37 pm
Weather Station: None !
Operating System: W10 - Threadripper 16core, etc
Location: Dudley, West Midlands, UK

Re: BT's Sager PHP Script V2 - For Cumulus

Post by beteljuice »

Just tried on my test page and info is OK.

Can't find sager-test.php or bt-sager.php on your site.

Try re-editing your bt-sager-cu.php.
Make sure you delete #14 $ms = "YSCB";, and re-type it from sratch, there maybe an 'invisible' character or something strange there.
Image
......................Imagine, what you will KNOW tomorrow !
User avatar
PaulMy
Posts: 3777
Joined: Sun 28 Sep 2008 11:54 pm
Weather Station: Davis VP2 Plus 24-Hour FARS
Operating System: Windows8 and Windows10
Location: Komoka, ON Canada
Contact:

Re: BT's Sager PHP Script V2 - For Cumulus

Post by PaulMy »

My Cumulus version http://www.komokaweather.com/weather/bt-sager.php is still working.

However have just noticed that my Sager forecaster in www.komokaweather.ca is not showing, nor the Davis VP2 forecast (both should be just below the EC Canada forecasts).

I have looked in sagerCW.php and cannot detect anything.
Also in get-metarSA-inc.php changed from http://weather.noaa.gov to https://

Code: Select all

   if ($reload) { // download METAR as existing file is stale or missing
      $rawfile = 'https://weather.noaa.gov/pub/data/observations/metar/stations/' . $ICAO . '.TXT';
      $raw_metar = @file($rawfile);
      if ($raw_metar === false) {return null;}
      $metar[0] = strtotime($raw_metar[0] . ' UTC');
      $metar[1] = preg_replace('/[\n\r]+/', '', $raw_metar[1]); // strip linefeeds
//    if ($matches = preg_split('/TEMPO/', $metar[1])) { // don't include data after TEMPO ( Temporary )
//       $metar[1] = $matches[0];
//    }


Any suggestions where to look?

Enjoy,
Paul
Davis Vantage Pro2+
C1 www.komokaweather.com/komokaweather-ca
MX www.komokaweather.com/cumulusmx/index.htm /index.html /index.php
MX www.komokaweather.com/cumulusmxwll/index.htm /index.html /index.php
MX www. komokaweather.com/cumulusmx4/index.htm

Image
User avatar
beteljuice
Posts: 3292
Joined: Tue 09 Dec 2008 1:37 pm
Weather Station: None !
Operating System: W10 - Threadripper 16core, etc
Location: Dudley, West Midlands, UK

Re: BT's Sager PHP Script V2 - For Cumulus

Post by beteljuice »

@paul

I can't see any evidence they were included in the first place. Have you moved things around recently ?
Image
......................Imagine, what you will KNOW tomorrow !
uncle_bob
Posts: 505
Joined: Wed 17 Aug 2011 2:58 pm
Weather Station: WeatherDuino Pro2
Operating System: 2008
Location: Canberra

Re: BT's Sager PHP Script V2 - For Cumulus

Post by uncle_bob »

beteljuice wrote: Sat 16 Mar 2019 2:40 pm Just tried on my test page and info is OK.

Can't find sager-test.php or bt-sager.php on your site.

Try re-editing your bt-sager-cu.php.
Make sure you delete #14 $ms = "YSCB";, and re-type it from sratch, there maybe an 'invisible' character or something strange there.
Thanks BetelJuice. I found there indeed was a trailing space on YSCB!
Unfortunately the problem still exists. Maybe XAMPP doesn't like this any more, but I still suspect it something I've done.
It's bloody annoying as it's a great little forecaster. If I can't get it working I'll have to disable it.

Here's what the php_error_log reckons:

Code: Select all

7-Mar-2019 08:52:53 Europe/Berlin] PHP Warning:  require(bt-sagerPlus.php): failed to open stream: No such file or directory in D:\xampp\htdocs\cond\sager_test.php on line 21

[17-Mar-2019 08:52:53 Europe/Berlin] PHP Fatal error:  require(): Failed opening required 'bt-sagerPlus.php' (include_path='.;D:\xampp\php\PEAR') in D:\xampp\htdocs\cond\sager_test.php on line 21
Interested in building your own Weather Station? Maybe check out the WeatherDuino Pro Project Here
Conder, Canberra Weather
Image
User avatar
beteljuice
Posts: 3292
Joined: Tue 09 Dec 2008 1:37 pm
Weather Station: None !
Operating System: W10 - Threadripper 16core, etc
Location: Dudley, West Midlands, UK

Re: BT's Sager PHP Script V2 - For Cumulus

Post by beteljuice »

Failed opening required 'bt-sagerPlus.php'
So there's the problem ...
Where is the file ? and are you using the correct path to find it ?

Wait a minute ....
EDIT: There shouldn't be a bt-sagerPlus.php file ??????????

Your home page IS finding -wc (betejuice version) because

Code: Select all

<!-- bt-sager-wc loaded -->
<!-- Loading bt-sager-cu > success -->
<!-- Looking for language info -->
<!-- lang over-ride to en requested <!-- Trying to load bt-sager-en.php -->
<!-- Language file loaded .... -->
<!-- getting METAR for YSCB -->
<!-- METAR FAIL or corrupted  -->
But it still can't parse a metar ...

Do you have multiple copies in different places ?
With the station ID corrected the home page should be working.
Image
......................Imagine, what you will KNOW tomorrow !
User avatar
beteljuice
Posts: 3292
Joined: Tue 09 Dec 2008 1:37 pm
Weather Station: None !
Operating System: W10 - Threadripper 16core, etc
Location: Dudley, West Midlands, UK

Re: BT's Sager PHP Script V2 - For Cumulus

Post by beteljuice »

Failed opening required 'bt-sagerPlus.php'
beteljuice problem !!!

Edit sager_test.php # 21
require "bt-sager-wc.php";

I'll be updating the distribution files updated, and a few other small tweaks ...

@uncle_bob

It does seem as if it still can't see the METAR id change.

Let me know when the updates are in ...
Image
......................Imagine, what you will KNOW tomorrow !
User avatar
beteljuice
Posts: 3292
Joined: Tue 09 Dec 2008 1:37 pm
Weather Station: None !
Operating System: W10 - Threadripper 16core, etc
Location: Dudley, West Midlands, UK

Re: BT's Sager PHP Script V2 - For Cumulus

Post by beteljuice »

@uncle_bob

Although you have a bt-sager-cu.php I suspect it hasn't actually been processed / uploaded recently ...

Have a look at the copy on your server side of things and make sure it's been populated with all the info.
Image
......................Imagine, what you will KNOW tomorrow !
uncle_bob
Posts: 505
Joined: Wed 17 Aug 2011 2:58 pm
Weather Station: WeatherDuino Pro2
Operating System: 2008
Location: Canberra

Re: BT's Sager PHP Script V2 - For Cumulus

Post by uncle_bob »

Man it's got me stumped. And I'm not a complete newbie when it comes to computers lol.
It looks like the Webserver bt-sager-cu.php is updating:

Code: Select all

<?php
/*
BT's Global Sager Weathercaster PHP Scripts For Cumulus (Variables)
by "Buford T. Justice" / "BTJustice"
http://www.freewebs.com/btjustice/bt-forecasters.html
2016-08-05

You may redistribute and use these PHP Scripts any way you wish as long as they remain FREE and money is not charged for their use directly or indirectly.  If these PHP Scripts are used in your work or are modified in any way, please retain the full credit header.

Most of the variables in bt-sager-cu.php are updated when Cumulus performs a web update.  They are used in bt-sager-wc.php to determine the correct Sager Weathercaster forecast.
*/

// On Line 14 below, replace XXXX with the 4-character METAR station ID (ICAO identifier) you want to use between the quote marks in capital letters:
$ms = "YSCB";

// ONLY CHANGE THIS IF ABSOLUTELY NECESSARY!  Sometimes, depending on your location, a barometric pressure offset is needed if the wind is consistently being forecasted too high or too low.  On Line 17 below, change 0 to 10 if the winds are being predicted too high or -10 if they are being predicted too low.  If 10 is not enough, try 15 or 20.  If 10 is too much, try 5.  Barometric pressure is converted to hPa in these PHP Scripts.  The number below simply adds or subtracts from the hPa barometric pressure:
$po = 0;

// Cumulus Information:
$version = "v1.9.4";
$build = "(1099)";
$updated = "2019-03-18 06:02 UTC";
$wxstation = "WeatherDuino Pro2";

// GPS Decimal Coordinates:
$lt = -35.462778;// Can be entered manually.
$lg = 149.095833;// Can be entered manually.

// Temperature Information:
$tr = str_replace (",",".","24.2");
$ts = "C";

// Average wind bearing from 6 hours ago, average wind bearing now, and wind speed unit used:
$b6 = 182;
$bd = 133;
$wu = "km/h";// Can be entered manually as "km/h", "kts", "m/s", or "mph".

// Barometric pressure, trend, and unit used: ... hmmm, why not value 6hrs and work out trend ?
$bp = str_replace (",",".","957.10");
$bt = str_replace (",",".","0.01");
$bu = "hPa";

// Minutes since Cumulus last reported Rain:
$rm = 705;
?>
I can do a screen connect session if you want to check it out closely BTLJ (that's seems like a fitting abbreviated name, especially since BT can't be with us for some unknown reason).
Interested in building your own Weather Station? Maybe check out the WeatherDuino Pro Project Here
Conder, Canberra Weather
Image
Post Reply