Welcome to the Cumulus Support forum.

Latest Cumulus MX release 3.28.5 (build 3282) - 23 February 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

TheBridge
Posts: 115
Joined: Mon 16 Mar 2020 3:23 am
Weather Station: Davis
Operating System: Windows 10
Contact:

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

Post by TheBridge »

Thanks Mark,

This is the line (below) the writes the Sager forecast to the Index.htm page. Can I write the same Sager output to the "currentconditions.txt" file at the same time?

<a href = "bt-sager.php" style = "text-decoration:none;" target = "_blank"><script src = "bt-sager-wc.php" type="text/javascript"></script></a>
User avatar
mcrossley
Posts: 12563
Joined: Thu 07 Jan 2010 9:44 pm
Weather Station: Davis VP2/WLL
Operating System: Bullseye Lite rPi
Location: Wilmslow, Cheshire, UK
Contact:

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

Post by mcrossley »

No, you would need to call it separately and either have some PHP code to save to file or pipe the output to file. I hope someone can chip in with a solution to that?
User avatar
ConligWX
Posts: 1563
Joined: Mon 19 May 2014 10:45 pm
Weather Station: Davis vPro2+ w/DFARS + AirLink
Operating System: Ubuntu 22.04 LTS
Location: Bangor, NI
Contact:

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

Post by ConligWX »

I have mine written to a forecast on the main screen but had some help from the late @betlejuice in coding it since my setup seemed to have issues with the standard script in the index file. I'll see if I can dig it all out...

hmm seems to drawn a blank. maybe I overwrote some time ago, I'm no using the forecast from my Davis VP2 console. :bash: :roll:
Regards Simon

https://www.conligwx.org - @conligwx
Davis Vantage Pro2 Plus with Daytime FARS • WeatherLink Live • Davis AirLink • PurpleAir •

Image
User avatar
ConligWX
Posts: 1563
Joined: Mon 19 May 2014 10:45 pm
Weather Station: Davis vPro2+ w/DFARS + AirLink
Operating System: Ubuntu 22.04 LTS
Location: Bangor, NI
Contact:

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

Post by ConligWX »

I do call bt-sager within my main saratoga templates (nearly all php files)

code is like so:

Code: Select all

           <td style="width: 510px;" class="data1"><?php echo "<b>Sager Forecast: </b>"; ?><?php include('./bt-sager-wc.php') ;?><?php echo "<br /><br />" ; ?></td>
code for my forecast in the cmx template is calling for a file called consoleforecast.txt

Code: Select all

<p><strong>Forecast:</strong> <?php echo file_get_contents('consoleforecast.txt') ?></p>
not sure if any of that helps.
Regards Simon

https://www.conligwx.org - @conligwx
Davis Vantage Pro2 Plus with Daytime FARS • WeatherLink Live • Davis AirLink • PurpleAir •

Image
User avatar
ConligWX
Posts: 1563
Joined: Mon 19 May 2014 10:45 pm
Weather Station: Davis vPro2+ w/DFARS + AirLink
Operating System: Ubuntu 22.04 LTS
Location: Bangor, NI
Contact:

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

Post by ConligWX »

mcrossley wrote: Thu 09 Feb 2023 5:43 pm
TheBridge wrote: Wed 08 Feb 2023 12:39 am Can the Sager forecast txt be feed into (in place of) the scrolling forecast text window at the top of the gauges webpage?
Off the top of my head, save the output of the script to a file called "currentconditions.txt" in the root CMX folder.

You can then pull the contents of that file using the <#currtcond> web tag inthe realtimegaugesT.txt file instead of the forecast tag.

I maybe mistaken but current conditions I think was this script: viewtopic.php?t=12831
Regards Simon

https://www.conligwx.org - @conligwx
Davis Vantage Pro2 Plus with Daytime FARS • WeatherLink Live • Davis AirLink • PurpleAir •

Image
TheBridge
Posts: 115
Joined: Mon 16 Mar 2020 3:23 am
Weather Station: Davis
Operating System: Windows 10
Contact:

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

Post by TheBridge »

Simon,
Thank you. Where and how did you create/write the contents to consoleforecast.txt file?
User avatar
ConligWX
Posts: 1563
Joined: Mon 19 May 2014 10:45 pm
Weather Station: Davis vPro2+ w/DFARS + AirLink
Operating System: Ubuntu 22.04 LTS
Location: Bangor, NI
Contact:

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

Post by ConligWX »

TheBridge wrote: Fri 10 Feb 2023 12:27 am Simon,
Thank you. Where and how did you create/write the contents to consoleforecast.txt file?
Thats done by Meteobridge Nano SD plugged into my Davis vPro2 Console. it processes a template which checks the "Console forecast" shown at the bottom of the screen, writes it to a file.

unfortunately I dont think CumulusMX gets the Davis Console forecast from the vPro2 and Vue consoles.

CumulusMX does have webtags however:

Code: Select all

<#forecast>		The current forecast
<#forecastenc>		The same as <#forecast> but with all reserved HTML characters, and those above character code 159, encoded as HTML entities
<#forecastJsEnc>	Available from version 3.11.0; The current forecast encoded for JavaScript
<#forecastnumber>	The number relating to the current forecast entry in the strings.ini file. If your station is not providing it's own forecast and Cumulus is not calculating one then 0 (zero) is returned. Note: two negative numbers can be returned by Cumulus: -1 (neg 1) = Exceptional Fine, -26 (neg 26) = Exceptional Bad
<#cumulusforecast>	Always gives Cumulus (Zambretti) forecast, even if the <#forecast> tag provides a station forecast
<#cumulusforecastenc>	The same as <#cumulusforecast> but with all reserved HTML characters, and those above character code 159, encoded as HTML entities
<#cumulusforecastJsEnc>	Available from version 3.11.0; The current Cumulus (Zambretti) forecast encoded for JavaScript
<#wsforecast>		Always gives station forecast (if available)
<#wsforecastenc>	The same as <#wsforecast> but with all reserved HTML characters, and those above character code 159, encoded as HTML entities
<#wsforecastJsEnc>	Available from version 3.11.0; The current station forecast encoded for JavaScript
if you want a good weather forecast simulator you could always purchase wxsim - https://www.wxsim.com/
Regards Simon

https://www.conligwx.org - @conligwx
Davis Vantage Pro2 Plus with Daytime FARS • WeatherLink Live • Davis AirLink • PurpleAir •

Image
User avatar
mcrossley
Posts: 12563
Joined: Thu 07 Jan 2010 9:44 pm
Weather Station: Davis VP2/WLL
Operating System: Bullseye Lite rPi
Location: Wilmslow, Cheshire, UK
Contact:

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

Post by mcrossley »

ConligWX wrote: Fri 10 Feb 2023 8:04 am
unfortunately I dont think CumulusMX gets the Davis Console forecast from the vPro2 and Vue consoles.
It does, but we want to get the Sager forecast into the current conditions file. I'd suggest running the Sager script as an hourly Cron job, and piping the output to the current conditions file
TheBridge
Posts: 115
Joined: Mon 16 Mar 2020 3:23 am
Weather Station: Davis
Operating System: Windows 10
Contact:

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

Post by TheBridge »

Almost there!
I have the current Sager forecast text now being written to .txt file each time the <website>index.htm file is accessed.
Now familiarizing myself with how the CMX gauges page to see what I need to do to have the Sager forecast .txt file imported and run in the gauges page ‘LCD’ scrolling display.

Bridge
TheBridge
Posts: 115
Joined: Mon 16 Mar 2020 3:23 am
Weather Station: Davis
Operating System: Windows 10
Contact:

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

Post by TheBridge »

Appreciate ‘so-ability’ perspective on either or both options.

This will complete the ability of CMX to show the Sager forecast in the ‘Gauges’ webpage LCD display. As noted on my previous post, code is now in place in the bu-sager.PHP file to generate the current Sager forecast text to the file SagerCurrentForecast.txt (on the host server side).

Option 1: replace the “forecast” web tag text value (on the server side) of realtimegauges file with the text contents of the SagerCurrentForecast.txt file (which is updated by sager-bu.php on the server side each time the file is accessed). This would then put the Sager forecast text into the LCD forecast display on the ‘gauges’ web page.

Or

option 2: could the text contents of SagerCurrentForecast.txt be directly imported into the ‘Gauges’ webpage (on the server side) and modify ‘Gauges’ code to use this imported text to display in the LCD forecast display?

Thank you!
Bridge
TheBridge
Posts: 115
Joined: Mon 16 Mar 2020 3:23 am
Weather Station: Davis
Operating System: Windows 10
Contact:

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

Post by TheBridge »

That should read ‘do-ability’ in my msg above
User avatar
mcrossley
Posts: 12563
Joined: Thu 07 Jan 2010 9:44 pm
Weather Station: Davis VP2/WLL
Operating System: Bullseye Lite rPi
Location: Wilmslow, Cheshire, UK
Contact:

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

Post by mcrossley »

Ideally you need the text on the same server as CMX. That is why I suggested a cron job running say once an hour, that either runs the sager script locally, or uses something like curl to get the out from your web server and save it to the current conditions file. Then all you have to do is edit the realtimegaugesT.txt file and replace the forecast tag with currcond.
TheBridge
Posts: 115
Joined: Mon 16 Mar 2020 3:23 am
Weather Station: Davis
Operating System: Windows 10
Contact:

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

Post by TheBridge »

Thanks Mark,

All done. All good and running well. Segar forecast now showing in LCD display. It was a great weekend adventure.

Setup of cURL (which is included on Windows 10) was a bit painful. Following examples (on-line) of commands didn’t work. Finally striped the command line sequence to its basics and viola. Updates the website once and hour now.

Bridge
TheBridge
Posts: 115
Joined: Mon 16 Mar 2020 3:23 am
Weather Station: Davis
Operating System: Windows 10
Contact:

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

Post by TheBridge »

Not sure if this anything to do specially with SAGER files..
SAGER files were running OK but now fail at point where a file (PHP) 'require' <filename> command is included. Suspected by running by-sager.php direct and confirmed using the curltest.php.(although this test file says 'cURL is present' it stops at that point) both files stall then they hit this command.

Ideas on this??

Bridge
User avatar
ConligWX
Posts: 1563
Joined: Mon 19 May 2014 10:45 pm
Weather Station: Davis vPro2+ w/DFARS + AirLink
Operating System: Ubuntu 22.04 LTS
Location: Bangor, NI
Contact:

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

Post by ConligWX »

TheBridge wrote: Thu 16 Feb 2023 11:29 pm Not sure if this anything to do specially with SAGER files..
SAGER files were running OK but now fail at point where a file (PHP) 'require' <filename> command is included. Suspected by running by-sager.php direct and confirmed using the curltest.php.(although this test file says 'cURL is present' it stops at that point) both files stall then they hit this command.

Ideas on this??

Bridge
looks like you have a couple of issues on main page... just use "inspect" on your browser


Capture.PNG
You do not have the required permissions to view the files attached to this post.
Regards Simon

https://www.conligwx.org - @conligwx
Davis Vantage Pro2 Plus with Daytime FARS • WeatherLink Live • Davis AirLink • PurpleAir •

Image
Post Reply