deformed-offering

Free Weather Website Templates

They're free, but use at your own risk

The scripts referenced here are used in the operation of this weather station, and may be freely copied and used to support your station. Please note that you use these scripts at your own risk. No warranty is expressed or implied. I accept no liability for any damages that may ensue from their use.
You will need to configure them for your own particular weather station website.
RSS feed for Scripts Updates A RSS Feed is available to help keep you informed on updates to the scripts.

Many of these scripts are now available on GitHub at https://github.com/ktrue

Buy Me A Coffee If you find one or more of the scripts useful to you, please consider making a donation to help offset the routine expenses of operation of this website.
Thanks for your kind support!

A Version History is available -- check back from time to time to see if there are updates to scripts you have downloaded earlier. Announcements of version updates and new scripts are made on WXForum.net and Weather-Watch forums and saratogaWXPHP Twitter account as they become available.

Note: Twitter widget has been disabled 3-Jul-2023 since it no longer displays the recent update Tweets.

This page was updated Tuesday, 09-Jan-2018 6:04 PM

PHP/AJAX Website Template Set - Settings-weather.php - WLCOM-Plugin

The configuration for Settings-weather.php discussed here is for the WLCOM-Plugin.

This plugin will retrieve your data from Weatherlink.com (Davis Weather stations only) at one minute intervals and create a set of weather tags matching those produced by the PC/Mac version of locally run WeatherLink software (using the WL-plugin). The primary differences are:

Note: As of January, 2018, this plugin has been rewritten to use the newer API from WeatherLink.com (V1.0 and V2.0 of their website). It no longer requires your weatherlink.com userid (still uses the weatherlink.com password), their API now requires two new items (Device ID, Key) from the Setup, WeatherLink.com dialog in WeatherLink V6 software. That, along with your existing password for your WeatherLink.com website access allows retrieval of your data as before.

WeatherLink Setup Dialog

For WeatherlinkIP users, the Device ID and Key are on the device (and packaging). You'll need to register on weatherlink.com for a userid/password, and register that Device ID and Key for use.

  • WeatherLink.com does not provide 'Yesterday' nor historical data. (See below for configuration of a cron job to capture 'today' data at 23:58 daily and use it as 'yesterday' data tomorrow.)
  • WeatherLink.com does not provide station graphs nor NOAA-style text reports for month or year (so the WL-plugin wxgraphs.php and wxnoaareports.php pages are not available with the WLCOM-plugin)
  • WeatherLink.com updates are (at a minimum) of once per minute.

Note: If you are running WeatherLink PC/Mac software on your weather station system, you can get more features by using the WL-plugin instead of this WLCOM-plugin to power your website.
Using the WL-plugin will allow station graphs, NOAA reports and automatic 'yesterday' data to be available (when the WeatherLink setup is completed).
This WLCOM-plugin should only be used by Davis WeatherLinkIP or Vantage Connect stations which only submit to WeatherLink.com and are not otherwise running WeatherLink software on a PC/Mac system.

<?php
#---------------------------------------------------------------------------
#  required settings for WeatherLink.com Network
#---------------------------------------------------------------------------
# Optional realtime settings.  Use if you are using 1 minute uploads of the WLrealtime.txt file
# uncomment next line ($SITE['ajaxScript']) to enable AJAX updates to your website. 
# $SITE['ajaxScript'] = 'ajaxWLCOMwx.js'; // optional for AJAX enabled display
#
$SITE['WXtags']     = 'WLCOMtags.php';   // for weather variables
$SITE['WLCOMpw']    = '-your-password-'// password for your WeatherLink.com userid
// following two settings are from the WeatherLink, Setup, WeatherLink.com network settings dialog
$SITE['WLCOMdid']   = '-device-id-';   // WeatherLink.com Network configuration Device ID
$SITE['WLCOMkey']   = '-key-';         // WeatherLink.com Network configuration Key
$SITE['WLCOMcacheDW'] = 60;            // number of seconds for conditions cache life (default=60)
#
# --------------------------------------------------------------------------
# Weather Station sensors and options for dashboard
#
$SITE['conditionsMETAR'] = 'KSJC';  // set to nearby METAR for current conditions icon/text
#  comment out conditionsMETAR if no nearby METAR.. conditions icon/text will not be displayed
#
$SITE['overrideRain'] = true// =true then rain rate will set rain words instead of METAR rain words
#                               // =false - no change to METAR rain words (station rain rate not used)
$SITE['DavisVP'] = true;  // set to false if not a Davis VP weather station
$SITE['UV']           = true;  // set to false if no UV sensor
$SITE['SOLAR']   = true;  // set to false if no Solar sensor
#
##########################################################################
# end of configurable settings

WeatherLink.com Network Configuration settings in Settings-weather.php

$SITE['ajaxScript'] = 'ajaxWLCOMwx.js';
This optional setting specifies the filename of the AJAX JavaScript that will read the WLrealtime.php file and update your pages with new data.
Comment out this setting (by placing either # or // in the front of this line) if you do not want AJAX updates active on your website pages.
$SITE['WXtags'] = 'WLCOMtags.php';
This setting specifies the filename of the WeatherLink weather tags file. This file is uploaded through WeatherLink and contains the current weather data associated with WeatherLink HTML tags. The data is loaded in a $WX[] array with the WeatherLink tag names used as the key to access the data in the associative array.
$SITE['WLCOMpw'] = '-your-password-';
This REQUIRED setting specifies the password associated with your WeatherLink.com userid.
$SITE['WLCOMdid'] = '-device-id-';
This NEW REQUIRED setting specifies the WeatherLink Device ID used for your station's conditions reporting.
$SITE['WLCOMkey'] = '-key-';
This NEW REQUIRED setting specifies the WeatherLink Key used for your station's conditions reporting.
$SITE['WLCOMcacheDW'] = 60;
This setting specifies the cache lifetime in seconds for the WeatherLink.com XML file that contains your current conditions. It should be set to the same interval (in seconds) that you use to upload your conditions to WeatherLink.com (60 seconds is the default).
$SITE['conditionsMETAR'] = 'KSJC';
This setting specifies the ICAO/name of the near-by METAR station that will be used to provide current conditions (weather/sky cover) for the ajax-dashboard and ajax-gizmo.
A list of nearby METAR names can be found using the find METAR query script.
$SITE['overrideRain'] = true;
This setting specifies whether the weather station rain-rate should display the rain words based on the current rain rate.
=false : METAR rain words (if any) will be displayed as current condition.
=true : current station rain rate will set words (as shown below) and rain words direct from METAR are removed. Icon is also set appropriately.
Words and selection criteria:
"Light Rain" when rain rate is > 0.0 and < 2.5 mm (0.098 in) per hour
"Moderate Rain" when rain rate is >= 2.5 mm (0.098 in) and < 7.6 mm (0.30 in) per hour
"Heavy Rain" when rain rate is >= 7.6 mm (0.30 in) per hour and < 50 mm (2.0 in) per hour
"Violent Rain" when rain rate is >= 50 mm (2.0 in) per hour
If this setting is ommitted from Settings-weather.php, the default will be assumed as 'true' to enable the function.
If enabled, the rain words from the METAR will be removed, and the above words used based on the current rain rate.
$SITE['DavisVP'] = true;
This setting specifies whether you have a Davis VP/Vue station.
= true means you have a Davis VP/VP2/Vue station
= false means you do not have a Davis VP/VP2/Vue station and the display of the VP forecast on the ajax-dashboard is suppressed.
$SITE['UV'] = true;
This setting specifies whether your station has a UV sensor.
= true means your station has a UV sensor.
= false means your station does not have a UV sensor which will result in the ajax-dashboard displaying a UV forecast in that area instead of the UV sensor value.
$SITE['SOLAR'] = true;
This setting specifies whether your station has a Solar sensor.
= true means your station has a Solar Radiation sensor.
= false means your station does not have a Solar Radiation sensor which will result in the ajax-dashboard displaying a UV forecast in that area instead of the Solar sensor value.

WLCOM-Plugin - capturing 'yesterday' data for display

One of the drawbacks with the WeatherLink.com website data is a lack of 'yesterday' data on the website. To be able to display yesterday's high/low temperatures/times and yesterday's rainfall amounts, you will need to run a cron job every hour at 58 minutes past the hour to capture the yesterday values at 23:58 local time each day. The WLCOM-plugin includes a saveYesterday.php script that will do this for you.

Edit the sample cron-yday.sh script for your home directory path and PHP path. Make sure that the file only has Unix line endings (NL) and not DOS line endings (CR NL). Notepad++ makes it easy to remove the DOS line endings if they are there. Bash scripts will not run with DOS line endings.

cron-yday.txt script:

#!/bin/bash
# cron job to get 'yesterday' data for WLCOM plugin
# Version 1.00 - 22-Apr-2017 - initial release
# 
# Note: customize the settings below for your site's specific paths/names
# use a cron job to run this script like:
# 58 * * * * bash "$HOME/httpdocs/cron-yday.txt"
#
# after editing this file, make sure that Unix line endings (LF) are used and
# NOT DOS line endings (CR LF).  Use Notepad++ to edit the file in Windows.
#
# --- begin settings
HDIR="$HOME/httpdocs"
SCRIPT=saveYesterday.php
URL="http://your.website.com/$SCRIPT"
PHPcmd=/usr/bin/php
CURLcmd=/usr/bin/curl
USECMD=PHP
#USECMD=CURL
# --- end settings
cd $HDIR

LOGFILE=$HDIR/cache/LOG_$SCRIPT.txt

# Use one or the other .. direct is prefered over curl
if [ "$USECMD" == "PHP" ]
then
  $PHPcmd -q $SCRIPT >> $LOGFILE  2> /dev/null
fi
if [ "$USECMD" == "CURL" ]
then
  $CURLcmd -s $URL >> $LOGFILE
fi
#

Then you can set cron to run the script hourly at 58 minutes past the hour with a cron spec of:

58 * * * * bash "$HOME/httpdocs/cron-yday.txt"

The saveYesterday.php script will use your timezone setting from Settings.php to determine if this is local hour 23, then it will save a copy of the current $WX[] variables in a file. That file will be loaded and used to extract the 'yesterday' values when needed. The saveYesterday.php script does nothing if the local hour is not equal 23.

It is strictly optional to enable the yesterday data capture -- if omitted, then the ajax-dashboard will just not display the yesterday values (temperature high/low/times and rainfall)

WLCOM-Plugin - URL options

You can use URL options on the WLCOMtags.php script (via a browser) to see additional information:

http://your.website.com/WLCOMtags.php?sce=dump will activate the debugging feature and also show the current contents of the $WX[] array for the weather data.

http://your.website.com/WLCOMtags.php?sce=view will show the source code for the WLCOMtags.php script itself.

http://your.website.com/WLCOMtags.php?ssg or
http://your.website.com/WLrealtimegauges.php will produce the current JSON file needed for the Steel Series Gauges (V12).

http://your.website.com/WLCOMtags.php?realtime or
http://your.website.com/WLrealtime.php will produce the current file needed for the ajaxWLCOM.js AJAX script

http://your.website.com/WLCOMtags.php?force=tags will force a reload of the Weatherlink.com XML conditions file.

WLCOM-Plugin - Steel Series Gauges configuration

The Steel Series Gauges are included with the WLCOM-plugin. Add wxssgauges.php to your flyout-menu.xml to activate the link on your site.

WLCOM-Plugin - multi-language support

The new wxsummary.php page has multi-language support built-in. Run wxsummary.php?show=missing on your site and view-source the page. At the bottom will be a list of terms to add to your language-LL.txt file for translation.

deformed-offering