#!/bin/sh HTML=weather.html if test -n "$*"; then HTML="$1" echo "Writing to $HTML" fi cat <$HTML Local Weather
EOF echo "Metcheck forecast" >> $HTML echo "BBC forecast" >> $HTML bothgraphs() { FILENAME="$1" shift rrdtool graph "$FILENAME-today.png" "$@" rrdtool graph --start -1wk "$FILENAME-1week.png" "$@" } current() { FILE="$1" shift rrdtool lastupdate "$FILE" | tail -1 | cut -f2 -d: | xargs echo } startgraphset() { sgsTITLE="$1" echo "
" >> $HTML echo "

$sgsTITLE

" >> $HTML } endgraphset() { echo "
" >> $HTML } graph_avg() { DATASET="$1" shift CF="$1" shift TITLE=`echo $DATASET | tr '_' ' '` bothgraphs "$DATASET" DEF:$DATASET=$DATASET.rrd:$DATASET:$CF LINE2:$DATASET#444444:"$TITLE" startgraphset "$TITLE (`current $DATASET.rrd`)" echo "" >> $HTML endgraphset } graph_avg Outdoor_temperature AVERAGE # wind speed startgraphset "Wind Speed (`current Wind_speed.rrd`)" bothgraphs Wind \ DEF:Wind_speed=Wind_speed.rrd:Wind_speed:AVERAGE \ DEF:Wind_gust=Wind_gust.rrd:Wind_gust:MAX \ LINE2:Wind_gust#999999:"Gust" \ LINE2:Wind_speed#444444:"Speed" echo "" >> $HTML endgraphset # air pressure DATASET="Air_pressure" TITLE=`echo $DATASET | tr '_' ' '` bothgraphs $DATASET DEF:$DATASET=$DATASET.rrd:$DATASET:AVERAGE LINE2:$DATASET#444444:"$TITLE" startgraphset "Air Pressure (`current $DATASET.rrd`)" echo "" >> $HTML endgraphset # humidity bothgraphs Humidity \ DEF:Outdoor_humidity=Outdoor_humidity.rrd:Outdoor_humidity:AVERAGE \ DEF:Indoor_humidity=Indoor_humidity.rrd:Indoor_humidity:AVERAGE \ LINE2:Outdoor_humidity#444444:"Outdoors" \ LINE2:Indoor_humidity#999999:"Indoors" startgraphset "Humidity (out `current Outdoor_humidity.rrd`, in `current Indoor_humidity.rrd`)" echo "" >> $HTML endgraphset graph_avg Indoor_temperature AVERAGE graph_avg Rain_1h AVERAGE #graph_avg Wind_direction AVERAGE echo "

Updated " `date` "

" >> $HTML cat <>$HTML
 
EOF