Monday, 23 July 2018

Install Weather34 with WeatherLink

Updated 2018-07-23 !!

Interface updated to WeatherLink 2.0(WL2.0)
Migrate info in this post

I You want Your Private Weather Station(PWS), Davis Vantage Pro2 or other Davis products that use WeatherLink, to provide data for the template we use at Domstens Båtklubb just follow the instructions below

If You want the same code version please check this post

And this is without additional software such as Cumulus, Weather display or the Meteobridge product.

Before You start You must ensure that;
When you have logged on to Your WL account You will find the link "Uploads" in the upper part. Click on it and register Your StationID and Password for WU data transfer.

W34 is built so it can get online data from many different PWS solutions which should update their respective online files at the W34 web-server. In our case we pull the XML data direct from the WL site and update an online file, type "cumulus", on the W34 web-server


Install Weather34(W34) according to the instructions WEB hosted installation or RPi install below.

To start up fresh on the RPi You can follow the instructions here.

Download all the files to Your Mac/PC and unzip them. Last download and test was done with the "All in one ZIP-file" and the CU-X7(Cumulus standalone.....) version.

Modify, RPi folder, owner/permission sudo chown pi:pi /var/www/html

Loged on as "pi" move the folder "CU-X7", using Finder/Explorer (Samba), to the RPi folder  /var/www/html/

Rename "CU-X7" to "pws"

Change authority sudo chmod 777 /var/www/html/pws/settings1.php so you can make the setup

Setup with URL http://pws01/pws/easyweathersetup.php No Password
Create a folder "add_on".

mkdir /var/www/html/pws/add_on

Download/fork the files, "cumulusdata.php" and "realtime.templ", from Github and place them in the "add_on" folder. (The online file "realtime.txt" will be created by the program)

Edit the PHP file, "cumulusdata.php", so that the 3 records in the beginning of the program

$wlink_user = "XXXX"; 
$wlink_pass = "YYYY";
$wlink_apiToken = "ZZZZ";

uses Your credentials to log on to WL. Please note that for the WL2.0 interface the $wlink_user  is changed to Device ID from former user.

The changed application is tested against both a WL account that is still on WL1.0 and a WL2.0

Since the updates from WU, local files are changed, is made by the W34 application, and the Apache servers default user/group is www-datathere will be authority problems.

Change authority with 

cd /var/www/html/pws
sudo chmod -R 777 chartswudata
sudo chmod -R 777 chartswudata/* (If the folder is empty You will get a notice)
sudo chmod -R 777 jsondata
sudo chmod -R 777 jsondata/*

Add a crontab record, as user "pi", using, crontab -e

*/5 * * * * php /var/www/html/pws/add_on/cumulusdata.php

This job will get the data, every 5 minutes, from WL and create/update the online file "realtime.txt"

Run the "easyweathersetup.php" again and update the path to the new online file.

In the section "Software Type & Path to Data file" choose 
  • "Data Type" => "cumulus" 
  • "Your Path to data file" => "add_on/realtime.txt"  
Now You should be up and running at http://pws01/pws and You can check the timestamp, after the cronjob has run, in the single record in the "add_on/realtime.txt" file.

Please note;
  • Trend values, temperatur and pressure, will take up to 2 hours before they are OK.
  • Wind run and daily max wind will be correct after a day shift
Update W34

When You update/replace W34 to a new version, save
  • ”settings1.php” file so You don't have to use "easyweathersetup.php" again(Dosen't work if there been major changes)
  • "add_on" folder
  • "menu.php" file if You have added own Menu rows
Tips and tricks
  • A very easy way to check that everything is set up right at WL is to put the URL (WL2.0) in Your browser, changing XXXX, YYYY and ZZZZ to Your credentials, as You do in the program
  • When registering at WL use lowercase for the "User name".
  • WL is updated once every minute so it's no use to run the Cron job more often
  • If Your host don't supports cronjobs You could use an external free service like where You register the URL to be executed.


Migrating realtime.txt to a new version could cause authority problem, so don't. Let the program create the file.


The new version, WL2.0, is migrated in this post.


The new version, WL2.0, is discussed in this post.


In the new version the "Extra links" was not handled but You can add them with the example code below in the "menu.php".

<li><!--- Extra menu row --->
 <div class="nav-text"> 
  <a href="" title="Domstens Båtklubb"> 
   <?php echo $arrow34icon;?> 
   Domstens Båtklubb 


Despite the termination of the project the code is availableBoth the Cumulus and the Multiple version is tested and works.


NOTE ! Project terminated by the developer !!


NOTE ! If You are updating to the new W34 version V3.4 X5(e) and migrating ”settings1.php” You have to use "easyweathersetup.php" and update new fields before You start the W34 application.
The file "homeindoor.php", showing just temperature, is updated at Github 


The program "cumulusdata.php" is updated for handling an extra temperature sensor, Davis 6372, which in our case is measuring the water temperature. To handle it, within the Cumulus file layout, the field for indoor temperature is used. "$water_temp = false;" which is default, means that the the indoor temp is used. If the field is set to "true" and there is a valid temperature in the XML answer from WL, 
field,  {'davis_current_observation'}->{'temp_extra_1'}  
the indoor temp is substituted with this value.
To display the info within W34 a changed "homeindoor.php" is available at Github which could be used in the "Top Row 4 Modules"


NOTE ! If You are updating to the new W34 version V3.4 X5 and migrating ”settings1.php” You have to use "easyweathersetup.php" and update new fields before You start the W34 application.
  • In the section "Set the Units ....." and the field "Distance unit measured miles or kilometres" choose the apropriate value (Used for windrun)
  • In the section "Some Extras....." and the part "These options are.... " choose the default "current34condtions.php"
  • In the part ”Options for Top Row 4 Modules” the value "Clock" is no longer valid for position 1

The program "cumulusdata.php" added support for fields 
  • temp high/low time => cumulus[27/29]
  • wind high/max time => cumulus[31/33]
 W34 changed use for cumulus[5/6/40] so updated app.

NOTE ! If You are updating to the new W34 version V3.4 X4 and migrating ”settings1.php” please note that You have to use "easyweathersetup.php" and update the part ”Options for Top Row 4 Modules” before You start the W34 application.


The program "cumulusdata.php" added support for fields 
  • uv-index => cumulus[43]
  • solar radiation => cumulus[45]

W34 has added support for the fields;
  • min barometer => cumulus[36]
  • windrun => cumulus[17]
so the program "cumulusdata.php" is updated


Due to changes in W34 the program "cumulusdata.php" now calculates trend values for temperature and pressure in a new way and therefore the file "realtime.templ" is extended. So if You are doing an update You must change to the new "realtime.templ" and "realtime.txt". The best way is to delete both files and download the extended "realtime.templ". Then when the program "cumulusdata.php" runs for the first time the "realtime.txt" will be recreated.

From version 3.4G, released 2017-03-25, the croon jobs for the native functions is not used anymore, but it's still needed for the Weatherlink data pull.

No comments:

Post a Comment