Skip to content
Lieven Hollevoet edited this page Mar 13, 2016 · 3 revisions

How to create and customize weather graphs

Misterhouse has the ability to generate graphs from any data source that populates the global %Weather hash. This can be data from a weather station, an internet source, or a combination of the two. The following scripts all support the %Weather hash and can be used to generate graphs:

  • froggyrita.pl
  • internet_weather.pl
  • internet_weather_noaa.pl
  • weather_aws.pl
  • weather_iB_OWW_client.pl
  • weather_iB_OWW_txt_client.pl
  • weather_metar.pl
  • xAP_weather.pl

The weather graphing facility is controlled by the mh/code/common/weather_rrd_update.pl script, which creates and updates the RRD file, and mh/bin/weather_rrd_update_graphs, which is run in the background to actually create the graphs.

The weather_rrd_update.pl script can also optionally create comma separated value (csv) text files of your weather data for other uses.

Getting started

Before you can start generating weather graphs, you need to enable one of the weather scripts listed above or write your own script that populates the %Weather hash. See mh/lib/weather_common.pm for more information about the %Weather hash.

RRDtool installation

You will also need to install rrdtool and the perl bindings for RRD.

Windows

Windows users can install the perl bindings by running "ppm install rrds".

Linux/OS X

You can either install RRD from source or install a binary package suited to your distribution. Then use CPAN to install RRD.pm.

Activation

Use the "Common code select" web page to activate the weather_rrd_update.pl script. By default, this script will create an RRD file and start generating graphs in your data directory in a subdirectory named rrd. To view the graphs, wait at least ten minutes, then point your browser at http://localhost/bin/weather_graph.pl?tempout for the outdoor temperature graphs. See the table below for the other graph names.

The default ini parameters will probably be fine to get you started, but you will probably want to change the weather_graph_sensor_names parameter to remove some unused sensors from your indoor humidity and temperature graphs. A good entry to start with would be:

temp => Temperature outdoor, humid => Humidity outdoor, dew => Temperature dewpoint outdoor, apparent => Apparent temperature, intemp => Temperature indoor, inhumid => Humidity indoor, indew => Temperature dewpoint indoor

Caveats

The process of creating the weather graphs might be too cpu intensive on slower systems. If this is the case, you can use the ini parameters to reduce the number of graphs and how frequently they are created.

Data is copied from the %Weather hash to the RRD file once a minute.

The "Indoor Temperatures" and "Indoor Humidity" graphs display the "spare" Temp/Humidity values. They will NOT display any graphed data if the "Indoor" value has no data. For example, the "Indoor Humidity" graph will not graph data (the data lines will still show the humidity value) if HumidSpare1 has data but the TempIndoor value has no data.

Data is stored in the default units listed below. If your data source uses different units than these, use the weather_uom_ ini parameters to specify them. The data will be converted from these units into the default units and stored in the RRD file, then converted back when graphed. There doesn't appear to be a way to collect data in one unit of measure, and graph it in another.

The default unit is fahrenheit for TempOutdoor, TempIndoor, TempSpare1, TempSpare2, TempSpare3, TempSpare4, TempSpare5, TempSpare6, TempSpare7, TempSpare8, TempSpare9, TempSpare10, DewOutdoor, DewIndoor, DewSpare1, DewSpare2, DewSpare3, and TempOutdoorApparent.

The default unit is inches for Barom and RainTotal.

The default unit is miles per hour for WindGustSpeed and WindAvgSpeed.

The default unit is inches per hour for RainRate.

The graphing capability in Misterhouse is currently limited to weather data. You could put other data into the %Weather hash and graph it, but you won't be able to easily change the title of the graphs. Only the indoor humidity and temperature graphs can be easily modified with different data sources.

The weather_rrd_update.pl script creates a trigger named "update rain totals from RRD database", which updates the $Weather{RainLast{x}Hours} variables from the RRD file data.

You can turn on debugging messages by adding weather_graph to the debug ini parameter.

Advanced configuration

The ini parameters are listed here by category with a description, the default value, and possible options in parentheses.

File and Directory Locations

RRD database weather data

weather_data_rrd = "$config_parms{data_dir}/rrd/weather_data.rrd" (any file location)

Archive weather data in flat file (type csv), blank to disable File is suffixed by $Year_Month_Now

weather_data_csv = "" (any file location)

Graph file directory

weather_graph_dir = $config_parms{data_dir}/rrd (any directory location)

Web dir for graph files (should match weather_graph_dir)

html_alias_rrd = $config_parms{data_dir}/rrd (any directory location)

Unit of Measure for Collecting and Graphing Data

  • weather_uom_temp = F (C, F)
  • weather_uom_baro = in (mb, in)
  • weather_uom_wind = mph (m/s, mph, kph)
  • weather_uom_rain = in (mm, in)
  • weather_uom_rainrate = in/hr (mm/hr, in/hr)

Colors Used in Graphs

Each element in the graphs has a color associated with it that can be customized by setting an ini parameter. See the table below for the element names associated with each sensor.

In addition to the graph lines and areas, you can also customize the following graph elements as well:

altbg  = 'EEEEEE'; # alternating (with white) background color
na     = 'C0C0C0'; # color for unknown area or 0 for gaps
zero   = '000000'; # color of zero line
shadea = '0000CC'; # share color A
shadeb = '0000CC'; # share color B
white  = 'ffffff'; # color white

To customize the color of an element, add "weather_rrd_color_" in front of the element's name when constructing the ini parameter name. For example:

weather_rrd_color_tempspare1=00ff00

Graph Customization

Footer center line text

weather_graph_footer = "Last updated $Time_Date, copyright www.domotix.net" (any text)

Sensor name for indoor temperature and humidity graphs

weather_graph_sensor_names = "temp => Temperature outdoor, humid => Humidity outdoor, dew => Temperature dewpoint outdoor, press => Pressure outdoor, dir => Wind direction, avgdir => Wind average direction, speed => Wind speed, avgspeed => Wind average speed, apparent => Apparent temperature, rate => Rain rate, rain => Rain total, intemp => Temperature indoor, inhumid => Humidity indoor, indew => Temperature dewpoint indoor, tempspare1 => Temperature extra sensor 1, humidspare1 => Humidity extra sensor 1, dewspare1 => Temperature dewpoint extra sensor 1, tempspare2 => Temperature extra sensor 2, humidspare2 => Humidity extra sensor 2, dewspare2 => Temperature dewpoint extra sensor 2, tempspare3 => Temperature extra sensor 3, humidspare3 => Humidity extra sensor 3, dewspare3 => Temperature dewpoint extra sensor 3, tempspare4 => Temperature extra sensor 4, humidspare4 => Humidity extra sensor 4, tempspare5 => Temperature extra sensor 5, humidspare5 => Humidity extra sensor 5, tempspare6 => Temperature extra sensor 6, humidspare6 => Humidity extra sensor 6, tempspare7 => Temperature extra sensor 7, humidspare7 => Humidity extra sensor 7, tempspare8 => Temperature extra sensor 8, humidspare8 => Humidity extra sensor 8, tempspare9 => Temperature extra sensor 9, humidspare9 => Humidity extra sensor 9, tempspare10 => Temperature extra sensor 10, humidspare10 => Humidity extra sensor 10 "

Note that although the default weather_graph_sensor_names parameter includes entries for wind and rain sensors, those cannot currently be customized. See the table below to see which sensors can be added, removed and renamed on your graphs.

Barometric Pressure Adjustment

Initialize the altitude of the local weather stationn in feet. Used to calculate the sea level barometric pressure.

altitude = 0 (any number)

Ratio of barometric pressure to altitude in millibars/meter. Used to calculate how much is added to the sea level barometric pressure in the weather graphs based on altitude.

ratio_sea_baro = 8 (any number)

Misc Parameters

Format used to generate graphs.

weather_rrd_format = PNG (PNG, GIF)

Frequency for graphs generation in minutes.

weather_graph_frequency = 10 (any integer number)

Skip generation graphs, blank to generate all the graphs.

weather_graph_skip = (any combination of tempout tempin windspeed winddir raintotal rainrate press humout humin)

Skip generation graphs for specific periods, blank to generate graphs for all periods.

weather_graph_period_skip = (any combination of 6hour 12hour 1day 2day 1week 2week 1month 2month 6month 1year 2year 5year)
|| Graph name || Graph title || %Weather vars || Entity name and
default color ||= Customizable ||
|| tempout || Temperatures || TempOutdoor
DewOutdoor
TempOutdoorApparent || temp = '330099'
dew = '00ff00'
apparent = '3300FF' ||   ||
|| tempin || Temperatures || TempIndoor
DewIndoor
TempSpare1
TempSpare2
TempSpare3
TempSpare4
TempSpare5
TempSpare6
TempSpare7
TempSpare8
TempSpare9
TempSpare10 || tempin = '990000'
dewin = 'ff9900'
tempspare1 = 'FF0000'
tempspare2 = '990099'
tempspare3 = 'CC0099'
tempspare4 = 'CC33CC'
tempspare5 = 'FF00FF'
tempspare6 = 'FF99CC'
tempspare7 = '99FF00'
tempspare8 = '006600'
tempspare9 = '66FFFF'
tempspare10 = '0000CC' ||= X ||
|| humout || Outdoor humidity || HumidOutdoor MAX*
HumidOutdoor MIN*
HumidOutdoor || humid = '330099'
white = 'ffffff'
moyhumid = 'ff0000' ||=   ||
|| humin || Indoor humidity || HumidIndoor
HumidSpare1
HumidSpare2
HumidSpare3
HumidSpare4
HumidSpare5
HumidSpare6
HumidSpare7
HumidSpare8
HumidSpare9
HumidSpare10 || humidin = '990000'
humidspare1 = 'FF0000'
humidspare2 = '990099'
humidspare3 = 'CC0099'
humidspare4 = 'CC33CC'
humidspare5 = 'FF00FF'
humidspare6 = 'FF99CC'
humidspare7 = '99FF00'
humidspare8 = '006600'
humidspare9 = '66FFFF'
humidspare10 = '0000CC' ||= X ||
|| press || Barometric pressure || Barom MAX*
Barom MIN*
Barom || press = '330099'
white = 'ffffff'
moypress = 'ff0000' ||=   ||
|| winddir || Wind directions || WindGustDir MAX*
WindGustDir MIN*
WindGustDir || dir = '330099'
white = 'ffffff'
moydir = 'ff0000' ||=   ||
|| windspeed || Wind speed || WindGustSpeed MAX*
WindGustSpeed MIN*
WindGustSpeed || speed = '330099'
white = 'ffffff'
moyspeed = 'ff0000' ||=   ||
|| rainrate || Rain rate || RainRate MAX*
RainRate MIN*
RainRate || rainmax = '000099'
rain = '3300FF'
moyrain = 'ff0000' ||=   ||
|| raintotal || Rain total || RainTotal MAX*
RainTotal MIN*
RainTotal || rainmax = '000099'
rain = '3300FF'
moyrain = 'ff0000' ||=   ||
  • these are MAX and MIN values stored in the RRD file and are graphed as areas. All other elements are AVE values stored in the RRD file and are graphed as lines.
Clone this wiki locally