April 01, 2019

Weather34 & WeatherLink w/o cronjob

Running Weather 34, W34, using my setup, the program "cumulusdata.php" is fetching data from Davis Weatherlink(WL), and are writing the data to a file, type Cumulus. The old way was to fetch the data via a scheduled cronjob. 

Doing a small change to "windspeeddirection.php", "updater.php, and using the latest version of "cumulusdata.php", will do the update with the built in W34 refresh routine instead of cron job.

Thanks to Ken who gave me the hint.

Intro
"cumulusdata.php" now limits the data fetch frequency, so the program will not fetch data more often than every minute.  This is due to that WL data, at the Davis server, isn't refreshed more often then once a minute and the  "windspeeddirection.php" program is running a refresh several times every minute.

Changes
First
In "windspeeddirection.php" You just add 

<?php include('add_on/cumulusdata.php'); ?>

AFTER the LAST row in the code

This will get new WL data every minute when the W34 page is displayed in a browser.


Second
In "updater.php" You just add 

<?php include_once('add_on/cumulusdata.php'); ?>

AFTER the FIRST php statement so it will look something like 

<!-- begin updater.php  30-Mar-2019 -->
<?php
include_once('settings1.php');
include_once('common.php');
date_default_timezone_set($TZ);
?>
<?php include_once('add_on/cumulusdata.php'); ?>
<script src="js/jquery.js"></script>
<script>.............

This will get new data from WL, when opening the W34 for the first time, thats why using "include_once".

Thats all ! and then check so WL data is updated every minute.

No comments:

Post a Comment

Feel free to leave a comment ! ... but due to a lot of spam comments I have to moderate them. Will reply ASAP !