Author Topic: Rain Not updating in realtime & error  (Read 2981 times)

0 Members and 1 Guest are viewing this topic.

Offline HamiltonNJWX

  • Senior Member
  • **
  • Posts: 60
    • HamiltonWx
Rain Not updating in realtime & error
« on: November 27, 2022, 02:20:16 PM »
Good Day, all. i just noticed that my dashboard has stopped updating rain in realtime. I must do a refresh to see that. I only have this occurring with the rain - all else seems to be updating properly. I also started getting the error :

Notice: Undefined variable: month_rain in /home/hamilton/www/www/raintodate.php on line 127

figure it has to be related, but cannot see what is causing it.

Thanks in advance!

John
www.hamiltonwx.com

Offline saratogaWX

  • Administrator
  • Forecaster
  • *****
  • Posts: 9257
  • Saratoga, CA, USA Weather - free PHP scripts
    • Saratoga-Weather.org
Re: Rain Not updating in realtime & error
« Reply #1 on: November 27, 2022, 03:57:07 PM »
I'm not sure where the script raintodate.php is getting the $month_rain number from.  The testtags.php has $monthrn as the variable with the monthly rain number.  That data is also in clientraw[8] (Monthly rain).  I don't know where the script is getting the value .. you'll need to post the script (as .txt) to enable further diagnosis.
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 HamiltonNJWX

  • Senior Member
  • **
  • Posts: 60
    • HamiltonWx
Re: Rain Not updating in realtime & error
« Reply #2 on: November 27, 2022, 05:35:20 PM »
Thanks again, as always, Ken.  [ You are not allowed to view attachments ]

Offline HamiltonNJWX

  • Senior Member
  • **
  • Posts: 60
    • HamiltonWx
Re: Rain Not updating in realtime & error
« Reply #3 on: November 27, 2022, 05:37:38 PM »
Not sure if that went through, Ken.

Raintodate.php in text format.

<?php
############################################################################
$start_year = 2020; // set to first year of dailynoaareport files available
$rain_places = 2; // set to how many decimal places for rain
$loc = "./"; // set to path of dailynoaareport files
############################################################################
if (isset($_REQUEST['sce']) && ( strtolower($_REQUEST['sce']) == 'view' or
    strtolower($_REQUEST['sce']) == 'show') ) {
   //--self downloader --
   $filenameReal = __FILE__;
   $download_size = filesize($filenameReal);
   header('Pragma: public');
   header('Cache-Control: private');
   header('Cache-Control: no-cache, must-revalidate');
   header("Content-type: text/plain");
   header("Accept-Ranges: bytes");
   header("Content-Length: $download_size");
   header('Connection: close');

   readfile($filenameReal);
   exit;
}

if(!function_exists('getnoaafile')) {
       
 # GETNOAAFILE function
# Developed by TNETWeather.com
#
# Returns an array of the contents of the specified filename
# Array contains days from 1 - 31 (or less if the month has less) and
# the values:
# Day
# Mean Temp
# High Temp
# Time of High Temp
# Low Temp
# Time of Low Temp
# Hot Degree Day
# Cold Degree Day
# Rain
# Avg Wind Speed
# High Wind
# Time High Wind
# Dom Wind Direction
############################################################################

function getnoaafile ($filename) {
    global $SITE;               
   
    $rawdata = array();
   
    $fd = @fopen($filename,'r');
   
    $startdt = 0;
    if ( $fd ) {
   
        while ( !feof($fd) ) {
       
            // Get one line of data
            $gotdat = trim ( fgets($fd,8192) );
           
            if ($startdt == 1 ) {
                if ( strpos ($gotdat, "--------------" ) !== FALSE ){
                    $startdt = 2;
                } else {
                    $foundline = preg_split("/[\n\r\t ]+/", $gotdat );                   
                    $rawdata[intval ($foundline[0]) -1 ] = $foundline;
                }
            }
       
            if ($startdt == 0 ) {
                if ( strpos ($gotdat, "--------------" ) !== FALSE ){
                    $startdt = 1;
                }
            }
        }
        // Close the file we are done getting data
        fclose($fd);
    }   
    return($rawdata);

}

$today = getdate();
$year = $today['year'];
$month = $today['mon'];
$day = $today['mday'];

$alltimeaverage = array($avrainjan,$avrainfeb,$avrainmar,$avrainapr,$avrainmay,$avrainjun,$avrainjul,
                                $avrainaug,$avrainsep,$avrainoct,$avrainnov,$avraindec);

$avg_ytd_rain = 0; 
// Get the total rain averages for the month(s) preceding the current month
    for ($i = 0 ; $i < ($month-1) ; $i++)
        {
        $avg_ytd_rain = $avg_ytd_rain + $alltimeaverage[$i];
        }
       
// Calculate the average rain to date for the current month of previous years         
$avg_mtd_rain = get_mtd_rain ($start_year,$day,$month,$year,$loc);
$avg_mtd_rain = number_format((round($avg_mtd_rain,2)),$rain_places);

$avg_ytd_rain = $avg_ytd_rain + $avg_mtd_rain;                               
$avg_ytd_rain = number_format((round($avg_ytd_rain,2)),$rain_places);
   
########## Functions ##########################################################
 
function get_mtd_rain ($start_year,$day,$month,$year,$loc)
{
$years = $year - $start_year;
$months = 0;   
for ($i = 0 ; $i < $years ; $i++)
    {   
$filename = "dailynoaareport" . ( $month) . ($start_year + $i) . ".htm";

if (file_exists($loc . $filename) )   
    {
    $data[0] = getnoaafile($loc . $filename);
    $months = $months + 1;
    // Now get data from the dailynoaareport for this month from the 1st to today's date'.

    for ($d = 0 ; $d < $day ; $d++)
        {
        $rain = $data[0][$d][8];
        if ($rain != "")
           {
           $month_rain = $month_rain + $rain;
                   
           }   
        }
    }
    }
if ($months == 0) {
    $mtd_rain = 0;
} else {   
        $mtd_rain = $month_rain / $months;   
       }   
return $mtd_rain;   
}

         
############################################################################
# End of Functions
############################################################################

?> 

Offline saratogaWX

  • Administrator
  • Forecaster
  • *****
  • Posts: 9257
  • Saratoga, CA, USA Weather - free PHP scripts
    • Saratoga-Weather.org
Re: Rain Not updating in realtime & error
« Reply #4 on: November 27, 2022, 06:35:17 PM »
This appears to be reading the dailynoaareport*.htm files for data.  The Undefined message is due to $month_rain being (well) undefined.. no prior statement initializes it.  Also, the dailynoaareport file is only updated once per day at midnight for the prior day's data, so shouldn't be expected to be 'realtime' for today.

Where is this script used? 
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 HamiltonNJWX

  • Senior Member
  • **
  • Posts: 60
    • HamiltonWx
Re: Rain Not updating in realtime & error
« Reply #5 on: November 27, 2022, 07:04:35 PM »
It was a file in the alternative ajax dashboard ver 6.95b+. As per the directions, it said to load all php files, so i did.  I thought it was for compiling the data in the rain field on the dashboard.

John

Offline HamiltonNJWX

  • Senior Member
  • **
  • Posts: 60
    • HamiltonWx
Re: Rain Not updating in realtime & error
« Reply #6 on: November 27, 2022, 07:33:35 PM »
Not sure if this is of any help to you, but i reloaded another copy of the file directly from the download package and installed it. The error is now gone, but the Nov to Date Avg has gone to zero. Prior to doing this, it had a value of 2.34 in.

John

Offline HamiltonNJWX

  • Senior Member
  • **
  • Posts: 60
    • HamiltonWx
Re: Rain Not updating in realtime & error
« Reply #7 on: November 28, 2022, 07:06:48 AM »
I think I am more concerned about the current rain, rate and totals not updating in realtime. The rain has stopped here, no error is shown, but the month to date totals are also no longer shown.

John

Offline HamiltonNJWX

  • Senior Member
  • **
  • Posts: 60
    • HamiltonWx
Re: Rain Not updating in realtime & error
« Reply #8 on: November 30, 2022, 04:36:34 PM »
I have also noticed that the wind rose does not update. i tried some things to see if i could eliminate or move the issues. i changed the .JS file we are supposed to use from the ajaxWDwx3.JS back to the one used on the regular dashoard (ajaxWDws.JS) and it then updated the windrose, direction text and wind in realtime, but had no effect on the rain. I have since switched it back.

Offline HamiltonNJWX

  • Senior Member
  • **
  • Posts: 60
    • HamiltonWx
Re: Rain Not updating in realtime & error
« Reply #9 on: December 01, 2022, 09:00:26 AM »
Morning!  After taking down the webpages with attempts to correct, i decided to upload fresh files from the alt dashboard files. All is back up, with the following issues:

Rain does not update realtime
Wind direction does not update realtime

If i switch to ajaxWXwd.js , the wind direction will update realtime, but there is no updating on the lower items.

I also realized that i maybe should not be posting this here, but in the sister board. Let me know if you would like me to do that from now on.

Sorry for the inconvenience all.

John

Offline hcorrin

  • Contributor
  • ***
  • Posts: 126
    • Ballaugh Weather
Re: Rain Not updating in realtime & error
« Reply #10 on: December 02, 2022, 04:20:56 AM »
You have double checked that the ajaxWDwd3 is pointing to the clientraw.txt line 320

Offline HamiltonNJWX

  • Senior Member
  • **
  • Posts: 60
    • HamiltonWx
Re: Rain Not updating in realtime & error
« Reply #11 on: December 02, 2022, 09:07:13 AM »
You have double checked that the ajaxWDwd3 is pointing to the clientraw.txt line 320


thanks, yeah. Still digging through things to see if I missed something

Offline andro700

  • Chuck
  • Forecaster
  • *****
  • Posts: 420
    • Gobles Weather Page
Re: Rain Not updating in realtime & error
« Reply #12 on: December 04, 2022, 01:11:11 PM »
I have noticed that as well. I have the same thing using ajax 6.95e version.  It worked on the previous version before the update for PHP 8.0.

Chuck

Offline hcorrin

  • Contributor
  • ***
  • Posts: 126
    • Ballaugh Weather
Re: Rain Not updating in realtime & error
« Reply #13 on: December 04, 2022, 07:18:33 PM »
What version of php 8 were you using and what has it been updated too

Offline andro700

  • Chuck
  • Forecaster
  • *****
  • Posts: 420
    • Gobles Weather Page
Re: Rain Not updating in realtime & error
« Reply #14 on: December 04, 2022, 07:31:15 PM »
I believe my webhost was on version 8.1.4 and now they are running 8.1.11. I have to reload the page to update the rain data.

Chuck

Offline saratogaWX

  • Administrator
  • Forecaster
  • *****
  • Posts: 9257
  • Saratoga, CA, USA Weather - free PHP scripts
    • Saratoga-Weather.org
Re: Rain Not updating in realtime & error
« Reply #15 on: December 04, 2022, 07:42:39 PM »
In ajaxWDwx3.js there is
Code: [Select]
      rain        = parseFloat( clientraw[ 7]).convertRain();
and
Code: [Select]
      set_ajax_obs("ajaxrain2"      ,rain   .toFixed(dp.Rain)   +' '+ uom.Rain);
to set the value on the dashboard as
Code: [Select]
<span class="ajax" id="ajaxrain2"><span class="convRain"><?php printf("%8.2f"strip_units($dayrn)); echo $uomRain?></span></span>so if the value is changing in clientraw.txt, it should show up on the ajax-dashboard6.php 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 andro700

  • Chuck
  • Forecaster
  • *****
  • Posts: 420
    • Gobles Weather Page
Re: Rain Not updating in realtime & error
« Reply #16 on: December 05, 2022, 12:50:20 PM »
Mine is set up exactly that way but for some reason it does not update in realtime.

Chuck

Offline HamiltonNJWX

  • Senior Member
  • **
  • Posts: 60
    • HamiltonWx
Re: Rain Not updating in realtime & error
« Reply #17 on: December 05, 2022, 04:48:24 PM »
In ajaxWDwx3.js there is
Code: [Select]
      rain        = parseFloat( clientraw[ 7]).convertRain();
and
Code: [Select]
      set_ajax_obs("ajaxrain2"      ,rain   .toFixed(dp.Rain)   +' '+ uom.Rain);
to set the value on the dashboard as
Code: [Select]
<span class="ajax" id="ajaxrain2"><span class="convRain"><?php printf("%8.2f"strip_units($dayrn)); echo $uomRain?></span></span>so if the value is changing in clientraw.txt, it should show up on the ajax-dashboard6.php display.

The first two lines are in ajaxWDwx3.js   --- in ajaxdashboard6 , it has this code

<td valign="middle" style="text-align: center;" >
                        <?php echo "<img src=\"${imagesDir}raindrop.jpg\" alt=\"Current Rain\" />"; ?>
                    </td>
                    <td valign="middle" style="text-align: center; border: 1px solid gray;" >
                        <?php langtrans('Rain'); ?>:<br/>
                        <span style="font-size: 18px" class="ajax" id="ajaxrain">
                        <?php echo strip_units($dayrn) . $uomRain; ?></span>
                    </td>

Is this correct?

Offline HamiltonNJWX

  • Senior Member
  • **
  • Posts: 60
    • HamiltonWx
Re: Rain Not updating in realtime & error
« Reply #18 on: December 05, 2022, 04:59:47 PM »
I believe my webhost was on version 8.1.4 and now they are running 8.1.11. I have to reload the page to update the rain data.

Chuck

I just checked mine.. i had 8.1.11 as well. bumped it down to 8.0.24, tipped the bucket, but didnt register until i did a manual refresh.

Offline HamiltonNJWX

  • Senior Member
  • **
  • Posts: 60
    • HamiltonWx
Re: Rain Not updating in realtime & error
« Reply #19 on: February 16, 2023, 03:00:33 PM »
Is it possible that the issue is with the Ajax version that is used with the Alt Dashboard? Could it not work with newer versions of PHP? I can only go down to 7.4 on my server. I have tried everything from 7.4 and up and it does not work - it works perfectly if i go to Ken's dashboard with the different ajax version. I know the easy fix would be to drop the alt dashboard, but i really like the layout.

Offline saratogaWX

  • Administrator
  • Forecaster
  • *****
  • Posts: 9257
  • Saratoga, CA, USA Weather - free PHP scripts
    • Saratoga-Weather.org
Re: Rain Not updating in realtime & error
« Reply #20 on: February 16, 2023, 03:16:28 PM »
The ajaxWDwx3.js alternative dashboard JavaScript has
Code: [Select]
      rain        = parseFloat( clientraw[ 7]).convertRain();

      set_ajax_obs("ajaxrain"       ,rain   .toFixed(dp.Rain)   +' '+ uom.Rain);
      set_ajax_obs("ajaxrain2"      ,rain   .toFixed(dp.Rain)   +' '+ uom.Rain);
so both instances on the dashboard should update from clientraw[7].
The ajaxWDwx3.js is JavaScript and only runs in the browser, so is not related to PHP version.  The PHP version would be a factor in the ajax-dashboard6.php however.  I see you're running V6.95e and there is a 6.95f version available which supports PHP 7 and PHP8 to PHP 8.2
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 HamiltonNJWX

  • Senior Member
  • **
  • Posts: 60
    • HamiltonWx
Re: Rain Not updating in realtime & error
« Reply #21 on: February 16, 2023, 03:26:34 PM »
Thank you, Ken, as always!  I know there is no longer support on this, but do house the 6.95f version on your homepage? I looked rather quickly and did not see it.





The ajaxWDwx3.js alternative dashboard JavaScript has
Code: [Select]
      rain        = parseFloat( clientraw[ 7]).convertRain();

      set_ajax_obs("ajaxrain"       ,rain   .toFixed(dp.Rain)   +' '+ uom.Rain);
      set_ajax_obs("ajaxrain2"      ,rain   .toFixed(dp.Rain)   +' '+ uom.Rain);
so both instances on the dashboard should update from clientraw[7].
The ajaxWDwx3.js is JavaScript and only runs in the browser, so is not related to PHP version.  The PHP version would be a factor in the ajax-dashboard6.php however.  I see you're running V6.95e and there is a 6.95f version available which supports PHP 7 and PHP8 to PHP 8.2

Offline HamiltonNJWX

  • Senior Member
  • **
  • Posts: 60
    • HamiltonWx
Re: Rain Not updating in realtime & error
« Reply #22 on: February 16, 2023, 03:29:01 PM »
Disregard..... found!

Offline HamiltonNJWX

  • Senior Member
  • **
  • Posts: 60
    • HamiltonWx
Re: Rain Not updating in realtime & error
« Reply #23 on: February 16, 2023, 04:41:49 PM »
Hey, Ken. I uploaded the new version and all files that accompanied it. I get error messages and blank pages if i try to up my webpages PHP version above 7.4  --- I have also updated all necessary files with your check fetch times tool. still digging. If you have any suggestions it would be very appreciated.

     BTW, the rain and windrose are still not updating no matter what PHP version i choose.

Offline saratogaWX

  • Administrator
  • Forecaster
  • *****
  • Posts: 9257
  • Saratoga, CA, USA Weather - free PHP scripts
    • Saratoga-Weather.org
Re: Rain Not updating in realtime & error
« Reply #24 on: February 16, 2023, 04:50:41 PM »
Since I'm older now, and any clairvoyance I may have had has faded, I can't see what error messages you are referring to.

Please copy some from your website error_log and paste as a code section so I can understand what might be wrong with your site on PHP 8.
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

 

anything