Page 6 of 8

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

Posted: Thu 09 Feb 2023 5:57 pm
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>

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

Posted: Thu 09 Feb 2023 6:01 pm
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?

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

Posted: Thu 09 Feb 2023 8:32 pm
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:

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

Posted: Thu 09 Feb 2023 8:57 pm
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.

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

Posted: Thu 09 Feb 2023 9:06 pm
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

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

Posted: Fri 10 Feb 2023 12:27 am
by TheBridge
Simon,
Thank you. Where and how did you create/write the contents to consoleforecast.txt file?

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

Posted: Fri 10 Feb 2023 8:04 am
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/

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

Posted: Fri 10 Feb 2023 1:11 pm
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

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

Posted: Sat 11 Feb 2023 12:35 am
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

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

Posted: Sat 11 Feb 2023 2:28 am
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

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

Posted: Sat 11 Feb 2023 3:59 am
by TheBridge
That should read ‘do-ability’ in my msg above

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

Posted: Sat 11 Feb 2023 6:03 pm
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.

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

Posted: Mon 13 Feb 2023 1:36 pm
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

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

Posted: Thu 16 Feb 2023 11:29 pm
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

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

Posted: Fri 17 Feb 2023 7:42 am
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