mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-01-31 12:49:34 +00:00
add IPWE support
git-svn-id: https://svn.fhem.de/fhem/trunk@196 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
500f4a9fff
commit
5e07c2e6b2
@ -404,3 +404,4 @@
|
|||||||
- feature: fhem.pl check modules for compiletime errors and do not initialize
|
- feature: fhem.pl check modules for compiletime errors and do not initialize
|
||||||
them
|
them
|
||||||
- feature: M232 add windows support (thomas 12.05.08)
|
- feature: M232 add windows support (thomas 12.05.08)
|
||||||
|
- feature: add simple ELV IPWE1 support (thomas 12.05.08)
|
150
fhem/FHEM/88_IPWE.pm
Normal file
150
fhem/FHEM/88_IPWE.pm
Normal file
@ -0,0 +1,150 @@
|
|||||||
|
|
||||||
|
package main;
|
||||||
|
##############################################
|
||||||
|
# 88_IPWE.pm
|
||||||
|
# Modul for FHEM
|
||||||
|
#
|
||||||
|
# contributed by thomas dressler 2008
|
||||||
|
# $Id: 88_IPWE.pm,v 1.1 2008-05-18 12:05:24 tdressler Exp $
|
||||||
|
|
||||||
|
use strict;
|
||||||
|
use warnings;
|
||||||
|
use IO::Socket::INET;
|
||||||
|
|
||||||
|
use vars qw {%attr $init_done}; #make komodo happy
|
||||||
|
sub Log($$);
|
||||||
|
#####################################
|
||||||
|
|
||||||
|
sub
|
||||||
|
IPWE_Initialize($)
|
||||||
|
{
|
||||||
|
my ($hash) = @_;
|
||||||
|
# Consumer
|
||||||
|
$hash->{DefFn} = "IPWE_Define";
|
||||||
|
$hash->{GetFn} = "IPWE_Get";
|
||||||
|
$hash->{AttrList}= "model:ipwe delay loglevel:0,1,2,3,4,5,6";
|
||||||
|
}
|
||||||
|
|
||||||
|
#####################################
|
||||||
|
|
||||||
|
sub
|
||||||
|
IPWE_Define($$)
|
||||||
|
{
|
||||||
|
my ($hash, $def) = @_;
|
||||||
|
my $name=$hash->{NAME};
|
||||||
|
my @a = split("[ \t][ \t]*", $def);
|
||||||
|
Log 5, "IPWE Define: $a[0] $a[1] $a[2] $a[3]";
|
||||||
|
return "Define the host as a parameter i.e. ipwe" if(@a < 3);
|
||||||
|
|
||||||
|
my $host = $a[2];
|
||||||
|
my $delay=$a[3];
|
||||||
|
$attr{$name}{delay}=$delay if $delay;
|
||||||
|
Log 1, "ipwe device is none, commands will be echoed only" if($host eq "none");
|
||||||
|
|
||||||
|
my $socket = IO::Socket::INET->new(PeerAddr=>$host,
|
||||||
|
PeerPort=>80, #http
|
||||||
|
timeout=>2,
|
||||||
|
blocking=>1
|
||||||
|
);
|
||||||
|
|
||||||
|
if (!$socket) {
|
||||||
|
$hash->{STATE} = "error opening device";
|
||||||
|
Log 1,"$name: Error opening Connection to $host";
|
||||||
|
return "Can't Connect to $host -> $@ ( $!)\n";
|
||||||
|
}
|
||||||
|
$socket->close;
|
||||||
|
$hash->{Host} = $host;
|
||||||
|
$hash->{STATE} = "Initialized";
|
||||||
|
InternalTimer(gettimeofday()+$delay, "IPWE_GetStatus", $hash, 0);
|
||||||
|
return undef;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
sub IPWE_Get($@)
|
||||||
|
{
|
||||||
|
my ($hash, @a) = @_;
|
||||||
|
return "argument is missing" if(int(@a) != 2);
|
||||||
|
my $msg;
|
||||||
|
$hash->{LOCAL} = 1;
|
||||||
|
my $v = IPWE_GetStatus($hash);
|
||||||
|
delete $hash->{LOCAL};
|
||||||
|
my @data=split (/\n/, $v);
|
||||||
|
if($a[1] eq "status") {
|
||||||
|
$msg= "$a[0] $a[1] =>".$/."$v";
|
||||||
|
}else {
|
||||||
|
my ($l)= grep {/$a[1]/}@data;
|
||||||
|
chop($l);
|
||||||
|
$msg="$a[0] $a[1] =>$l";
|
||||||
|
}
|
||||||
|
$msg="$a[0]: Unknown get command $a[1]" if (!$msg);
|
||||||
|
return $msg;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#####################################
|
||||||
|
|
||||||
|
sub
|
||||||
|
IPWE_GetStatus($)
|
||||||
|
{
|
||||||
|
my ($hash) = @_;
|
||||||
|
|
||||||
|
my $buf;
|
||||||
|
Log 5, "IPWE_GetStatus";
|
||||||
|
my $name = $hash->{NAME};
|
||||||
|
my $host = $hash->{Host};
|
||||||
|
my $text='';
|
||||||
|
my $alldata='';
|
||||||
|
|
||||||
|
my $delay=$attr{$name}{delay}||300;
|
||||||
|
InternalTimer(gettimeofday()+$delay, "IPWE_GetStatus", $hash, 0);
|
||||||
|
my $socket = IO::Socket::INET->new(PeerAddr=>$host,
|
||||||
|
PeerPort=>80, #http
|
||||||
|
timeout=>2,
|
||||||
|
blocking=>1
|
||||||
|
);
|
||||||
|
|
||||||
|
if (!$socket) {
|
||||||
|
$hash->{STATE} = "error opening device";
|
||||||
|
Log 1,"$name: Error opening Connection to $host";
|
||||||
|
return "Can't Connect to $host -> $@ ( $!)\n";
|
||||||
|
}
|
||||||
|
Log 5, "$name: Connected to $host";
|
||||||
|
|
||||||
|
$socket->autoflush(1);
|
||||||
|
$socket->write("GET /ipwe.cgi HTTP/1.0\r\n");
|
||||||
|
my @lines=$socket->getlines();
|
||||||
|
close $socket;
|
||||||
|
Log 5,"$name: Data received";
|
||||||
|
|
||||||
|
my $allines=join('',@lines);
|
||||||
|
my (@tables)= ($allines=~m#<tbody>(?:(?!<tbody>).)*</tbody>#sgi);
|
||||||
|
my ($datatable)=grep{/Sensortyp/} @tables;
|
||||||
|
my (@rows)=($datatable=~m#<tr>(?:(?!<tr>).)*</tr>#sgi);
|
||||||
|
foreach my $l(@rows) {
|
||||||
|
next if ($l=~/Sensortyp/); #headline
|
||||||
|
my ($typ,$id,$sensor,$temp,$hum,$wind,$rain)=($l=~m#<td.*?>(.*?)<br></td>#sgi);
|
||||||
|
next if ($typ=~/^\s+$/);
|
||||||
|
$text= "Typ: $typ, ID: $id, Name $sensor, T: $temp H: $hum";
|
||||||
|
if ($id == 8) {
|
||||||
|
$text.= ",W: $wind, R: $rain";
|
||||||
|
}
|
||||||
|
Log 5,"$name: $text";
|
||||||
|
if (!$hash->{local}){
|
||||||
|
$hash->{CHANGED}[0] = $text;
|
||||||
|
$hash->{READINGS}{$sensor}{TIME} = TimeNow();
|
||||||
|
$hash->{READINGS}{$sensor}{VAL} = $text;;
|
||||||
|
DoTrigger($name, undef) if($init_done);
|
||||||
|
}
|
||||||
|
|
||||||
|
$alldata.="$text\n";
|
||||||
|
}
|
||||||
|
return $alldata;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
1;
|
||||||
|
|
@ -278,3 +278,6 @@
|
|||||||
|
|
||||||
-tdressler Mo May 12 19:00:00 MEST 2008
|
-tdressler Mo May 12 19:00:00 MEST 2008
|
||||||
- feature : add windows support to M232
|
- feature : add windows support to M232
|
||||||
|
|
||||||
|
-tdressler So May 18 13:30:00 MEST 2008
|
||||||
|
- feature : add ELV IPWE1 support
|
@ -427,6 +427,7 @@ make editing of multiline commands transparent.<br><br>
|
|||||||
<li>WS300: ws300pc</li>
|
<li>WS300: ws300pc</li>
|
||||||
<li>EM1010: em1010pc</li>
|
<li>EM1010: em1010pc</li>
|
||||||
<li>WS2000: ws2000</li>
|
<li>WS2000: ws2000</li>
|
||||||
|
<li>IPWE: ipwe</li>
|
||||||
</ul>
|
</ul>
|
||||||
</li><br>
|
</li><br>
|
||||||
|
|
||||||
@ -926,6 +927,41 @@ make editing of multiline commands transparent.<br><br>
|
|||||||
<br>
|
<br>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
|
<a name="IPWE"></a>
|
||||||
|
<h4>Type IPWE</h4>
|
||||||
|
<ul>
|
||||||
|
<code>define <name> IPWE <hostname> [<delay>]</code>
|
||||||
|
<br><br>
|
||||||
|
|
||||||
|
Define a IPWE network attached weather data receiver device sold by ELV. Details see <a
|
||||||
|
href="http://www.elv.de/output/controller.aspx?cid=74&detail=10&detail2=21508">here</a>.
|
||||||
|
It's intended to receive the same sensors as WS300 (8 T/H-Sensors and one kombi sensor),
|
||||||
|
but can be accessed via http and telnet.
|
||||||
|
<br>
|
||||||
|
For unknown reason, my try to use the telnet interface was not working neither with raw sockets
|
||||||
|
nor with Net::Telnet module. Therefore i choosed here the "easy" way
|
||||||
|
to simple readout the http page and extract all data from the offered table. For this reason this module doesnt
|
||||||
|
contain any option to configure this device.
|
||||||
|
<br><br><b>Note:</b> You should give your sensors a name within the web interface, once they a received the first time.
|
||||||
|
<br>To extract a single sensor simply match for this name or sensor id<br>
|
||||||
|
<br>
|
||||||
|
|
||||||
|
Attributes:
|
||||||
|
<ul>
|
||||||
|
<li><code>delay</code>: seconds between read accesses(default 300s)</li>
|
||||||
|
|
||||||
|
</ul>
|
||||||
|
<br>
|
||||||
|
Example:
|
||||||
|
<ul>
|
||||||
|
<code>define ipwe IPWE ipwe1 120</code><br>
|
||||||
|
</ul>
|
||||||
|
<ul>
|
||||||
|
<code>attr ipwe delay 600</code> : 10min between readouts<br>
|
||||||
|
</ul>
|
||||||
|
<br>
|
||||||
|
</ul>
|
||||||
|
|
||||||
<a name="FileLog"></a>
|
<a name="FileLog"></a>
|
||||||
<h4>Type FileLog</h4>
|
<h4>Type FileLog</h4>
|
||||||
<ul>
|
<ul>
|
||||||
@ -1334,7 +1370,33 @@ make editing of multiline commands transparent.<br><br>
|
|||||||
<code>list</code> statement for the device).
|
<code>list</code> statement for the device).
|
||||||
<br><br>
|
<br><br>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
|
<h4>Type WS2000:</h4>
|
||||||
|
<ul>
|
||||||
|
<code>get <name> list</code>
|
||||||
|
<br>
|
||||||
|
Gets the last reading of all received sensord
|
||||||
|
<br><br>
|
||||||
|
<code>get <name> [TH0..TH7, T0..T7, I0..I7, R0..R7, W0..W7, L0..L7, P0..P7,LAST,RAW]</code><br>
|
||||||
|
get the last reading for the name sensor, <br>
|
||||||
|
<code>LAST</code>: Last received Sensor
|
||||||
|
<br><br>
|
||||||
|
<code>RAW</code>: original Data from interface
|
||||||
|
<br><br>
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
|
||||||
|
<h4>Type IPWE</h4>
|
||||||
|
<ul>
|
||||||
|
<code>get <name> status</code>
|
||||||
|
<br><br>
|
||||||
|
Gets actual data from device for sensors with data
|
||||||
|
<br><br>
|
||||||
|
<code>get <name> < sensorname> </code>
|
||||||
|
<br><br>
|
||||||
|
will grep output from device for this sensorname
|
||||||
|
<br><br>
|
||||||
|
</ul>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
|
|
||||||
|
@ -15,7 +15,7 @@ Formerly known as fhz1000.pl
|
|||||||
|
|
||||||
<h2>News (as of =DATE=, Version =VERS=)</h2>
|
<h2>News (as of =DATE=, Version =VERS=)</h2>
|
||||||
<ul>
|
<ul>
|
||||||
|
<li>feature: added ELV IPWE-Support via 88_IPWE.pm (thomas 18.05.08)</li>
|
||||||
<li>feature: added windows COM-Port support to FHZ, EM,WS2000,WS300 (thomas 12.05.08)</li>
|
<li>feature: added windows COM-Port support to FHZ, EM,WS2000,WS300 (thomas 12.05.08)</li>
|
||||||
<li>feature: added ReadyFn to have an alternate methode to check if data available(thomas 11.05.08)</li>
|
<li>feature: added ReadyFn to have an alternate methode to check if data available(thomas 11.05.08)</li>
|
||||||
<li>feature: added ws2000 support via 87_WS2000.pm(thomas 10.05.08)</li>
|
<li>feature: added ws2000 support via 87_WS2000.pm(thomas 10.05.08)</li>
|
||||||
@ -78,7 +78,8 @@ Currently implemented features:<br>
|
|||||||
<li>reading attached SCIVT devices</li>
|
<li>reading attached SCIVT devices</li>
|
||||||
<li>reading attached M232 devices</li>
|
<li>reading attached M232 devices</li>
|
||||||
<li>reading attached WS2000/WS25000 devices, also via raw network converters(xport)</li>
|
<li>reading attached WS2000/WS25000 devices, also via raw network converters(xport)</li>
|
||||||
<li>logging events to files or databases
|
<li>extract sensor data from IPWE networked weather data receiver</li>
|
||||||
|
<li>logging events to files or databases</li>
|
||||||
<li>logging events to files or databases, with regexp filters</li>
|
<li>logging events to files or databases, with regexp filters</li>
|
||||||
<li>notifying external programs or internal modules when receiving certain
|
<li>notifying external programs or internal modules when receiving certain
|
||||||
events</li>
|
events</li>
|
||||||
|
Loading…
Reference in New Issue
Block a user