2
0
mirror of https://github.com/fhem/fhem-mirror.git synced 2024-11-22 02:59:49 +00:00

Sonstiges: Moved modules from Sacha Gloor to contrib/sacha_gloor (Forum #110221)

git-svn-id: https://svn.fhem.de/fhem/trunk@21688 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
jeschkec 2020-04-15 07:08:17 +00:00
parent 19b19c9c7a
commit e4fa3230a5
10 changed files with 1911 additions and 10 deletions

View File

@ -147,13 +147,9 @@ FHEM/21_OWTHERM.pm pahenning 1Wire
FHEM/21_OWVAR.pm pahenning 1Wire
FHEM/21_SONOSPLAYER Reinerlein Multimedia
FHEM/21_VBUSDEV.pm Tobias/pejonp Sonstige Systeme
FHEM/22_ALL3076.pm jeschkec Sonstiges
FHEM/22_HOMEMODE.pm DeeSPe Automatisierung
FHEM/23_ALL4027.pm jeschkec Sonstiges
FHEM/23_KOSTALPIKO.pm john CodeSchnipsel
FHEM/23_LUXTRONIK2.pm tupol Heizungssteuerung/Raumklima (link als PM an tupol)
FHEM/23_WEBIO.pm jeschkec Sonstiges
FHEM/23_WEBIO_12DIGITAL.pm jeschkec Sonstiges
FHEM/24_Iluminize.pm VolkerKettenbach Sonstige Systeme
FHEM/24_NetIO230B.pm rudolfkoenig/orphan Sonstiges
FHEM/24_TPLinkHS110.pm VolkerKettenbach Sonstige Systeme
@ -416,7 +412,6 @@ FHEM/83_IOhomecontrol.pm neubert Sonstige Systeme
FHEM/84_IOhomecontrolDevice.pm neubert Sonstige Systeme
FHEM/86_Robonect.pm andi291 Sonstige Systeme
FHEM/87_WS2000.pm tdressler Sonstiges
FHEM/88_ALL4000T.pm jeschkec Sonstiges
FHEM/88_HMCCU.pm zap HomeMatic
FHEM/88_HMCCUCHN.pm zap HomeMatic
FHEM/88_HMCCUDEV.pm zap HomeMatic
@ -424,11 +419,7 @@ FHEM/88_HMCCURPC.pm zap HomeMatic
FHEM/88_HMCCURPCPROC.pm zap HomeMatic
FHEM/88_IPWE.pm tdressler Sonstiges
FHEM/88_Itach_IRDevice ulimaass Sonstige Systeme
FHEM/88_Itach_Relay.pm jeschkec Automatisierung
FHEM/88_LINDY_HDMI_SWITCH.pm jeschkec Multimedia
FHEM/88_Timer.pm HomeAuto_User/elektron-bbs Automatisierung
FHEM/88_VantagePro2.pm jeschkec Sonstiges
FHEM/88_WEBCOUNT.pm jeschkec Sonstiges
FHEM/88_xs1Bridge.pm HomeAuto_User Sonstige Systeme
FHEM/88_xs1Dev.pm HomeAuto_User Sonstige Systeme
FHEM/89_FULLY.pm zap Frontends
@ -603,7 +594,7 @@ FHEM/lib/SHC_packet_layout.xml rr2000 Sonstige Systeme
FHEM/lib/SWAP/* justme1968 Sonstige Systeme
FHEM/lib/UPnP/* Reinerlein Multimedia
contrib/23_WEBTHERM.pm jeschkec Sonstiges
contrib/sacha_gloor/* jeschkec Sonstiges
contrib/70_ONKYO_AVR_PULL.pm loredo (deprecated)
contrib/DS_Starter/* DS_Starter Sonstiges
contrib/98_EDIPLUG.pm Wzut Sonstige Systeme

View File

@ -0,0 +1,223 @@
################################################################
#
# Copyright notice
#
# (c) 2010 Sacha Gloor (sacha@imp.ch)
#
# This script is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# The GNU General Public License can be found at
# http://www.gnu.org/copyleft/gpl.html.
# A copy is found in the textfile GPL.txt and important notices to the license
# from the author is found in LICENSE.txt distributed with these scripts.
#
# This script is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# This copyright notice MUST APPEAR in all copies of the script!
#
################################################################
# $Id: 22_ALL3076.pm 2076 2012-11-04 13:49:43Z rudolfkoenig $
##############################################
package main;
use strict;
use warnings;
use Data::Dumper;
use LWP::UserAgent;
use HTTP::Request;
sub
ALL3076_Initialize($)
{
my ($hash) = @_;
$hash->{SetFn} = "ALL3076_Set";
$hash->{DefFn} = "ALL3076_Define";
$hash->{AttrList} = "loglevel:0,1,2,3,4,5,6";
}
###################################
sub
ALL3076_Set($@)
{
my ($hash, @a) = @_;
return "no set value specified" if(int(@a) != 2);
return "Unknown argument $a[1], choose one of on off toggle dimdown dimup dim10% dim20% dim30% dim40% dim50% dim60% dim70% dim80% dim90% dim100%" if($a[1] eq "?");
my $v = $a[1];
my $v2 = "";
my $err_log="";
if(defined $a[2]) { $v2=$a[2]; }
if($v eq "toggle")
{
if(defined $hash->{READINGS}{state}{VAL})
{
if($hash->{READINGS}{state}{VAL} eq "off")
{
$v="on";
}
else
{
$v="off";
}
}
else
{
$v="off";
}
}
Log GetLogLevel($a[0],2), "ALL3076 set @a";
$err_log=ALL3076_execute($hash->{DEF},$v,$v2);
if($err_log ne "")
{
Log GetLogLevel($a[0],2), "ALL3076 ".$err_log;
}
$hash->{CHANGED}[0] = $v.$v2;
$hash->{STATE} = $v.$v2;
$hash->{READINGS}{state}{TIME} = TimeNow();
$hash->{READINGS}{state}{VAL} = $v.$v2;
return undef;
}
###################################
sub
ALL3076_execute($@)
{
my ($target,$cmd,$cmd2) = @_;
my $URL='';
my $log='';
if($cmd eq "on")
{
$URL="http://".$target."/r?r=0&s=1";
}
elsif($cmd eq "off")
{
$URL="http://".$target."/r?r=0&s=0";
}
elsif($cmd eq "dimdown")
{
# We switch it on first
$log.=ALL3076_execute($target,"on");
$URL="http://".$target."/r?d=0";
}
elsif($cmd eq "dimup")
{
# We switch it on first
$log.=ALL3076_execute($target,"on");
$URL="http://".$target."/r?d=1";
}
elsif(substr($cmd,0,3) eq "dim")
{
# We switch it on first
$log.=ALL3076_execute($target,"on");
my $proz=substr($cmd,3,length($cmd)-4);
my $proz_v=sprintf("%d",$proz*255/100);
$URL="http://".$target."/r?d=".$proz_v;
}
elsif($cmd eq "on-old-for-timer")
{
sleep(1); # Todo
}
else
{
return($log);
}
# print "URL: $URL\n";
my $agent = LWP::UserAgent->new(env_proxy => 1,keep_alive => 1, timeout => 30);
my $header = HTTP::Request->new(GET => $URL);
my $request = HTTP::Request->new('GET', $URL, $header);
my $response = $agent->request($request);
$log.= "Can't get $URL -- ".$response->status_line
unless $response->is_success;
return($log);
}
sub
ALL3076_Define($$)
{
my ($hash, $def) = @_;
my @a = split("[ \t][ \t]*", $def);
return "Wrong syntax: use define <name> ALL3076 <ip-address>" if(int(@a) != 3);
return undef;
}
1;
=pod
=begin html
<a name="ALL3076"></a>
<h3>ALL3076</h3>
<ul>
Note: this module needs the HTTP::Request and LWP::UserAgent perl modules.
<br><br>
<a name="ALL3076define"></a>
<b>Define</b>
<ul>
<code>define &lt;name&gt; ALL3076 &lt;ip-address&gt; </code>
<br><br>
Defines an Allnet 3076 device (Dimmable lightswitch) via its ip address or dns name<br><br>
Examples:
<ul>
<code>define lamp1 ALL3076 192.168.1.200</code><br>
</ul>
</ul>
<br>
<a name="ALL3076set"></a>
<b>Set </b>
<ul>
<code>set &lt;name&gt; &lt;value&gt;</code>
<br><br>
where <code>value</code> is one of:<br>
<pre>
dimdown
dim10%
dim20%
dim30%
dim40%
dim50%
dim60%
dim70%
dim80%
dim90%
dim100%
dim[0-100]%
dimup
off
on
toggle
</pre>
Examples:
<ul>
<code>set lamp1 on</code><br>
<code>set lamp1 dim11%</code><br>
<code>set lamp2 toggle</code><br>
</ul>
<br>
Notes:
<ul>
<li>Toggle is special implemented. List name returns "on" or "off" even after a toggle command</li>
</ul>
</ul>
</ul>
=end html
=cut

View File

@ -0,0 +1,206 @@
################################################################
#
# Copyright notice
#
# (c) 2010 Sacha Gloor (sacha@imp.ch)
#
# This script is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# The GNU General Public License can be found at
# http://www.gnu.org/copyleft/gpl.html.
# A copy is found in the textfile GPL.txt and important notices to the license
# from the author is found in LICENSE.txt distributed with these scripts.
#
# This script is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# This copyright notice MUST APPEAR in all copies of the script!
#
################################################################
# $Id: 23_WEBIO.pm 2076 2012-11-04 13:49:43Z rudolfkoenig $
##############################################
package main;
use strict;
use warnings;
use Data::Dumper;
use LWP::UserAgent;
use HTTP::Request;
sub
WEBIO_Initialize($)
{
my ($hash) = @_;
$hash->{SetFn} = "WEBIO_Set";
$hash->{DefFn} = "WEBIO_Define";
$hash->{AttrList} = "loglevel:0,1,2,3,4,5,6";
}
###################################
sub
WEBIO_Set($@)
{
my ($hash, @a) = @_;
return "no set value specified" if(int(@a) != 2);
return "Unknown argument $a[1], choose one of 0 1 2 3 4 5 6 7 8 9 10" if($a[1] eq "?");
my $v = $a[1];
my $sensor="volt";
WEBIO_execute($hash->{DEF},$v);
Log GetLogLevel($a[0],2), "WEBIO set @a";
$hash->{CHANGED}[0] = "Volt:";
$hash->{STATE} = "V: ".$v;
$hash->{READINGS}{$sensor}{TIME} = TimeNow();
$hash->{READINGS}{$sensor}{VAL} = $v." (Volt)";
return undef;
}
###################################
sub
WEBIO_execute($@)
{
my ($target,$cmd) = @_;
my $URL='';
my @a = split("[ \t][ \t]*", $target);
$URL="http://".$a[0]."/outputaccess".$a[1]."?PW=&State=".$cmd."&";
my $agent = LWP::UserAgent->new(env_proxy => 1,keep_alive => 1, timeout => 1);
my $header = HTTP::Request->new(GET => $URL);
my $request = HTTP::Request->new('GET', $URL, $header);
my $response = $agent->request($request);
return undef;
}
sub
WEBIO_Define($$)
{
my ($hash, $def) = @_;
my $name=$hash->{NAME};
my @a = split("[ \t][ \t]*", $def);
my $host = $a[2];
my $host_port = $a[3];
my $delay=$a[4];
$attr{$name}{delay}=$delay if $delay;
return "Wrong syntax: use define <name> WEBIO <ip-address> <port-nr> <poll-delay>" if(int(@a) != 5);
$hash->{Host} = $host;
$hash->{Host_Port} = $host_port;
InternalTimer(gettimeofday()+$delay, "WEBIO_GetStatus", $hash, 0);
return undef;
}
#####################################
sub
WEBIO_GetStatus($)
{
my ($hash) = @_;
my $err_log='';
my $line;
my $name = $hash->{NAME};
my $host = $hash->{Host};
my $delay=$attr{$name}{delay}||300;
InternalTimer(gettimeofday()+$delay, "WEBIO_GetStatus", $hash, 0);
if(!defined($hash->{Host_Port})) { return(""); }
my $host_port = $hash->{Host_Port};
my $URL="http://".$host."/Single".$host_port;
my $agent = LWP::UserAgent->new(env_proxy => 1,keep_alive => 1, timeout => 3);
my $header = HTTP::Request->new(GET => $URL);
my $request = HTTP::Request->new('GET', $URL, $header);
my $response = $agent->request($request);
$err_log.= "Can't get $URL -- ".$response->status_line
unless $response->is_success;
if($err_log ne "")
{
Log GetLogLevel($name,2), "WEBIO ".$err_log;
return("");
}
my $body = $response->content;
# print $body."\n";
my @values=split(/;/,$body);
my $last=$values[$#values];
my @v=split(/ /,$last);
my $state=$v[0];
$state=~s/,/./g;
my $sensor="volt";
Log 4, "WEBIO_GetStatus: $host_port ".$hash->{STATE}." -> ".$state;
$hash->{STATE} = "V: ".$state;
$hash->{CHANGED}[0] = $state;
$hash->{READINGS}{$sensor}{TIME} = TimeNow();
$hash->{READINGS}{$sensor}{VAL} = $state." (Volt)";
DoTrigger($name, undef) if($init_done);
}
1;
=pod
=begin html
<a name="WEBIO"></a>
<h3>WEBIO</h3>
<ul>
Note: this module needs the HTTP::Request and LWP::UserAgent perl modules.
<br><br>
<a name="WEBIOdefine"></a>
<b>Define</b>
<ul>
<code>define &lt;name&gt; WEBIO &lt;ip-address&gt; &lt;port&gt; &lt;delay&gt;</code>
<br><br>
Defines an Web-IO device (Box with 2 Analog-In/Out 0..10V, www.wut.de) via ip address. The status of the device is also pooled (delay interval).<br><br>
Examples:
<ul>
<code>define pumpspeed WEBIO 192.168.8.200 1 60</code><br>
</ul>
</ul>
<br>
<a name="WEBIOset"></a>
<b>Set </b>
<ul>
<code>set &lt;name&gt; &lt;value&gt;</code>
<br><br>
where <code>value</code> is one of:<br>
<pre>
0.00 - 10.00
</pre>
Examples:
<ul>
<code>set pumpspeed 6.75</code><br>
</ul>
<br>
</ul>
</ul>
=end html
=cut

View File

@ -0,0 +1,242 @@
################################################################
#
# Copyright notice
#
# (c) 2011 Sacha Gloor (sacha@imp.ch)
#
# This script is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# The GNU General Public License can be found at
# http://www.gnu.org/copyleft/gpl.html.
# A copy is found in the textfile GPL.txt and important notices to the license
# from the author is found in LICENSE.txt distributed with these scripts.
#
# This script is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# This copyright notice MUST APPEAR in all copies of the script!
#
################################################################
# $Id: 23_WEBIO_12DIGITAL.pm 2076 2012-11-04 13:49:43Z rudolfkoenig $
##############################################
package main;
use strict;
use warnings;
use Data::Dumper;
use IO::Socket;
#use LWP::UserAgent;
#use HTTP::Request;
sub
WEBIO_12DIGITAL_Initialize($)
{
my ($hash) = @_;
$hash->{SetFn} = "WEBIO_12DIGITAL_Set";
$hash->{DefFn} = "WEBIO_12DIGITAL_Define";
$hash->{AttrList} = "loglevel:0,1,2,3,4,5,6";
}
###################################
sub
WEBIO_12DIGITAL_Set($@)
{
my ($hash, @a) = @_;
return "no set value specified" if(int(@a) < 2);
return "Unknown argument $a[1], choose one of on off on-for-timer" if($a[1] eq "?");
my $v = $a[1];
my $v2= "";
if(defined($a[2])) { $v2=$a[2]; }
RemoveInternalTimer("WEBIO_12DIGITAL_on_timeout");
if($v eq "on-for-timer")
{
InternalTimer(gettimeofday()+$v2, "WEBIO_12DIGITAL_on_timeout",$hash, 0);
# on-for-timer is now a on.
$v="on";
}
WEBIO_12DIGITAL_execute($hash->{DEF},$v);
Log GetLogLevel($a[0],2), "WEBIO_12DIGITAL set @a";
$hash->{CHANGED}[0] = $v;
$hash->{STATE} = $v;
$hash->{READINGS}{state}{TIME} = TimeNow();
$hash->{READINGS}{state}{VAL} = $v;
DoTrigger($hash->{NAME}, undef);
return undef;
}
sub
WEBIO_12DIGITAL_on_timeout($)
{
my ($hash) = @_;
my @a;
$a[0]=$hash->{NAME};
$a[1]="off";
WEBIO_12DIGITAL_Set($hash,@a);
return undef;
}
###################################
sub
WEBIO_12DIGITAL_execute($@)
{
my ($target,$cmd) = @_;
my $URL='';
my $v='';
my $err_log='';
if($cmd eq "on") { $v="ON"; }
else { $v="OFF"; }
my @a = split("[ \t][ \t]*", $target);
my $sock = new IO::Socket::INET (
PeerAddr => $a[0],
PeerPort => '80',
Proto => 'tcp',
Timeout => "3",
);
$err_log = "Could not create socket: $!\n" unless $sock;
if($err_log ne "") { return undef; }
print $sock "GET /outputaccess".$a[1]."?PW=&State=".$v."\n";
close($sock);
return undef;
}
sub
WEBIO_12DIGITAL_Define($$)
{
my ($hash, $def) = @_;
my $name=$hash->{NAME};
my @a = split("[ \t][ \t]*", $def);
my $host = $a[2];
my $host_port = $a[3];
my $delay=$a[4];
$attr{$name}{delay}=$delay if $delay;
return "Wrong syntax: use define <name> WEBIO_12DIGITAL <ip-address> <port-nr> <poll-delay>" if(int(@a) != 5);
$hash->{Host} = $host;
$hash->{Host_Port} = $host_port;
InternalTimer(gettimeofday()+$delay, "WEBIO_12DIGITAL_GetStatus", $hash, 0);
return undef;
}
#####################################
sub
WEBIO_12DIGITAL_GetStatus($)
{
my ($hash) = @_;
my $err_log='';
my $line;
my $state;
my $name = $hash->{NAME};
my $host = $hash->{Host};
my $delay=$attr{$name}{delay}||300;
InternalTimer(gettimeofday()+$delay, "WEBIO_12DIGITAL_GetStatus", $hash, 0);
if(!defined($hash->{Host_Port})) { return(""); }
my $host_port = $hash->{Host_Port};
my $sock = new IO::Socket::INET (
PeerAddr => $host,
PeerPort => '80',
Proto => 'tcp',
Timeout => "3",
);
$err_log = "Could not create socket: $!\n" unless $sock;
if($err_log ne "")
{
Log GetLogLevel($name,2), "WEBIO_12DIGITAL ".$err_log;
return("");
}
print $sock "GET /output".$host_port."?PW=&\n";
$line = <$sock>;
close($sock);
if($line =~ /ON/) { $state="on"; } else { $state="off"; }
if($hash->{STATE} ne $state)
{
Log 4, "WEBIO_12DIGITAL_GetStatus: $host_port ".$hash->{STATE}." -> ".$state;
$hash->{STATE} = $state;
$hash->{CHANGED}[0] = $state;
$hash->{READINGS}{state}{TIME} = TimeNow();
$hash->{READINGS}{state}{VAL} = $state;
DoTrigger($name, undef) if($init_done);
}
}
1;
=pod
=begin html
<a name="WEBIO_12DIGITAL"></a>
<h3>WEBIO_12DIGITAL</h3>
<ul>
Note: this module needs the HTTP::Request and LWP::UserAgent perl modules.
<br><br>
<a name="WEBIO_12DIGITALdefine"></a>
<b>Define</b>
<ul>
<code>define &lt;name&gt; WEBIO_12DIGITAL &lt;ip-address&gt; &lt;outputport&gt; &lt;delay&gt;</code>
<br><br>
Defines an Web-IO-Digital device (Box with up to 12 digital in/outputs, www.wut.de) via ip address. The status of the device is also pooled (delay interval).<br><br>
Examples:
<ul>
<code>define motor1 WEBIO_12DIGITAL 192.168.8.200 1 60</code><br>
</ul>
</ul>
<br>
<a name="WEBIO_12DIGITALset"></a>
<b>Set </b>
<ul>
<code>set &lt;name&gt; &lt;value&gt;</code>
<br><br>
where <code>value</code> is one of:<br>
<pre>
on off
</pre>
Examples:
<ul>
<code>set motor1 on</code><br>
</ul>
<br>
</ul>
</ul>
=end html
=cut

View File

@ -0,0 +1,179 @@
# $Id: 23_WEBTHERM.pm 4793 2014-02-02 11:20:16Z betateilchen $
################################################################
#
# This module will connect a webbased thermometer
# to your fhem installation.
#
# Further informations about required hardware:
# http://www.wut.de/e-57w0w-ww-dade-000.php
#
# (c) 2010 Sacha Gloor (sacha@imp.ch)
#
# corrections & documentation added for fhem
# 2013-07-30 by betateilchen ®
#
# This file is part of fhem.
#
# Fhem is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.
#
# Fhem is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with fhem. If not, see <http://www.gnu.org/licenses/>.
#
################################################################
package main;
use strict;
use warnings;
use Data::Dumper;
use LWP::UserAgent;
use HTTP::Request;
sub
WEBTHERM_Initialize($)
{
my ($hash) = @_;
$hash->{DefFn} = "WEBTHERM_Define";
$hash->{AttrList} = "loglevel:0,1,2,3,4,5,6";
}
sub
WEBTHERM_Define($$)
{
my ($hash, $def) = @_;
my $name=$hash->{NAME};
my @a = split("[ \t][ \t]*", $def);
my $host = $a[2];
my $host_port = $a[3];
my $interval=$a[4];
$attr{$name}{interval}=$interval if $interval;
return "Usage: define <name> WEBTHERM <ip-address> <port-nr> <poll-interval>" if(int(@a) != 5);
$hash->{Host} = $host;
$hash->{Host_Port} = $host_port;
InternalTimer(gettimeofday()+$interval, "WEBTHERM_GetStatus", $hash, 0);
return;
}
sub
WEBTHERM_GetStatus($)
{
my ($hash) = @_;
my $err_log='';
my $line;
my $name = $hash->{NAME};
my $host = $hash->{Host};
my $interval=$attr{$name}{interval}||300;
InternalTimer(gettimeofday()+$interval, "WEBTHERM_GetStatus", $hash, 0);
if(!defined($hash->{Host_Port})) { return(""); }
my $host_port = $hash->{Host_Port};
### 2013-07-30 corrected by betateilchen
# my $URL="http://".$host."/Single".$host_port;
my $URL="http://".$host.":".$host_port."/Single";
### end-of-correction
my $agent = LWP::UserAgent->new(env_proxy => 1,keep_alive => 1, timeout => 3);
my $header = HTTP::Request->new(GET => $URL);
my $request = HTTP::Request->new('GET', $URL, $header);
my $response = $agent->request($request);
$err_log.= "Can't get $URL -- ".$response->status_line
unless $response->is_success;
if($err_log ne "")
{
Log GetLogLevel($name,2), "WEBTHERM $name ".$err_log;
return;
}
my $body = $response->content;
my $text='';
my @values=split(/;/,$body);
my $last=$values[$#values];
my $state=$last;
$state=~s/,/./g;
$state=substr($state,0,-2);
my $sensor="temperature";
Log 4, "WEBTHERM_GetStatus: $name $host_port ".$hash->{STATE}." -> ".$state;
$text="Temperature: ".$state;
$hash->{STATE} = "T: ".$state;
$hash->{CHANGED}[0] = $text;
readingsSingleUpdate($name, $sensor, $state, 1);
return;
}
1;
=pod
not to be translated
=begin html
<a name="WEBTHERM"></a>
<h3>WEBTHERM</h3>
<ul>
This module connects a <a href="http://www.wut.de/e-57w0w-ww-dade-000.php">Web-Thermometer made by W&T</a> to your FHEM installation.<br/>
Currently this module is no longer maintained, but it should work in its current state.<br/>
It is provided "as is" for backward compatibility.<br/>
<br />
<a name="WEBTHERM_Define"></a>
<b>Define</b>
<ul><br/>
<code>define &lt;name&gt; WEBTHERM &lt;ip-address&gt; &lt;port-nr&gt; &lt;interval&gt;</code><br/>
<br/>
Defines a WEBTHERM device at given ip and port.</br>
Values are polled periodically defined by given interval (in seconds).<br/>
Read temperature is written into reading "state".<br/>
</ul>
<br/><br />
<a name="WEBTHERM_Set"></a>
<b>Set</b>
<ul>
N/A
</ul>
<br/><br />
<a name="WEBTHERM_Get"></a>
<b>Get</b>
<ul>
N/A
</ul>
<br/><br />
<a name="WEBTHERM_Attr"></a>
<b>Attr</b>
<ul>
N/A
</ul>
</ul>
=end html
=begin html_DE
<a name="WEBTHERM"></a>
<h3>WEBTHERM</h3>
<ul>
Sorry, keine deutsche Dokumentation vorhanden.<br/><br/>
Die englische Doku gibt es hier: <a href='http://fhem.de/commandref.html#WEBTHERM'>WEBTHERM</a><br/>
</ul>
=end html_DE
=cut

View File

@ -0,0 +1,167 @@
################################################################
#
# Copyright notice
#
# (c) 2010 Sacha Gloor (sacha@imp.ch)
#
# This script is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# The GNU General Public License can be found at
# http://www.gnu.org/copyleft/gpl.html.
# A copy is found in the textfile GPL.txt and important notices to the license
# from the author is found in LICENSE.txt distributed with these scripts.
#
# This script is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# This copyright notice MUST APPEAR in all copies of the script!
#
################################################################
# $Id: 88_ALL4000T.pm 2076 2012-11-04 13:49:43Z rudolfkoenig $
package main;
use strict;
use warnings;
use XML::Simple;
use Data::Dumper;
use LWP::UserAgent;
use HTTP::Request;
sub Log($$);
#####################################
sub
trim($)
{
my $string = shift;
$string =~ s/^\s+//;
$string =~ s/\s+$//;
return $string;
}
sub
ALL4000T_Initialize($)
{
my ($hash) = @_;
# Consumer
$hash->{DefFn} = "ALL4000T_Define";
$hash->{AttrList}= "model:ALL4000T delay loglevel:0,1,2,3,4,5,6";
}
#####################################
sub
ALL4000T_Define($$)
{
my ($hash, $def) = @_;
my $name=$hash->{NAME};
my @a = split("[ \t][ \t]*", $def);
Log 5, "ALL4000T Define: $a[0] $a[1] $a[2] $a[3] $a[4]";
return "Define the host as a parameter i.e. ALL4000T" if(@a < 4);
my $host = $a[2];
my $host_port = $a[3];
my $delay=$a[4];
$attr{$name}{delay}=$delay if $delay;
Log 1, "ALL4000T device is none, commands will be echoed only" if($host eq "none");
$hash->{Host} = $host;
$hash->{Host_Port} = $host_port;
$hash->{STATE} = "Initialized";
Log 4,"$name: Delay $delay";
InternalTimer(gettimeofday()+$delay, "ALL4000T_GetStatus", $hash, 0);
return undef;
}
#####################################
sub
ALL4000T_GetStatus($)
{
my ($hash) = @_;
my $buf;
if(!defined($hash->{Host_Port})) { return(""); }
Log 5, "ALL4000T_GetStatus";
my $name = $hash->{NAME};
my $host = $hash->{Host};
my $host_port = $hash->{Host_Port};
my $text='';
my $err_log='';
my $delay=$attr{$name}{delay}||300;
InternalTimer(gettimeofday()+$delay, "ALL4000T_GetStatus", $hash, 0);
my $xml = new XML::Simple;
my $URL="http://".$host."/xml";
my $agent = LWP::UserAgent->new(env_proxy => 1,keep_alive => 1, timeout => 3);
my $header = HTTP::Request->new(GET => $URL);
my $request = HTTP::Request->new('GET', $URL, $header);
my $response = $agent->request($request);
$err_log.= "Can't get $URL -- ".$response->status_line
unless $response->is_success;
if($err_log ne "")
{
Log GetLogLevel($name,2), "ALL4000T ".$err_log;
return("");
}
my $body = $response->content;
my $data = $xml->XMLin($body);
my $current=trim($data->{BODY}->{FORM}->{TEXTAREA}->{xml}->{data}->{$host_port});
$text="Temperature: ".$current;
my $sensor="temperature";
Log 4,"$name: $text";
if (!$hash->{local}){
$hash->{CHANGED}[0] = $text;
$hash->{READINGS}{$sensor}{TIME} = TimeNow();
$hash->{READINGS}{$sensor}{VAL} = $current." (Celsius)";;
DoTrigger($name, undef) if($init_done);
}
$hash->{STATE} = "T: ".$current;
return($text);
}
1;
=pod
=begin html
<a name="ALL4000T"></a>
<h3>ALL4000T</h3>
<ul>
Note: this module requires the following perl modules: XML::Simple LWP::UserAgent
HTTP::Request.
<br><br>
<a name="ALL4000Tdefine"></a>
<b>Define</b>
<ul>
<code>define &lt;name&gt; ALL4000T &lt;ip-address&gt; &lt;port&gt; &lt;delay&gt;</code>
<br><br>
Defines a temperature sensor connected on an Allnet 4000 device via its ip address and port. Use the delay argument to define the delay between polls.<br><br>
Examples:
<ul>
<code>define AUSSEN.POOL.TEMP.vorlauf ALL4000T 192.168.68.20 t2 120</code><br>
</ul>
</ul>
<br>
</ul>
=end html
=cut

View File

@ -0,0 +1,186 @@
################################################################
#
# Copyright notice
#
# (c) 2011 Sacha Gloor (sacha@imp.ch)
#
# This script is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# The GNU General Public License can be found at
# http://www.gnu.org/copyleft/gpl.html.
# A copy is found in the textfile GPL.txt and important notices to the license
# from the author is found in LICENSE.txt distributed with these scripts.
#
# This script is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# This copyright notice MUST APPEAR in all copies of the script!
#
################################################################
# $Id: 88_Itach_Relay.pm 2078 2012-11-04 14:31:59Z rudolfkoenig $
##############################################
package main;
use strict;
use warnings;
use Data::Dumper;
use Net::Telnet;
sub
ITACH_RELAY_Initialize($)
{
my ($hash) = @_;
$hash->{SetFn} = "ITACH_RELAY_Set";
$hash->{DefFn} = "ITACH_RELAY_Define";
$hash->{AttrList} = "loglevel:0,1,2,3,4,5,6";
}
###################################
sub
ITACH_RELAY_Set($@)
{
my ($hash, @a) = @_;
return "no set value specified" if(int(@a) != 2);
return "Unknown argument $a[1], choose one of on off toggle" if($a[1] eq "?");
my $v = $a[1];
if($v eq "toggle")
{
if(defined $hash->{READINGS}{state}{VAL})
{
if($hash->{READINGS}{state}{VAL} eq "off")
{
$v="on";
}
else
{
$v="off";
}
}
else
{
$v="off";
}
}
ITACH_RELAY_execute($hash->{DEF},$v);
Log GetLogLevel($a[0],2), "ITACH_RELAY set @a";
$hash->{CHANGED}[0] = $v;
$hash->{STATE} = $v;
$hash->{READINGS}{state}{TIME} = TimeNow();
$hash->{READINGS}{state}{VAL} = $v;
DoTrigger($hash->{NAME}, undef);
return undef;
}
###################################
sub
ITACH_RELAY_execute($@)
{
my ($target,$cmd) = @_;
my $URL='';
my $v='';
my $err_log='';
if($cmd eq "on") { $v=1; }
else { $v=0; }
my @a = split("[ \t][ \t]*", $target);
my $tel=new Net::Telnet(Host => $a[0], Port => 4998,Timeout => 3, Binmode => 0, Telnetmode => 0, Errmode => "return");
if(!defined($tel))
{
Log 4,"Error connecting to ".$a[0].":4998";
}
else
{
my $cmd="setstate,1:".$a[1].",".$v."\n";
$tel->print($cmd);
sleep(1);
}
return undef;
}
sub
ITACH_RELAY_Define($$)
{
my ($hash, $def) = @_;
my $name=$hash->{NAME};
my @a = split("[ \t][ \t]*", $def);
my $host = $a[2];
my $host_port = $a[3];
return "Wrong syntax: use define <name> ITACH_RELAY <ip-address> <port-nr>" if(int(@a) != 4);
$hash->{Host} = $host;
$hash->{Host_Port} = $host_port;
return undef;
}
1;
=pod
=begin html
<a name="Itach_Relay"></a>
<h3>ITACH_RELAY</h3>
<ul>
Note: this module needs the Net::Telnet module.
<br><br>
<a name="ITACH_RELAYdefine"></a>
<b>Define</b>
<ul>
<code>define &lt;name&gt; ITACH_RELAY &lt;ip-address&gt; &lt;port&gt;</code>
<br><br>
Defines an Global Cache iTach Relay device (Box with 3 relays) via its ip address. <br><br>
Examples:
<ul>
<code>define motor1 ITACH_RELAY 192.168.8.200 1</code><br>
</ul>
</ul>
<br>
<a name="ITACH_RELAYset"></a>
<b>Set </b>
<ul>
<code>set &lt;name&gt; &lt;value&gt;</code>
<br><br>
where <code>value</code> is one of:<br>
<pre>
off
on
toggle
</pre>
Examples:
<ul>
<code>set motor1 on</code><br>
</ul>
<br>
Notes:
<ul>
<li>Toggle is special implemented. List name returns "on" or "off" even after a toggle command</li>
</ul>
</ul>
</ul>
=end html
=cut

View File

@ -0,0 +1,153 @@
################################################################
#
# Copyright notice
#
# (c) 2013 Sacha Gloor (sacha@imp.ch)
#
# This script is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# The GNU General Public License can be found at
# http://www.gnu.org/copyleft/gpl.html.
# A copy is found in the textfile GPL.txt and important notices to the license
# from the author is found in LICENSE.txt distributed with these scripts.
#
# This script is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# This copyright notice MUST APPEAR in all copies of the script!
#
################################################################
# $Id: 88_LINDY_HDMI_SWITCH.pm 19716 2019-06-26 17:04:05Z jeschkec $
##############################################
package main;
use strict;
use warnings;
use Data::Dumper;
use Net::Telnet;
sub
LINDY_HDMI_SWITCH_Initialize($)
{
my ($hash) = @_;
$hash->{SetFn} = "LINDY_HDMI_SWITCH_Set";
$hash->{DefFn} = "LINDY_HDMI_SWITCH_Define";
$hash->{AttrList} = "loglevel:0,1,2,3,4,5,6";
}
###################################
sub
LINDY_HDMI_SWITCH_Set($@)
{
my ($hash, @a) = @_;
return "no set value specified" if(int(@a) != 2);
return "Unknown argument $a[1], choose one of 11 12 13 14 21 22 23 24" if($a[1] eq "?");
my $v = $a[1];
my $tel=new Net::Telnet(Host => $hash->{Host}, Port => $hash->{Host_Port},Timeout => 3, Binmode => 0, Telnetmode => 0, Errmode => "return");
if(!defined($tel))
{
Log 4,"Error connecting to ".$a[0].":4999";
}
else
{
my $cmd="PORT ".$v."\n";
$tel->print($cmd);
sleep(1);
}
Log GetLogLevel($a[0],2), "LINDY_HDMI_SWITCH set @a";
$hash->{CHANGED}[0] = $v;
$hash->{STATE} = $v;
$hash->{READINGS}{state}{TIME} = TimeNow();
$hash->{READINGS}{state}{VAL} = $v;
DoTrigger($hash->{NAME}, undef);
return undef;
}
sub
LINDY_HDMI_SWITCH_Define($$)
{
my ($hash, $def) = @_;
my $name=$hash->{NAME};
my @a = split("[ \t][ \t]*", $def);
my $host = $a[2];
my $host_port = $a[3];
return "Wrong syntax: use define <name> LINDY_HDMI_SWITCH <ip-address> <port-nr>" if(int(@a) != 4);
$hash->{Host} = $host;
$hash->{Host_Port} = $host_port;
return undef;
}
1;
=pod
=item device
=item summary Controls LINDY HDMI 38054 4:2 switch
=item summary_DE Steuert LINDY HDMI 38054 4:2 Umschalter
=begin html
<a name="LINDY_HDMI_SWITCH"></a>
<h3>LINDY_HDMI_SWITCH</h3>
<ul>
Note: this module needs the Net::Telnet module.
<br><br>
<a name="LINDY_HDMI_SWITCHdefine"></a>
<b>Define</b>
<ul>
<code>define &lt;name&gt; LINDY_HDMI_SWITCH &lt;ip-address&gt; &lt;port&gt;</code>
<br><br>
Defines an Lindy 4:2 HDMI Switch serial connected to a transparent ethernet to serial adapter via the ip address of the adapter. Lindy partnumber: 38054 <br><br>
Examples:
<ul>
<code>define livingroom.hdmi LINDY_HDMI_SWITCH 192.168.1.64 4999</code><br>
</ul>
</ul>
<br>
<a name="LINDY_HDMI_SWITCHset"></a>
<b>Set </b>
<ul>
<code>set &lt;name&gt; &lt;value&gt;</code>
<br><br>
where <code>value</code> is one of:<br>
<pre>
11
12
13
14
21
22
23
24
</pre>
First digit is the output port, second digit is the input port.
Example:
<ul>
<code>set livingroom.hdmi 12</code><br>
</ul>
<br>
</ul>
</ul>
=end html
=cut

View File

@ -0,0 +1,393 @@
################################################################
#
# Copyright notice
#
# (c) 2010 Sacha Gloor (sacha@imp.ch)
#
# This script is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# The GNU General Public License can be found at
# http://www.gnu.org/copyleft/gpl.html.
# A copy is found in the textfile GPL.txt and important notices to the license
# from the author is found in LICENSE.txt distributed with these scripts.
#
# This script is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# This copyright notice MUST APPEAR in all copies of the script!
#
################################################################
# $Id: 88_VantagePro2.pm 2076 2012-11-04 13:49:43Z rudolfkoenig $
package main;
use strict;
use warnings;
use Data::Dumper;
use Net::Telnet;
sub Log($$);
#####################################
sub
VantagePro2_Initialize($)
{
my ($hash) = @_;
# Consumer
$hash->{DefFn} = "VantagePro2_Define";
$hash->{AttrList}= "model:VantagePro2 delay loglevel:0,1,2,3,4,5,6";
}
#####################################
sub
VantagePro2_Define($$)
{
my ($hash, $def) = @_;
my $name=$hash->{NAME};
my @a = split("[ \t][ \t]*", $def);
Log 5, "VantagePro2 Define: $a[0] $a[1] $a[2] $a[3]";
return "Define the host as a parameter i.e. VantagePro2" if(@a < 3);
my $host = $a[2];
my $port=$a[3];
my $delay=$a[4];
$attr{$name}{delay}=$delay if $delay;
Log 1, "VantagePro2 device is none, commands will be echoed only" if($host eq "none");
$hash->{Host} = $host;
$hash->{Port} = $port;
$hash->{STATE} = "Initialized";
InternalTimer(gettimeofday()+$delay, "VantagePro2_GetStatus", $hash, 0);
return undef;
}
#####################################
sub
VantagePro2_GetStatus($)
{
my ($hash) = @_;
my $buf;
Log 5, "VantagePro2_GetStatus";
my $name = $hash->{NAME};
my $host = $hash->{Host};
my $port = $hash->{Port};
my $text='';
my $err_log='';
my $answer;
my $sensor;
my $delay=$attr{$name}{delay}||300;
InternalTimer(gettimeofday()+$delay, "VantagePro2_GetStatus", $hash, 0);
my $tel=new Net::Telnet(Host => $host, Port => $port,Timeout => 3, Binmode => 1, Telnetmode => 0, Errmode => "return");
if(!defined($tel))
{
Log 4,"$name: Error connecting to $host:$port";
}
else
{
$tel->print("");
$answer=$tel->get();
$tel->print("TEST");
$answer=$tel->get();
$tel->print("LOOP 1");
sleep(1);
$answer=$tel->get();
$tel->close();
# print "Debug:".length($answer)."\n";
if(length($answer)>=63)
{
my $offset=1;
my $t;
my $btrend="";
$t=substr($answer,$offset+3,1);
my ($bartrend)=unpack("c1",$t);
$t=substr($answer,$offset+7,2);
my ($barometer)=unpack("s2",$t);
$barometer=sprintf("%.02f",$barometer/1000*2.54);
$t=substr($answer,$offset+9,2);
my ($itemp)=unpack("s2",$t);
$t=substr($answer,$offset+11,1);
my ($ihum)=unpack("c1",$t);
$t=substr($answer,$offset+12,2);
my ($otemp)=unpack("s2",$t);
$t=substr($answer,$offset+33,1);
my ($ohum)=unpack("c1",$t);
$t=substr($answer,$offset+14,1);
my ($windspeed)=unpack("c1",$t);
$t=substr($answer,$offset+15,1);
my ($avgwindspeed)=unpack("c1",$t);
$t=substr($answer,$offset+16,2);
my ($winddir)=unpack("s1",$t);
$t=substr($answer,$offset+41,2);
my ($rainrate)=unpack("s2",$t);
$t=substr($answer,$offset+43,1);
my ($uv)=unpack("c1",$t);
$t=substr($answer,$offset+44,2);
my ($solar)=unpack("s2",$t);
$t=substr($answer,$offset+46,2);
my ($stormrain)=unpack("s2",$t);
$stormrain=sprintf("%.02f",($stormrain/100*25.4));
$t=substr($answer,$offset+50,2);
my ($drain)=unpack("s2",$t);
$drain=sprintf("%.02f",($drain*0.2)); #Es werden Anzahl ticks à 0.2mm übermittelt
$t=substr($answer,$offset+52,2);
my ($mrain)=unpack("s2",$t);
$mrain=sprintf("%.02f",($mrain*0.2)); #Es werden Anzahl ticks à 0.2mm übermittelt
$t=substr($answer,$offset+54,2);
my ($yrain)=unpack("s2",$t);
$yrain=sprintf("%.02f",($yrain*0.2)); # #Es werden Anzahl ticks à 0.2mm übermittelt
$t=substr($answer,$offset+56,2);
my ($etday)=unpack("s2",$t);
$etday=sprintf("%.02f",($etday/1000*25.4));
$t=substr($answer,$offset+58,2);
my ($etmonth)=unpack("s2",$t);
$etmonth=sprintf("%.02f",($etmonth/100*25.4));
$t=substr($answer,$offset+60,2);
my ($etyear)=unpack("s2",$t);
$etyear=sprintf("%.02f",($etyear/100*25.4));
$itemp=sprintf("%.02f",(($itemp/10)-32)*5/9);
$otemp=sprintf("%.02f",(($otemp/10)-32)*5/9);
$rainrate=sprintf("%.02f",$rainrate/5);
$windspeed=sprintf("%.02f",$windspeed*1.609);
$avgwindspeed=sprintf("%.02f",$avgwindspeed*1.609);
$uv=$uv/10;
if($bartrend==0) { $btrend="Steady"; }
elsif($bartrend==20) { $btrend="Rising Slowly"; }
elsif($bartrend==60) { $btrend="Rising Rapidly"; }
elsif($bartrend==-20) { $btrend="Falling Slowly"; }
elsif($bartrend==-60) { $btrend="Falling Rapidly"; }
# WindChill and HeatIndex by Andreas Berweger
my $wct; #WindChill temperature
my $hit; #HeatIndex temperature
if($otemp<10 && $avgwindspeed>5)
{
$wct=sprintf("%.02f",(13.12+(0.6215*$otemp)-(11.37*$avgwindspeed**0.16)+(0.3965*$otemp*$avgwindspeed**0.16)));
}
else
{
$wct=$otemp;
}
if($otemp>25 && $ohum>40)
{
$hit=sprintf("%.02f",(-8.784695 + (1.61139411*$otemp) + (2.338549*$ohum) + (-0.14611605*$otemp*$ohum) + (-1.2308094*10**-2*$otemp**2) + (-1.6424828*10**-2*$ohum**2) + (2.211732*10**-3*$otemp**2*$ohum) + (7.2546*10**-4*$otemp*$ohum**2) + (-3.582*10**-6*$otemp**2*$ohum**2)));
}
else
{
$hit=$otemp;
}
$text="T-OUT: ".$otemp." T-WC-OUT: ".$wct." T-HI-OUT: ".$hit." T-IN: ".$itemp." H-OUT: ".$ohum." H-IN: ".$ihum." W: ".$windspeed." W-AV: ".$avgwindspeed." WD: ".$winddir." R: ".$rainrate." S: ".$solar." UV: ".$uv." RD: ".$drain." RM: ".$mrain. " RY: ".$yrain." SR: ".$stormrain." BM: ".$barometer." BT: ".$btrend. " ET-DAY: ".$etday." ET-MONTH: ".$etmonth." ET-YEAR: ".$etyear;
my $n=0;
Log 4,"$name: $text";
if (!$hash->{local}){
$sensor="temperature-outside";
$hash->{CHANGED}[$n++] = "Temperature Outside: ".$otemp;
$hash->{READINGS}{$sensor}{TIME} = TimeNow();
$hash->{READINGS}{$sensor}{VAL} = $otemp." (Celsius)";;
$sensor="temperature-windchill";
$hash->{CHANGED}[$n++] = "WCT: ".$wct;
$hash->{READINGS}{$sensor}{TIME} = TimeNow();
$hash->{READINGS}{$sensor}{VAL} = $wct." (Celsius)";;
$sensor="temperature-heatindex";
$hash->{CHANGED}[$n++] = "HeatT: ".$hit;
$hash->{READINGS}{$sensor}{TIME} = TimeNow();
$hash->{READINGS}{$sensor}{VAL} = $hit." (Celsius)";;
$sensor="temperature-inside";
$hash->{CHANGED}[$n++] = "Temperature Inside: ".$itemp;
$hash->{READINGS}{$sensor}{TIME} = TimeNow();
$hash->{READINGS}{$sensor}{VAL} = $itemp." (Celsius)";;
$sensor="humidity outside";
$hash->{CHANGED}[$n++] = "Humidity Outside: ".$ohum;
$hash->{READINGS}{$sensor}{TIME} = TimeNow();
$hash->{READINGS}{$sensor}{VAL} = $ohum." (%)";;
$sensor="humidity inside";
$hash->{CHANGED}[$n++] = "Humidity Inside: ".$ihum;
$hash->{READINGS}{$sensor}{TIME} = TimeNow();
$hash->{READINGS}{$sensor}{VAL} = $ihum." (%)";;
$sensor="windspeed";
$hash->{CHANGED}[$n++] = "Wind: ".$windspeed;
$hash->{READINGS}{$sensor}{TIME} = TimeNow();
$hash->{READINGS}{$sensor}{VAL} = $windspeed." (km/h)";;
$sensor="10 min. average windspeed";
$hash->{CHANGED}[$n++] = "10 Min. Wind: ".$avgwindspeed;
$hash->{READINGS}{$sensor}{TIME} = TimeNow();
$hash->{READINGS}{$sensor}{VAL} = $avgwindspeed." (km/h)";;
$sensor="wind direction";
$hash->{CHANGED}[$n++] = "Wind Direction: ".$winddir;
$hash->{READINGS}{$sensor}{TIME} = TimeNow();
$hash->{READINGS}{$sensor}{VAL} = $winddir." (Degrees)";;
$sensor="solar";
$hash->{CHANGED}[$n++] = "Solar: ".$solar;
$hash->{READINGS}{$sensor}{TIME} = TimeNow();
$hash->{READINGS}{$sensor}{VAL} = $solar." (Watt/m^2)";;
$sensor="UV";
$hash->{CHANGED}[$n++] = "UV: ".$uv;
$hash->{READINGS}{$sensor}{TIME} = TimeNow();
$hash->{READINGS}{$sensor}{VAL} = $uv." (UV/Index)";;
$sensor="rainrate";
$hash->{CHANGED}[$n++] = "Rainrate: ".$rainrate;
$hash->{READINGS}{$sensor}{TIME} = TimeNow();
$hash->{READINGS}{$sensor}{VAL} = $rainrate." (mm/h)";;
$sensor="day rain";
$hash->{CHANGED}[$n++] = "Dayrain: ".$drain;
$hash->{READINGS}{$sensor}{TIME} = TimeNow();
$hash->{READINGS}{$sensor}{VAL} = $drain." (mm/day)";;
$sensor="month rain";
$hash->{CHANGED}[$n++] = "Monthrain: ".$mrain;
$hash->{READINGS}{$sensor}{TIME} = TimeNow();
$hash->{READINGS}{$sensor}{VAL} = $mrain." (mm/month)";;
$sensor="year rain";
$hash->{CHANGED}[$n++] = "Yearrain: ".$yrain;
$hash->{READINGS}{$sensor}{TIME} = TimeNow();
$hash->{READINGS}{$sensor}{VAL} = $yrain." (mm/year)";;
$sensor="storm rain";
$hash->{CHANGED}[$n++] = "SR: ".$stormrain;
$hash->{READINGS}{$sensor}{TIME} = TimeNow();
$hash->{READINGS}{$sensor}{VAL} = $stormrain." (mm/storm)";;
$sensor="barometer";
$hash->{CHANGED}[$n++] = "Barometer: ".$barometer;
$hash->{READINGS}{$sensor}{TIME} = TimeNow();
$hash->{READINGS}{$sensor}{VAL} = $barometer." (Millimeters)";;
$sensor="barometer trend";
$hash->{CHANGED}[$n++] = "Barometer Trend: ".$btrend;
$hash->{READINGS}{$sensor}{TIME} = TimeNow();
$hash->{READINGS}{$sensor}{VAL} = $btrend;
$sensor="ET Day";
$hash->{CHANGED}[$n++] = "ETD: ".$etday;
$hash->{READINGS}{$sensor}{TIME} = TimeNow();
$hash->{READINGS}{$sensor}{VAL} = $etday." (mm/day)";;
$sensor="ET Month";
$hash->{CHANGED}[$n++] = "ETM: ".$etmonth;
$hash->{READINGS}{$sensor}{TIME} = TimeNow();
$hash->{READINGS}{$sensor}{VAL} = $etmonth." (mm/month)";;
$sensor="ET Year";
$hash->{CHANGED}[$n++] = "ETY: ".$etyear;
$hash->{READINGS}{$sensor}{TIME} = TimeNow();
$hash->{READINGS}{$sensor}{VAL} = $etyear." (mm/year)";;
DoTrigger($name, undef) if($init_done);
}
$hash->{STATE} = $text;
}
}
return($text);
}
1;
=pod
=begin html
<a name="VantagePro2"></a>
<h3>VantagePro2</h3>
<ul>
Note: this module needs the Net::Telnet perl module.
<br><br>
<a name="VantagePro2define"></a>
<b>Define</b>
<ul>
<code>define &lt;name&gt; &lt;ip-address&gt; &lt;port&gt; &lt;delay&gt;</code>
<br><br>
Defines a Davis VantagePro2 weatherstation attached on transparent ethernet/usb|serial server accessable by telnet.<br><br>
Examples:
<ul>
<code>define AUSSEN.wetterstation VantagePro2 192.168.8.127 4999 60</code><br>
<code>
fhem> list AUSSEN.wetterstation<br>
Internals:<br>
DEF 192.168.8.127 4999 60<br>
Host 192.168.8.127<br>
NAME AUSSEN.wetterstation<br>
NR 5<br>
Port 4999<br>
STATE T-OUT: 22.78 T-IN: 26.50 H-OUT: 55 H-IN: 45 W: 1.61 W-AV: 1.61 WS 257 R: 0.00 S: 770 UV: 4.1 RD: 0 RM: 41 RY: 241 BM: 76.27 BT: Steady<br>
TYPE VantagePro2<br>
Readings:<br>
2010-08-04 10:15:17 10 min. average windspeed 1.61 (km/h)<br>
2010-08-04 10:15:17 UV 4.1 (UV/Index)<br>
2010-08-04 10:15:17 barometer 76.27 (Millimeters)<br>
2010-08-04 10:15:17 barometer trend Steady<br>
2010-08-04 10:15:17 day rain 0 (mm/day)<br>
2010-08-04 10:15:17 humidity inside 45 (%)<br>
2010-08-04 10:15:17 humidity outside 55 (%)<br>
2010-08-04 10:15:17 month rain 41 (mm/month)<br>
2010-08-04 10:15:17 rainrate 0.00 (mm/h)<br>
2010-08-04 10:15:17 solar 770 (Watt/m^2)<br>
2010-08-04 10:15:17 temperature-inside 26.50 (Celsius)<br>
2010-08-04 10:15:17 temperature-outside 22.78 (Celsius)<br>
2010-08-04 10:15:17 wind direction 257 (Degrees)<br>
2010-08-04 10:15:17 windspeed 1.61 (km/h)<br>
2010-08-04 10:15:17 year rain 241 (mm/year)<br>
Attributes:<br>
delay 60<br>
</code><br>
</ul>
</ul>
</ul>
=end html
=cut

View File

@ -0,0 +1,161 @@
################################################################
#
# Copyright notice
#
# (c) 2019 Christoph Morrison <fhem@christoph-jeschke.de>
# 2011 Sacha Gloor (sacha@imp.ch)
#
# This script is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# The GNU General Public License can be found at
# http://www.gnu.org/copyleft/gpl.html.
# A copy is found in the textfile GPL.txt and important notices to the license
# from the author is found in LICENSE.txt distributed with these scripts.
#
# This script is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# This copyright notice MUST APPEAR in all copies of the script!
#
################################################################
# $Id: 88_WEBCOUNT.pm 19919 2019-07-30 12:21:04Z jeschkec $
package main;
use strict;
use warnings;
use XML::Simple;
use Data::Dumper;
use LWP::UserAgent;
use HTTP::Request;
#####################################
sub WEBCOUNT_Initialize($)
{
my ($hash) = @_;
# Consumer
$hash->{DefFn} = "WEBCOUNT_Define";
$hash->{AttrList}= "model:WEBCOUNT delay loglevel:0,1,2,3,4,5,6";
}
#####################################
sub WEBCOUNT_Define($$)
{
my ($hash, $def) = @_;
my $name=$hash->{NAME};
my @a = split("[ \t][ \t]*", $def);
Log 5, "WEBCOUNT Define: $a[0] $a[1] $a[2] $a[3] $a[4]";
return "Define the host as a parameter i.e. WEBCOUNT" if(@a < 4);
my $host = $a[2];
my $host_port = $a[3];
my $delay=$a[4];
$attr{$name}{delay}=$delay if $delay;
Log 1, "WEBCOUNT device is none, commands will be echoed only" if($host eq "none");
$hash->{Host} = $host;
$hash->{Host_Port} = $host_port;
$hash->{STATE} = "Initialized";
Log 4,"$name: Delay $delay";
InternalTimer(gettimeofday()+$delay, "WEBCOUNT_GetStatus", $hash, 0);
return undef;
}
#####################################
sub WEBCOUNT_GetStatus($)
{
my ($hash) = @_;
my $buf;
if(!defined($hash->{Host_Port})) { return(""); }
Log 5, "WEBCOUNT_GetStatus";
my $name = $hash->{NAME};
my $host = $hash->{Host};
my $host_port = $hash->{Host_Port};
my $text='';
my $err_log='';
my $delay=$attr{$name}{delay}||300;
InternalTimer(gettimeofday()+$delay, "WEBCOUNT_GetStatus", $hash, 0);
my $xml = new XML::Simple;
my $URL="http://".$host."/counter?PW=&";
my $agent = LWP::UserAgent->new(env_proxy => 1,keep_alive => 1, timeout => 3);
my $header = HTTP::Request->new(GET => $URL);
my $request = HTTP::Request->new('GET', $URL, $header);
my $response = $agent->request($request);
$err_log.= "Can't get $URL -- ".$response->status_line
unless $response->is_success;
if($err_log ne "")
{
Log GetLogLevel($name,2), "WEBCOUNT ".$err_log;
return("");
}
my $body = $response->content;
my @cur = split(";", $body);
my $current=$cur[$host_port];
$text="Counter: ".$current;
my $sensor="counter";
Log 4,"$name: $text";
if (!$hash->{local}){
$hash->{CHANGED}[0] = $text;
$hash->{READINGS}{$sensor}{TIME} = TimeNow();
$hash->{READINGS}{$sensor}{VAL} = $current;
DoTrigger($name, undef) if($init_done);
}
$hash->{STATE} = $current;
return($text);
}
1;
=pod
=item device
=item summary Support for Wiesemann &amp; Theis 57652 Web-Count 6x Digital
=item summary_DE Unterstützung für Wiesemann &amp; Theis 57652 Web-Count 6x Digital
=begin html
<a name="WEBCOUNT"></a>
<h3>WEBCOUNT</h3>
<ul>
Note: this module needs the HTTP::Request and LWP::UserAgent perl modules.
<br><br>
<a name="WEBCOUNTdefine"></a>
<b>Define</b>
<ul>
<code>define &lt;name&gt; WEBCOUNT &lt;ip-address&gt; &lt;port&gt; &lt;delay&gt;</code>
<br><br>
Defines an WEBCOUNT device (Box with 6 count pulses, www.wut.de) via ip address. The device is pooled (delay interval).<br><br>
Examples:
<ul>
<code>define pump WEBCOUNT 192.168.8.200 1 60</code><br>
</ul>
</ul>
<br>
</ul>
=end html
=cut