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 Monday, 26-Feb-2018 11:20 AM

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

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

This plugin will retrieve your data from ambientweather.net at one minute intervals and create a set of weather tags closely matching those produced by the PC/Mac version of locally run WeatherLink (for Davis weather stations) software.
You can use any ambientweather.net supported weather station with this plugin.

Note:The ambientweather.net API service is still in Beta at this time.
To use this plugin:

  1. You must have a valid loginid/password for the ambientweather.net website
  2. You must have (at least) one weather station submitting data to ambientweather.net website.
  3. You must have an apiKey associated with your ambientweather.net account. Currently, those are issued by Ed at ed@ambientweather.com. Email him your device macAddress to have an apiKey created for your account.
    After the Beta is over, an apiKey will be available by request on the ambientweather.net account page.

Some additional information about the ambientweather.net service and this plugin:

  • The plugin does not provide yesterday data by default. You can set up a cron job to do this. (See below for configuration of a cron job to capture 'today' data at 23:58 daily and use it as 'yesterday' data tomorrow.)
  • The plugin does not provide station graphs nor NOAA-style text reports for month or year, and except for rain, no data is available regarding monthly/yearly high/low values. The plugin does compute daily min/max values/times.
  • ambientweather.net JSON data updates are at (a minimum) once per minute, with summary min/max data at 5 minute intervals. The summary JSON data may be up to 10 minutes old.
  • ambientweather.net enforces a query rate per apiKey of one per second (and 3 per second for Application Key). As a result, the plugin will wait 1 second between queries and retry up to 3 times to get the data -- this may result in long delays in loading a page while the data is gathered with two-different JSON requests. The current (device) data is cached for 60 seconds, the summary data is cached for 120 seconds.
  • You will likely see differences between the ambientweather.net dashboard display and data displayed on your website. This is normal as your website data is likely to be 'older' than that displayed on the ambientweather.net dashboard due to caching and update update times for the API data on ambientweather.net.


<?php
#---------------------------------------------------------------------------
#  required settings for ambientweather.net AWN-plugin
#---------------------------------------------------------------------------
#Note: AJAX as data is only available in 1 minute interval results
$SITE['ajaxScript'] = 'ajaxAWNwx.js'// for AJAX enabled display
#
$SITE['WXtags']     = 'AWNtags.php';  // for weather variables
#

$SITE['AWNdid']   = '-your-device-id-'// your xx:xx:xx:xx:xx:xx device ID on Ambientweather.net
$SITE['AWNkey']   = '-your-apikey-';        // your apiKey for access to Ambientweather.net
$SITE['AWNcacheDW'] = 60;             // number of seconds for conditions cache life (default=120)
#
# --------------------------------------------------------------------------
# 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
#

ambientweather.net Network Configuration settings in Settings-weather.php

$SITE['ajaxScript'] = 'ajaxAWNwx.js';
This optional setting specifies the filename of the AJAX JavaScript that will read the AWNrealtime.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'] = 'AWNtags.php';
This setting specifies the filename of the ambientweather.net weather tags file. This file will query ambientweather.net and and processes the JSON responses to load weather data in a $WX[] array with the WeatherLink tag names used as the key to access the data in the associative array.
$SITE['AWNdid'] = '-your-device-id-';
This REQUIRED setting specifies the ambientweather.net Device ID used for your station's conditions reporting. A device ID is a macAddress like 'A4:2B:B0:B4:3F:DC'. It is shown on your ambientweather.net devices page.
$SITE['AWNkey'] = '-your-apikey-';
This REQUIRED setting specifies the ambientweather.net apiKey used for your station's conditions reporting. Your apiKey is displayed on your ambientweather.net account page.
$SITE['AWNcacheDW'] = 60;
This setting specifies the cache lifetime in seconds for the ambientweather.net JSON file that contains your current conditions. As ambientweather.net only updates the JSON data every minute, this should be left at 60 seconds.
$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.

AWN-Plugin - capturing 'yesterday' data for display

One of the drawbacks with the ambientweather.net 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 AWN-plugin includes a saveYesterday.php script that will do this for you.

Edit the sample cron-yday.txt 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 AWN 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)

AWN-Plugin - URL options

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

http://your.website.com/AWNtags.php?sce=dump will activate the debugging feature and also show the current contents of the $WX[] array for the weather data. Do a view-source of this page to see the details (in HTML comments) about the running of the script (useful for debugging).

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

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

http://your.website.com/AWNtags.php?realtime or
http://your.website.com/AWNrealtime.php will produce the current file needed for the ajaxAWN.js AJAX script

http://your.website.com/AWNtags.php?force=tags will force a reload of the ambientweather.net JSON conditions and summary files.

AWN-Plugin - Steel Series Gauges configuration

The Steel Series Gauges are included with the AWN-plugin. Add wxssgaugesawn.php to your flyout-menu.xml to activate the link on your site.
Also add wxsummaryawn.php to your flyout-menu.xml to activate the summary page.

AWN-Plugin - multi-language support

The new wxsummaryawn.php page has multi-language support built-in. Run wxsummaryawn.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