Author Topic: Meteobridge Uptime displayed on Saratoga wxstatus page **Solved**  (Read 1012 times)

0 Members and 1 Guest are viewing this topic.

Offline Ian.

  • Forecaster
  • *****
  • Posts: 460
    • Chatteris Weather
Hi,

I would like to have the Meteobridge Pro uptime displayed on the Saratoga Template Status page, any tips on how I can do this?

Cheers

Ian
« Last Edit: February 22, 2017, 12:25:48 AM by Ian. »
CWOP - DW3371
PWS - ICAMBRID16
https://www.chatteris.biz

Offline saratogaWX

  • Administrator
  • Forecaster
  • *****
  • Posts: 9288
  • Saratoga, CA, USA Weather - free PHP scripts
    • Saratoga-Weather.org
Re: Meteobridge Uptime displayed on Saratoga wxstatus page
« Reply #1 on: February 19, 2017, 10:34:50 AM »
It's a bit complicated, but doable.

First, add a line to MBtags-template.txt on your website that has:
Code: [Select]
wvar mbsystem-uptime:0 Meteobridge uptime in seconds
with a tab character separating wvar and mbsystem-uptime:0 and the comment.  The tab character is used as a field delimiter in MBtags-template.txt

Then reload the template in Meteobridge (from gen-MBtags.php)

You should then have a $WX['mbsystem-uptime'] variable you can use in the wxstatus.php page.. it will contain the number of seconds, so you'll have to convert it to days, hours, minutes, seconds for display.

Ken True/Saratoga, CA, USA main site: saratoga-weather.org
Davis VP1+ FARS, Blitzortung RED, GRLevel3, WD, WL, VWS, Cumulus, Meteobridge
Free weather PHP scripts/website templates - update notifications on Twitter saratogaWXPHP

Offline Ian.

  • Forecaster
  • *****
  • Posts: 460
    • Chatteris Weather
Re: Meteobridge Uptime displayed on Saratoga wxstatus page
« Reply #2 on: February 19, 2017, 12:17:23 PM »
Thanks Ken,

I have modified MBtags-template.txt and reloaded via gen-MBtags.php, on the wxstatus page to get the variable to display, I have tried replacing '$windowsuptime' with '$WX['mbsystem-uptime']' on the wxstatus.php script below without success,

<?php
   langtransstr('This page shows the current status of the weather software used in the operation of this website.'); ?>
   <br/>
   <?php if(isset($windowsuptime)) { ?>
  <?php langtrans('Station system up for'); ?> <b><?php print $windowsuptime; ?></b><br/>
  <?php } // end $windowsuptime ?>
CWOP - DW3371
PWS - ICAMBRID16
https://www.chatteris.biz

Offline saratogaWX

  • Administrator
  • Forecaster
  • *****
  • Posts: 9288
  • Saratoga, CA, USA Weather - free PHP scripts
    • Saratoga-Weather.org
Re: Meteobridge Uptime displayed on Saratoga wxstatus page
« Reply #3 on: February 19, 2017, 06:57:17 PM »
Try changing the MBtags-template.txt to have 'mbsystem-uptime' instead of 'mbsystem-uptime:0' for the second field in the line.

You should be able to see the $WX['mbsystem-uptime'] listed in a MBtags.php?sce=dump .. so far, it's not showing up.

Yes, replace '$windowsuptime' with '$WX['mbsystem-uptime']' in the code you showed above.
Ken True/Saratoga, CA, USA main site: saratoga-weather.org
Davis VP1+ FARS, Blitzortung RED, GRLevel3, WD, WL, VWS, Cumulus, Meteobridge
Free weather PHP scripts/website templates - update notifications on Twitter saratogaWXPHP

Offline Ian.

  • Forecaster
  • *****
  • Posts: 460
    • Chatteris Weather
Re: Meteobridge Uptime displayed on Saratoga wxstatus page
« Reply #4 on: February 20, 2017, 03:02:48 PM »
Hi Ken,

Good news, the seconds are now showing up on the wxstatus page, if you could please indulge me one last time.

I found this code to convert seconds to Months, Days, H, M & s, but i don't know how to get $WX['mbsystem-uptime:0'] to $ss and then how to get it to display, as I don't know what I'm doing each tome I try the site breaks :oops:

function seconds2human($ss) {
$s = $ss % 60;
$m = (floor(($ss%3600)/60)>0)?floor(($ss%3600)/60).’ minutes’:”;
$h = (floor(($ss % 86400) / 3600)>0)?floor(($ss % 86400) / 3600).’ hours’:”;
$d = (floor(($ss % 2592000) / 86400)>0)?floor(($ss % 2592000) / 86400).’ days’:”;
$M = (floor($ss / 2592000)>0)?floor($ss / 2592000).’ months’:”;
return “$M $d $h $m $s seconds”;
}
CWOP - DW3371
PWS - ICAMBRID16
https://www.chatteris.biz

Offline saratogaWX

  • Administrator
  • Forecaster
  • *****
  • Posts: 9288
  • Saratoga, CA, USA Weather - free PHP scripts
    • Saratoga-Weather.org
Re: Meteobridge Uptime displayed on Saratoga wxstatus page
« Reply #5 on: February 20, 2017, 04:44:18 PM »
Hi Ken,

Good news, the seconds are now showing up on the wxstatus page, if you could please indulge me one last time.

I found this code to convert seconds to Months, Days, H, M & s, but i don't know how to get $WX['mbsystem-uptime:0'] to $ss and then how to get it to display, as I don't know what I'm doing each tome I try the site breaks :oops:

function seconds2human($ss) {
$s = $ss % 60;
$m = (floor(($ss%3600)/60)>0)?floor(($ss%3600)/60).’ minutes’:”;
$h = (floor(($ss % 86400) / 3600)>0)?floor(($ss % 86400) / 3600).’ hours’:”;
$d = (floor(($ss % 2592000) / 86400)>0)?floor(($ss % 2592000) / 86400).’ days’:”;
$M = (floor($ss / 2592000)>0)?floor($ss / 2592000).’ months’:”;
return “$M $d $h $m $s seconds”;
}
Well, the conditional statements are missing the 'false' entries, so no wonder it has PHP griping about syntax :)

I suggest you use
Code: [Select]
<?php print sec2hms($WX['mbsystem-uptime']); ?> which uses the sec2hms routine (part of include-wxstatus.php loaded by the wxstatus.php page).  That will show the hours:minutes:seconds of uptime for you.

Or... I fixed up the syntax issues with your function (wrong single and double quote marks used in the original) and the real code that should work looks like
Code: [Select]
function seconds2human($ss) {
$s = $ss % 60;
$m = (floor(($ss%3600)/60)>0)?floor(($ss%3600)/60).' minutes':'';
$h = (floor(($ss % 86400) / 3600)>0)?floor(($ss % 86400) / 3600).' hours':'';
$d = (floor(($ss % 2592000) / 86400)>0)?floor(($ss % 2592000) / 86400).' days':'';
$M = (floor($ss / 2592000)>0)?floor($ss / 2592000).' months':'';
return "$M $d $h $m $s seconds";
}
« Last Edit: February 20, 2017, 04:48:22 PM by saratogaWX »
Ken True/Saratoga, CA, USA main site: saratoga-weather.org
Davis VP1+ FARS, Blitzortung RED, GRLevel3, WD, WL, VWS, Cumulus, Meteobridge
Free weather PHP scripts/website templates - update notifications on Twitter saratogaWXPHP

Offline Ian.

  • Forecaster
  • *****
  • Posts: 460
    • Chatteris Weather
Re: Meteobridge Uptime displayed on Saratoga wxstatus page
« Reply #6 on: February 21, 2017, 02:19:59 PM »
Hi Ken,

Many thanks yet again for your expertise in helping me to get the desired result, everything is working just fine thanks to your goodself.

All the best

Ian
CWOP - DW3371
PWS - ICAMBRID16
https://www.chatteris.biz

 

anything