Author Topic: Problem with Ajax updating and Solar/UV on WH3080  (Read 6394 times)

0 Members and 1 Guest are viewing this topic.

Offline GordonB

  • Member
  • *
  • Posts: 4
Problem with Ajax updating and Solar/UV on WH3080
« on: January 13, 2012, 04:33:33 AM »
First post so please be gentle! I'm running a Signatrol WH3080 (Fine Offset clone) feeding a Meteohub that supplies data to my site at www.10db.co.uk/meteohub based on the Saratoga templates. Very pleased with it although it's taken a number of tweaks to get it running more or less as it should. However, I have a problem with Ajax updating the solar and UV values. If I enable Ajax updating I get the solar radiation and UV reported incorrectly as shown below. If I disable Ajax updating by commenting out the relevant line in settings-weather.php it reports the values correctly. Anyone got any thoughts as to what's wrong and how to correct it?

Cheers
Gordon

« Last Edit: January 13, 2012, 09:03:17 AM by GordonB »

Offline saratogaWX

  • Administrator
  • Forecaster
  • *****
  • Posts: 9288
  • Saratoga, CA, USA Weather - free PHP scripts
    • Saratoga-Weather.org
Re: Problem with Ajax updating and Solar/UV on WH3080
« Reply #1 on: January 13, 2012, 12:13:21 PM »
Hi Gordon, and welcome to WXforum.net!

The PHP display of the UV and Solar values are done from the MHtags.php uploaded by Meteohub (and mapped to the variables used in the ajax-dashboard by the MH-defs.php). 

Using http://www.10db.co.uk/meteohub/MHtags.php?sce=dump shows
Quote
$WX['actual_uv0_index'] = '0.0';
$WX['actual_sol0_radiation_wqm'] = '0.0';
$WX['day1_uv0_indexmax_time'] = '20120113110951';
$WX['day1_uv0_indexmax'] = '2.0';
$WX['day1_sol0_radiationmax_time'] = '20120113112852';
$WX['day1_sol0_radiationmax_wqm'] = '147';

and the MH-defs.php map that via
Quote
if(isset($WX['actual_sol0_radiation_wqm'])) { $VPsolar = $WX['actual_sol0_radiation_wqm']; }
if(isset($WX['actual_uv0_index'])) { $VPuv = $WX['actual_uv0_index']; }
if(isset($WX['day1_sol0_radiationmax_wqm'])) { $highsolar = $WX['day1_sol0_radiationmax_wqm']; }
if(isset($WX['day1_uv0_indexmax'])) { $highuv = $WX['day1_uv0_indexmax']; }
if(isset($WX['actual_sol0_radiation_rel'])) { $currentsolarpercent = $WX['actual_sol0_radiation_rel']; }
if(isset($WX['day1_sol0_radiationmax_time'])) {$highsolartime  = MHtimeOnly($WX['day1_sol0_radiationmax_time']);}
if(isset($WX['day1_uv0_indexmax_time'])) {$highuvtime  = MHtimeOnly($WX['day1_uv0_indexmax_time']);}
so the display shows
Quote
UV Index
   0.0    None
High: 2.0 @ 11:09

 Solar Radiation   
0.0 W/m2 (0 %)
High: 147 @  11:28

When the AJAX kicks in (ajaxMHwx.js), the updates are done from the clientraw.txt produced by Meteohub using this code
Code: [Select]
//  Solar Radiation
var solar    = clientraw[127] * 1.0;
set_ajax_obs("ajaxsolar",solar.toFixed(0));

        var solarpct = clientraw[34];
set_ajax_obs("ajaxsolarpct",solarpct);

// UV Index
var uv       = clientraw[79];
set_ajax_obs("ajaxuv",uv) ;
set_ajax_obs("gizmouv",uv) ;

var uvword = ajax_getUVrange(uv);
set_ajax_obs("ajaxuvword",uvword);
set_ajax_obs("gizmouvword",uvword);

So the value in clientraw[127] is used for current Solar w/m2 and the value in clientraw[79] is used for current UV index.

Using Kevin's clientraw decoder on your site at http://www.tnetweather.com/wd-parser.php?site=http%3A%2F%2Fwww.10db.co.uk%2Fmeteohub%2F&submit=Submit shows
Quote
127   VP Solarwm   N   -
079   Davis VP UV   N   -
Those two values are not numeric (just a '-' meaning 'no data' I suppose), so the AJAX JavaScript interprets them as 'NaN' meaning NotANumber.

Short of Boris changing the generation of clientraw.txt by Meteohub to use 0 (zero) for those values, you can change ajaxMHwx.js to have
Code: [Select]
//  Solar Radiation
var solar    = clientraw[127];
if(solar == '-') { solar = 0; }
solar    = solar * 1.0;
set_ajax_obs("ajaxsolar",solar.toFixed(0));

        var solarpct = clientraw[34];
set_ajax_obs("ajaxsolarpct",solarpct);

// UV Index
var uv       = clientraw[79];
if( uv == '-' ) { uv = 0; }
set_ajax_obs("ajaxuv",uv) ;
set_ajax_obs("gizmouv",uv) ;

var uvword = ajax_getUVrange(uv);
set_ajax_obs("ajaxuvword",uvword);
set_ajax_obs("gizmouvword",uvword);
and that should fix the display issue for AJAX.

Hope this helps, and
best regards,
Ken

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 GordonB

  • Member
  • *
  • Posts: 4
Re: Problem with Ajax updating and Solar/UV on WH3080
« Reply #2 on: January 13, 2012, 03:01:12 PM »
Thanks very much indeed for that Ken, as it's pitch black outside at the moment I'll have to wait until tomorrow to see how it works when we get some light but it's certainly set the values to 0 now. I like the link to Kevin's parser, I can see that would be useful and thanks also for the very clear explanation regarding how the various files interact, most instructive!

Cheers
Gordon

Offline saratogaWX

  • Administrator
  • Forecaster
  • *****
  • Posts: 9288
  • Saratoga, CA, USA Weather - free PHP scripts
    • Saratoga-Weather.org
Re: Problem with Ajax updating and Solar/UV on WH3080
« Reply #3 on: January 13, 2012, 03:40:59 PM »
You're very welcome, Gordon.

I'll add that code for the next release of ajaxMHwx.js so others can use it too.
I've also added your site to the list of sites using the templates :)

Best regards,
Ken
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 JohnR

  • Member
  • *
  • Posts: 23
    • Mickfield Weather
Re: Problem with Ajax updating and Solar/UV on WH3080
« Reply #4 on: January 13, 2012, 05:08:12 PM »
Gordon and I have been working together to set up our sites with the templates. I've no UV sensors on mine but I have noticed that if I enable Ajax updating, the current wind speed in the Trends page doesn't match the current wind speed further down the same page, plus the rain unit for current rain loses a decimal place ( [edit] just noticed Gordon's site is the same).

With updating turned off, the wind speeds do match and the rain unit goes back to two decimal places. I suppose the real question here is why there are two decimal places for rainfall mm on the non-updating page rather than one!

Neither of us actually realised we had the updating enabled from our first installs until I moved my pages to a new hosting service with server logs and found hundreds of error messages about not locating the clientraw.txt file in the folder above the (/weather) one in which the file actually was.

I altered the file path in ajaxMHwx.js from /clientraw.txt to ./clientraw.txt (just clientraw.txt works as well) and the errors stopped but suddenly my site had flashing green data. For a while I had no idea what was going on! Found out it was the ajax updating, told Gordon, he made the same change and up came his updating display as well.

My site is now at www.rainer.me.uk/weather - the updating is currently turned off the proper way in settings-weather.php  :-)

John
« Last Edit: January 14, 2012, 04:29:03 AM by JohnR »

Offline saratogaWX

  • Administrator
  • Forecaster
  • *****
  • Posts: 9288
  • Saratoga, CA, USA Weather - free PHP scripts
    • Saratoga-Weather.org
Re: Problem with Ajax updating and Solar/UV on WH3080
« Reply #5 on: January 14, 2012, 09:15:11 PM »
Thanks for the status update, John.  Glad the AJAX update was sorted out ;)

I've added your site to the list too.

Best regards,
Ken
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 GordonB

  • Member
  • *
  • Posts: 4
Re: Problem with Ajax updating and Solar/UV on WH3080
« Reply #6 on: January 15, 2012, 05:37:53 AM »
Ken

The change in the ajaxMHwx.js file works fine! Once I'd added the correct settings in Meteohub that is............. :oops:

Cheers
Gordon

Offline jachen

  • Member
  • *
  • Posts: 39
    • Neue Wetterstation Widen
Re: Problem with Ajax updating and Solar/UV on WH3080
« Reply #7 on: March 28, 2012, 06:27:02 AM »
Hello

My first question in this forum. I am doing something wrong with Ken's Meteohub Plugin as far as Solar Sensor Data Display is concerned.
Also after carefully reading this thread, it was impossible for me to find the error. My MHtags.php has completely different Variables from Gordon's.



I am also facing an effect that when refreshing the page solar radiation shows the correct value. After the next ajax refresh it falls back to the wrong one.

Also to compare Data I have set up two weather websites, one feeded by WD and one by Meteohub:

WD: http://jachen.homedns.org:81/wetter/index.php

MH: http://jachen.homedns.org:81/wetter_backup_MH/index.php

Maybe somebody is so kind to have a look into this and provide some help.

Thank you very much in advance.

Best regards
jachen

Offline saratogaWX

  • Administrator
  • Forecaster
  • *****
  • Posts: 9288
  • Saratoga, CA, USA Weather - free PHP scripts
    • Saratoga-Weather.org
Re: Problem with Ajax updating and Solar/UV on WH3080
« Reply #8 on: March 28, 2012, 12:02:16 PM »
Hi Jachen,

I observed both WD and MH sites for several minutes (with multiple page reloads), and I found that the WD and MH pages showed the same current solar W/m2 values.  Your MH site does have the correct setting for loading the clientraw.txt from the wetter_backup_MH/ directory.   Generally, when the AJAX update produces a different result, it is due to having the wrong clientraw.txt being read, but that does not seem to be the case here.  Have you tried clearing your browser cache, then observing both sites?
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 jachen

  • Member
  • *
  • Posts: 39
    • Neue Wetterstation Widen
Re: Problem with Ajax updating and Solar/UV on WH3080
« Reply #9 on: March 28, 2012, 12:21:22 PM »
Oh thank you very much for taking your time for me.

Trying to fix the Solar Radiation Value at the bottom, somehow I managed to poke a wrong array value in the ajaxWH.js [88] instead of [127] for clientraw actual solar.
That is corrected now.

But there is something in Meteohub's clientraw.txt that generates VP forecast Icon instead of current condition on the top left. WD generates current conditions (sunny here all the time).
If you want to look at the clientraw.txt using Tnet's parser you can check on http://jachen.homedns.org/meteohubwdl/ which runs on Port 80 rather than 81 which is not accepted by the parser.

Maybe you have an idea where to start debugging.

Wish you all the best.
jachen

Offline saratogaWX

  • Administrator
  • Forecaster
  • *****
  • Posts: 9288
  • Saratoga, CA, USA Weather - free PHP scripts
    • Saratoga-Weather.org
Re: Problem with Ajax updating and Solar/UV on WH3080
« Reply #10 on: March 28, 2012, 01:18:52 PM »
You're welcome, Jachen.  Meteohub does not provide exactly the same values for the iconnumber that WD does.  MH uses the forecast not the conditions for the iconnumber and conditions-text in clientraw.txt:

[actual_thb1_fc_wdlive:-] [actual_thb1_fc_text&:-]

are the values (on my Meteohub for the /home/meteohub/clientraw.conf ) which are based on the forecast (not current conditions).

For the template set, the conditions should be set by using a nearby METAR for the PHP page, and the ajaxMHwx.js does not update the text/icon, since Meteohub does not provide that data in clientraw.txt

Currently, in your Settings-weather.php you have
Code: [Select]
$SITE['conditionsMETAR'] = 'KSJC'; which means you are using my nearby METAR (San Jose, California) for your current conditions icon/text .. I suggest you use my find-metar utility to locate one near you, and if you don't have a suitable one, then comment out that line so no icon/conditions text is displayed.

Hope this helps...

Best regards,
Ken
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 jachen

  • Member
  • *
  • Posts: 39
    • Neue Wetterstation Widen
Re: Problem with Ajax updating and Solar/UV on WH3080
« Reply #11 on: March 28, 2012, 02:45:26 PM »
Ken thanks a lot.

Just got that 2 minutes ago and changed to LSZH. I really had to cheat and get the answer from another similar website in the States.
Changed to LSZH in Settings-weather.php accordingly and that was it. Much fun if one gets the clue.

Cheers and much much appreciated your help as always.

jachen