Author Topic: MB-defs.php errors with new Meteobridge  (Read 801 times)

0 Members and 1 Guest are viewing this topic.

Online drrehak

  • Senior Member
  • **
  • Posts: 65
MB-defs.php errors with new Meteobridge
« on: February 19, 2022, 08:57:45 PM »
My new Davis Pro 2 Plus finally arrived!  Up and running and working on connecting it to my new Meteobridge. 

MB-defs.php is throwing a set of 5 errors.
" A non-numeric value encountered "
Error is on the lines that use rain0total-ydmin, i.e.;
----
$rain5minuteago = sprintf($rainDP,$WX['rain0total-val5']-$WX['rain0total-ydmin']); // should be dmax!
----
and the 4 similar lines for 10,15,30,60 minutes ago

MBtags.php is showing
----
$WX['rain0total-ydmin'] = '--'; // rain min of yesterday
----
Which makes sense as the Meteobridge doesn't have historic data yet; only been connected for a few hours.

Is there anything I can do to the MB-defs.php to deal with this edge case other than wait for a day to get historic data?
I'm guessing the code should use 0 if rain0total-ydmin is missing but not sure.  I could add the conditional to set a default for rain0total-ydmin if its missing, but don't want to break something else in the process.

Using the latest version of MB-defs, Meteobridge
//Version MB-defs.php - V1.06 - 26-Jan-2022 - fixes for PHP 8.1
Meteobridge (5.3 build 14660 CARAMBOLA2)

Thanks
Dan Rehak | Pittsburgh PA
Davis Vantage Pro 2 Plus | Meteobridge Pro
Local Site | Raspberry Pi 4B

Offline saratogaWX

  • Administrator
  • Forecaster
  • *****
  • Posts: 9257
  • Saratoga, CA, USA Weather - free PHP scripts
    • Saratoga-Weather.org
Re: MB-defs.php errors with new Meteobridge
« Reply #1 on: February 20, 2022, 10:42:38 AM »
I'm afraid you'll have to wait for at least one overnight cycle with Meteobridge for your readings to stabilize and display as expected.  Sorry...
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

Online drrehak

  • Senior Member
  • **
  • Posts: 65
Re: MB-defs.php errors with new Meteobridge
« Reply #2 on: February 20, 2022, 12:45:16 PM »
Thanks Ken

MB-defs works today and the thermometer.php script is generating the image.

I found another place where the lack of historic data is a problem.
MB-trends-inc.php throws an error if the year for the record wind chill data is reported as "--" (mktime isn't happy with the -- value for year arg).

My quick change was from:
----
<?php echo formatDateYMD($mrecordlowchillyear,$mrecordlowchillmonth,$mrecordlowchillday); ?>
----
to
----
<?php if ($mrecordlowchillyear=="--") echo "--"; else
 echo formatDateYMD($mrecordlowchillyear,$mrecordlowchillmonth,$mrecordlowchillday); ?>
----
Similar change a few lines down for yearly data.

I suspect there may be a better way to handle this case, but I don't understand all the code logic enough yet to know where to fix it.



Dan Rehak | Pittsburgh PA
Davis Vantage Pro 2 Plus | Meteobridge Pro
Local Site | Raspberry Pi 4B

Online drrehak

  • Senior Member
  • **
  • Posts: 65
Re: MB-defs.php errors with new Meteobridge
« Reply #3 on: February 21, 2022, 12:11:24 PM »
I finally found the root cause of a lot of my problems including getting errors from MB-trends-inc.

On the Meteobridge Station Settings Tab, I had "don't check for windchill" set.
This causes the undefined data and triggers the errors in MB-trends-inc.
More importantly, it causes the HTTP upload event to fail, and as a result no realtime updates on the dashboard.  Unchecking the setting fixes it.

As an aside, if I run cond.php?d=... with the template for upload, I get a bunch of
A non-numeric value encountered warnings in the output.
Should I be concerned about these?
Anything else I could be missing?

Thanks.
Dan Rehak | Pittsburgh PA
Davis Vantage Pro 2 Plus | Meteobridge Pro
Local Site | Raspberry Pi 4B

Offline saratogaWX

  • Administrator
  • Forecaster
  • *****
  • Posts: 9257
  • Saratoga, CA, USA Weather - free PHP scripts
    • Saratoga-Weather.org
Re: MB-defs.php errors with new Meteobridge
« Reply #4 on: February 21, 2022, 01:13:14 PM »
Running the cond.php is the method of getting 'realtime' data to the template (via HTTP GET and the filled-in d= argument from the MBrealtime-template.txt used as an HTML template in Meteobridge).

What is the URL to your template website?  I'll take a look.
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

Online drrehak

  • Senior Member
  • **
  • Posts: 65
Re: MB-defs.php errors with new Meteobridge
« Reply #5 on: February 21, 2022, 02:25:13 PM »
I'm running on a local server, so no external access.
Here's the URL in the MB template in the Meteobridge, just direct cut and paste from MBrealtime-template.txt, fixing the IP, path
Code: [Select]
http://192.168.132.114/weather/st/conds.php?d=[DD]/[MM]/[YYYY],[hh]:[mm]:[ss],[th0temp-act],[th0hum-act.0],[th0dew-act],[wind0avgwind-act],[wind0wind-act],[wind0dir-act],[rain0rate-act],[rain0total-daysum],[thb0seapress-act],[wind0dir-act],[wind0wind-act=bft.0],m/s,C,hPa,mm,--,[thb0seapress-val60:--],[rain0total-monthsum],[rain0total-yearsum],[rain0total-ydaysum],[thb0temp-act],[thb0hum-act],[wind0chill-act],[th0temp-val60:--],[th0temp-dmax],[th0temp-dmaxtime],[th0temp-dmin],[th0temp-dmintime],[wind0avgwind-dmax],[wind0avgwind-dmaxtime],[wind0wind-dmax],[wind0wind-dmaxtime],[thb0seapress-dmax],[thb0seapress-dmaxtime],[thb0seapress-dmin],[thb0seapress-dmintime],[mbsystem-swversion:--],[mbsystem-buildnum:--],[wind0wind-max10],--,--,[uv0index-act:--],--,[sol0rad-act:--],[wind0dir-avg10:--],[rain0total-sum60],--,[mbsystem-daynightflag:--],--,[wind0dir-avg10:--],--,m,--,[mbsystem-daylength:--],--,--,[uv0index-dmax:--]
Output file from this call attached (changed the extension from html to txt to upload)

Anything else I can provide?
« Last Edit: February 21, 2022, 03:02:10 PM by saratogaWX »
Dan Rehak | Pittsburgh PA
Davis Vantage Pro 2 Plus | Meteobridge Pro
Local Site | Raspberry Pi 4B

Online drrehak

  • Senior Member
  • **
  • Posts: 65
Re: MB-defs.php errors with new Meteobridge
« Reply #6 on: February 21, 2022, 02:28:49 PM »
Don't know why the attachment was wrong before.  Let's try inline
Code: [Select]
<!-- saved from url=(0968)http://192.168.132.114/weather/st/conds.php?d=[DD]/[MM]/[YYYY],[hh]:[mm]:[ss],[th0temp-act],[th0hum-act.0],[th0dew-act],[wind0avgwind-act],[wind0wind-act],[wind0dir-act],[rain0rate-act],[rain0total-daysum],[thb0seapress-act],[wind0dir-act],[wind0wind-act=bft.0],m/s,C,hPa,mm,-%2D,[thb0seapress-val60:-%2D],[rain0total-monthsum],[rain0total-yearsum],[rain0total-ydaysum],[thb0temp-act],[thb0hum-act],[wind0chill-act],[th0temp-val60:-%2D],[th0temp-dmax],[th0temp-dmaxtime],[th0temp-dmin],[th0temp-dmintime],[wind0avgwind-dmax],[wind0avgwind-dmaxtime],[wind0wind-dmax],[wind0wind-dmaxtime],[thb0seapress-dmax],[thb0seapress-dmaxtime],[thb0seapress-dmin],[thb0seapress-dmintime],[mbsystem-swversion:-%2D],[mbsystem-buildnum:-%2D],[wind0wind-max10],-%2D,-%2D,[uv0index-act:-%2D],-%2D,[sol0rad-act:-%2D],[wind0dir-avg10:-%2D],[rain0total-sum60],-%2D,[mbsystem-daynightflag:-%2D],-%2D,[wind0dir-avg10:-%2D],-%2D,m,-%2D,[mbsystem-daylength:-%2D],-%2D,-%2D,[uv0index-dmax:-%2D] -->
<html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"></head><body><br>
<b>Warning</b>:  A non-numeric value encountered in <b>/var/www/html/weather/st/conds.php</b> on line <b>719</b><br>
<br>
<b>Warning</b>:  A non-numeric value encountered in <b>/var/www/html/weather/st/conds.php</b> on line <b>719</b><br>
<br>
<b>Warning</b>:  A non-numeric value encountered in <b>/var/www/html/weather/st/conds.php</b> on line <b>721</b><br>
<br>
<b>Warning</b>:  A non-numeric value encountered in <b>/var/www/html/weather/st/conds.php</b> on line <b>722</b><br>
<br>
<b>Warning</b>:  A non-numeric value encountered in <b>/var/www/html/weather/st/conds.php</b> on line <b>744</b><br>
<br>
<b>Warning</b>:  A non-numeric value encountered in <b>/var/www/html/weather/st/conds.php</b> on line <b>166</b><br>
<br>
<b>Warning</b>:  A non-numeric value encountered in <b>/var/www/html/weather/st/conds.php</b> on line <b>166</b><br>
<br>
<b>Warning</b>:  A non-numeric value encountered in <b>/var/www/html/weather/st/conds.php</b> on line <b>168</b><br>
<br>
<b>Warning</b>:  A non-numeric value encountered in <b>/var/www/html/weather/st/conds.php</b> on line <b>168</b><br>
<br>
<b>Warning</b>:  A non-numeric value encountered in <b>/var/www/html/weather/st/conds.php</b> on line <b>719</b><br>
<br>
<b>Warning</b>:  A non-numeric value encountered in <b>/var/www/html/weather/st/conds.php</b> on line <b>719</b><br>
<br>
<b>Warning</b>:  A non-numeric value encountered in <b>/var/www/html/weather/st/conds.php</b> on line <b>721</b><br>
<br>
<b>Warning</b>:  A non-numeric value encountered in <b>/var/www/html/weather/st/conds.php</b> on line <b>722</b><br>
<br>
<b>Warning</b>:  A non-numeric value encountered in <b>/var/www/html/weather/st/conds.php</b> on line <b>729</b><br>
<br>
<b>Warning</b>:  A non-numeric value encountered in <b>/var/www/html/weather/st/conds.php</b> on line <b>744</b><br>
<br>
<b>Warning</b>:  A non-numeric value encountered in <b>/var/www/html/weather/st/conds.php</b> on line <b>338</b><br>
<br>
<b>Warning</b>:  A non-numeric value encountered in <b>/var/www/html/weather/st/conds.php</b> on line <b>338</b><br>
<br>
<b>Warning</b>:  A non-numeric value encountered in <b>/var/www/html/weather/st/conds.php</b> on line <b>342</b><br>
<br>
<b>Warning</b>:  A non-numeric value encountered in <b>/var/www/html/weather/st/conds.php</b> on line <b>342</b><br>
<br>
<b>Warning</b>:  A non-numeric value encountered in <b>/var/www/html/weather/st/conds.php</b> on line <b>623</b><br>
<br>
<b>Warning</b>:  A non-numeric value encountered in <b>/var/www/html/weather/st/conds.php</b> on line <b>623</b><br>
<br>
<b>Warning</b>:  A non-numeric value encountered in <b>/var/www/html/weather/st/conds.php</b> on line <b>623</b><br>
<br>
<b>Warning</b>:  A non-numeric value encountered in <b>/var/www/html/weather/st/conds.php</b> on line <b>623</b><br>
<br>
<b>Warning</b>:  A non-numeric value encountered in <b>/var/www/html/weather/st/conds.php</b> on line <b>664</b><br>
<br>
<b>Warning</b>:  A non-numeric value encountered in <b>/var/www/html/weather/st/conds.php</b> on line <b>664</b><br>
<br>
<b>Warning</b>:  A non-numeric value encountered in <b>/var/www/html/weather/st/conds.php</b> on line <b>664</b><br>
<br>
<b>Warning</b>:  A non-numeric value encountered in <b>/var/www/html/weather/st/conds.php</b> on line <b>690</b><br>
<br>
<b>Warning</b>:  A non-numeric value encountered in <b>/var/www/html/weather/st/conds.php</b> on line <b>690</b><br>
<br>
<b>Warning</b>:  A non-numeric value encountered in <b>/var/www/html/weather/st/conds.php</b> on line <b>623</b><br>
<br>
<b>Warning</b>:  A non-numeric value encountered in <b>/var/www/html/weather/st/conds.php</b> on line <b>557</b><br>
<br>
<b>Warning</b>:  Cannot modify header information - headers already sent by (output started at /var/www/html/weather/st/conds.php:719) in <b>/var/www/html/weather/st/conds.php</b> on line <b>449</b><br>
<p>Success.</p>
</body></html>
Dan Rehak | Pittsburgh PA
Davis Vantage Pro 2 Plus | Meteobridge Pro
Local Site | Raspberry Pi 4B

Offline saratogaWX

  • Administrator
  • Forecaster
  • *****
  • Posts: 9257
  • Saratoga, CA, USA Weather - free PHP scripts
    • Saratoga-Weather.org
Re: MB-defs.php errors with new Meteobridge
« Reply #7 on: February 21, 2022, 03:00:22 PM »
That's the output I'd expect when the call to conds.php with
Code: [Select]
d=[DD]/[MM]/[YYYY],[hh]:[mm]:[ss],[th0temp-act],[th0hum-act.0],[th0dew-act],... is done.

To work correctly, the script has to be used as a Meteobridge template to a HTTP Request, Periodical Event so all the Meteobridge variables are turned into values before the GET REQUEST is issued to the conds.php script on your website.
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

Online drrehak

  • Senior Member
  • **
  • Posts: 65
Re: MB-defs.php errors with new Meteobridge
« Reply #8 on: February 21, 2022, 03:10:11 PM »
Thank You!
Just trying to understand the workflow before I try to change something and break it.
Dan Rehak | Pittsburgh PA
Davis Vantage Pro 2 Plus | Meteobridge Pro
Local Site | Raspberry Pi 4B

Offline saratogaWX

  • Administrator
  • Forecaster
  • *****
  • Posts: 9257
  • Saratoga, CA, USA Weather - free PHP scripts
    • Saratoga-Weather.org
Re: MB-defs.php errors with new Meteobridge
« Reply #9 on: February 21, 2022, 03:32:03 PM »
You're welcome.

The two ways that Meteobridge gets data to the site are:
1) FTP/SFTP/etc the MBtags.php to the site (usually every 5 minutes).  That is the BULK of the data that is presented on the website.
2) HTTP REQUEST, Periodic (every 10 seconds) to the conds.php URL on your website in which the d=... arguments are replaced with Meteobridge variable values, then the MBrealtime.txt is saved.  Also, the MBtags.php is accessed and data from there and the d=... values are used to create MBrealtimegauges.txt (the JSON file for the Steel Series gauges).

If enabled, the ajaxMBwx.js JavaScript will update SOME of the weather data displayed on the website (from MBrealtime.txt).

Hope this helps...
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

Online drrehak

  • Senior Member
  • **
  • Posts: 65
Re: MB-defs.php errors with new Meteobridge
« Reply #10 on: February 22, 2022, 12:12:16 PM »
Thanks
I think I have some of it figured out.
Let me know if this is the basic flow -- or please point me to some existing posts if I can find it there.

So for non realtime, my summary understanding:
-- gen-MBtags.php is called from the MB and generates the template that gets loaded
   into the MB when setting up FTP, reload via the MB if it changes
-- according to schedule the MB creates MBtags.php from the stored template and transfers via FTP
-- Then, as an example, user asks for wxtrends.php which (for MB) embeds MB-trends-inc.php via the include
---- MB-trends-inc.php via the value of $WXTags embeds latest MBtags.php generated/FTPd from MB
------ MBtags.php dumps all the MB data in $WX[]
-------- MBtags.php embeds MB-def.php to process $WX[] and put it into the individual WD variables
----- and finally MB-trends.php renders the WD variables into HTML

So if I wanted to display something like $WX['mbsystem-uptime'] on a different page all I need to do is get that script to embed MBtags.php to get $WX[] values that I can use.

Planning to play around and add some MB performance stats to my status page, along with some stats from the PI.

Then I'll be going through the forum once I'm ready to add my AQ sensor.
Dan Rehak | Pittsburgh PA
Davis Vantage Pro 2 Plus | Meteobridge Pro
Local Site | Raspberry Pi 4B

Offline saratogaWX

  • Administrator
  • Forecaster
  • *****
  • Posts: 9257
  • Saratoga, CA, USA Weather - free PHP scripts
    • Saratoga-Weather.org
Re: MB-defs.php errors with new Meteobridge
« Reply #11 on: February 22, 2022, 12:37:18 PM »
Yep, you've sussed out the process .. congratulations!

You can add tags to be processed by editing MBtags-template.txt to add the new variables.  Then upload the changed MBtags-template.txt to your site, and have Meteobridge reload the gen-MBtags.php template to use for MBtags.php generation.

Then you can use $WX['new-tag-name'] in your pages as you wish.

The MBtags-template.txt has the format of:

wvar{tab}MB-variable-name{tab}description-of-variable-contents

Use MBtags.php?sce=dump to show the contents of all the $WX variables available.

Hope this helps...

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

Online drrehak

  • Senior Member
  • **
  • Posts: 65
Re: MB-defs.php errors with new Meteobridge
« Reply #12 on: February 22, 2022, 12:47:21 PM »
Definitely helps!
I hadn't dug enough into MBtags-template.txt to understand it
and the magic to properly add more tags.  This will help.
Dan Rehak | Pittsburgh PA
Davis Vantage Pro 2 Plus | Meteobridge Pro
Local Site | Raspberry Pi 4B