ATTENTION: IPWE.pm is still a testing version. It works, but it might not be sufficiently tested.
To download IPWE.pm have a look at the bottom of this page.
Installation instructions:
1. copy IPWE.pm to some directory on your harddisk
2. use the command > use lib "/path/to/your/directory" < in your script to include this module.
IPWE.pm
NAME
IPWE - Query an IPWE 1 (IP-Wetterdatenempfaenger / IP weather data receiver)
VERSION
This document refers to version 0.41 of IPWE released 26.04.2010
SYNOPSIS
use IPWE;
my $url = "http://192.168.1.100";;
my $ipwe = IPWE->new(url => $url);
# print raw data for the whole IPWE (all sensors):
$ipwe->print;
# to get the sensor object for sensor 9:
my $s = $ipwe->sensor(9);
# print raw data for the current sensor object:
$s->print;
# let's get the humidity of the current sensor object:
my $humidity = $s->humidity();
# do something if it's raining:
if ($s->raining) {
# close_roof_window();
}
# Retrieve new information from the IPWE hardware device:
$ipwe->update;
# print temperature for all sensors:
foreach ($ipwe->sensor) {
print $_->temperature . "\n";
}
# for the lazy, instead of doing
my $s = $ipwe->sensor(9);
my $temperature = $s->temperature();
# you can also write:
my $temperature = $ipwe->sensor(9)->temperature();
DESCRIPTION
The IPWE 1 (IP-Wetterdatenempfaenger) is an electronic appliance from ELV (http://www.elv.de) which is able to receive weather information from up to nine local sensors.
This module provides an object oriented API to access the IPWE device and retrieve its sensor values.
While using this module you will have to deal with 10 objects - one of type "IPWE" for the IPWE device itself and nine of type "IPWE::Sensor" (one for each sensor).
CONSTRUCTOR METHODS
- $ipwe = IPWE->new(url => $url)
-
This method constructs a new IPWE object and returns it. During initialization the nine IPWE::Sensor objects will be created internally. There is no constructor method for IPWE:Sensor objects (of course there is a private method to construct them, otherwise we could not create IPWE::Sensor objects at all). A special method "$ipwe->sensor()" exists to return the sensor objects. See below for details.
IPWE OBJECT METHODS
- $ipwe->update
-
This method retrieves the current information from the IPWE hardware device and stores it into nine IPWE::Sensor objects (one object for each sensor). Return values: 1 if update was successful, 0 if unsuccessful.
- $s = $ipwe->
sensor($nr)
- @s = $ipwe->sensor
-
This method returns an IPWE::Sensor object. The first form returns the IPWE::Sensor object for the sensor identified by $nr. Possible values for $nr are digits from 1-9.
The second form without any arguments returns a list of all nine sensor objects.
- $ipwe->print
-
This prints out a nice table which shows all sensors and their values. Values shown are exactly what IPWE 1 reports via its web frond-end or telnet interface (adjust your terminal size, so that the output fits on your screen).
IPWE::Sensor OBJECT METHODS
These are the methods to be used in order to get the weather information from a particular sensor:
- $s->
temperature()
- $s->temperature("Fahrenheit")
- $s->temperature("Kelvin")
- $s->temperature("Rankine")
-
Returns the temperature if the sensor is able to report it. With no argument (default) the unit in °Celsius (°C). Possible other units are: "Fahrenheit", "Kelvin", "Rankine"
- $s->windspeed
- $s->windspeed("m/s)
- $s->windspeed("mph")
- $s->windspeed("kn")
-
Returns the wind speed if the sensor is able to report it. With no argument (default) the unit is km/h (kilometers per hour). Possible other units are: "m/s" (meters per second), "mph" (miles per hour), "kn" (knots)
- $s->beaufort_bezeichnung
-
Returns the Beaufort wind speed in text form (german), like "frische Briese", "orkanartiger Sturm", etc.
- $s->beaufort_description
-
Returns the Beaufort wind speed in text form (english), like "Fresh breeze", "Violent storm", etc.
- $s->rain
-
Returns the amount of rain if the sensor is able to report it. The unit is "mm/24h" which equals to "l/sqm/24h" (liter per square meter in 24 hours).
- $s->rain_beginning
-
Returns 1 (true) at rain beginning (the hash sign '#' preceeds the rain value in the web front-end of IPWE 1), otherwise the empty string "" will be returned.
- $s->rain_increased
-
Returns 1 (true) if the amount of rain has increased in comparison to the previously measured value, otherwise the empty string "" will be returned.
- $s->raining
-
Returns 1 (true) if either $s->rain_beginning or $s->rain_increased returns 1, otherwise the empty string "" will be returned.
- $s->new_values
-
Returns 1 (true) if the measured values for the specified sensor have changed after execution of $ipwe->update, otherwise 0 will be returned. This can be useful e.g. if you only want to know whether new sensor values are available or not in order to control your program flow.
- $s->print
-
This prints out a nice table which shows the information about the requested sensor. Values shown are exactly what IPWE 1 reports via its web frond-end or telnet interface (adjust your terminal size, so that the output fits on your screen).
DEPRECATED IPWE::Sensor OBJECT METHODS
Those are deprecated methods which still exist for backward compatibility. Do not use them any longer, they might disappear in futur releases:
- $s->raining_reported
-
This method is deprecated. Use $s->rain_beginning instead which does exactly the same.
- $s->raining_calculated
-
This method is deprecated. Use $s->rain_increased instead which does exactly the same.
REQUIRED MODULES
LWP::UserAgent; HTML::TableExtract;
AUTHOR
Thomas Hoerndlein
COPYRIGHT
Copyright (c) 2009, Thomas Hoerndlein. All rights reserved, some wrongs reversed. This module is free software. It may be used, redistributed and/or modified under the same terms as Perl itself.