From e4fa3230a5fa5df96ceb8a331cb390108d6975fc Mon Sep 17 00:00:00 2001 From: jeschkec <> Date: Wed, 15 Apr 2020 07:08:17 +0000 Subject: [PATCH] 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 --- fhem/MAINTAINER.txt | 11 +- fhem/contrib/sacha_gloor/22_ALL3076.pm | 223 ++++++++++ fhem/contrib/sacha_gloor/23_WEBIO.pm | 206 +++++++++ .../contrib/sacha_gloor/23_WEBIO_12DIGITAL.pm | 242 +++++++++++ fhem/contrib/sacha_gloor/23_WEBTHERM.pm | 179 ++++++++ fhem/contrib/sacha_gloor/88_ALL4000T.pm | 167 ++++++++ fhem/contrib/sacha_gloor/88_Itach_Relay.pm | 186 +++++++++ .../sacha_gloor/88_LINDY_HDMI_SWITCH.pm | 153 +++++++ fhem/contrib/sacha_gloor/88_VantagePro2.pm | 393 ++++++++++++++++++ fhem/contrib/sacha_gloor/88_WEBCOUNT.pm | 161 +++++++ 10 files changed, 1911 insertions(+), 10 deletions(-) create mode 100644 fhem/contrib/sacha_gloor/22_ALL3076.pm create mode 100644 fhem/contrib/sacha_gloor/23_WEBIO.pm create mode 100644 fhem/contrib/sacha_gloor/23_WEBIO_12DIGITAL.pm create mode 100644 fhem/contrib/sacha_gloor/23_WEBTHERM.pm create mode 100644 fhem/contrib/sacha_gloor/88_ALL4000T.pm create mode 100644 fhem/contrib/sacha_gloor/88_Itach_Relay.pm create mode 100644 fhem/contrib/sacha_gloor/88_LINDY_HDMI_SWITCH.pm create mode 100644 fhem/contrib/sacha_gloor/88_VantagePro2.pm create mode 100644 fhem/contrib/sacha_gloor/88_WEBCOUNT.pm diff --git a/fhem/MAINTAINER.txt b/fhem/MAINTAINER.txt index a444bf614..5b6b8a7bd 100644 --- a/fhem/MAINTAINER.txt +++ b/fhem/MAINTAINER.txt @@ -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 diff --git a/fhem/contrib/sacha_gloor/22_ALL3076.pm b/fhem/contrib/sacha_gloor/22_ALL3076.pm new file mode 100644 index 000000000..263ecf81e --- /dev/null +++ b/fhem/contrib/sacha_gloor/22_ALL3076.pm @@ -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 ALL3076 " if(int(@a) != 3); + return undef; +} + +1; + +=pod +=begin html + + +

ALL3076

+ + +=end html +=cut diff --git a/fhem/contrib/sacha_gloor/23_WEBIO.pm b/fhem/contrib/sacha_gloor/23_WEBIO.pm new file mode 100644 index 000000000..b36546b68 --- /dev/null +++ b/fhem/contrib/sacha_gloor/23_WEBIO.pm @@ -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 WEBIO " 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 + + +

WEBIO

+
    + Note: this module needs the HTTP::Request and LWP::UserAgent perl modules. +

    + + Define +
      + define <name> WEBIO <ip-address> <port> <delay> +

      + 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).

      + + + Examples: +
        + define pumpspeed WEBIO 192.168.8.200 1 60
        +
      +
    +
    + + + Set +
      + set <name> <value> +

      + where value is one of:
      +
      +    0.00 - 10.00
      +    
      + Examples: +
        + set pumpspeed 6.75
        +
      +
      +
    +
+ +=end html +=cut diff --git a/fhem/contrib/sacha_gloor/23_WEBIO_12DIGITAL.pm b/fhem/contrib/sacha_gloor/23_WEBIO_12DIGITAL.pm new file mode 100644 index 000000000..22d662c33 --- /dev/null +++ b/fhem/contrib/sacha_gloor/23_WEBIO_12DIGITAL.pm @@ -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 WEBIO_12DIGITAL " 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 + + +

WEBIO_12DIGITAL

+
    + Note: this module needs the HTTP::Request and LWP::UserAgent perl modules. +

    + + Define +
      + define <name> WEBIO_12DIGITAL <ip-address> <outputport> <delay> +

      + 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).

      + + Examples: +
        + define motor1 WEBIO_12DIGITAL 192.168.8.200 1 60
        +
      +
    +
    + + + Set +
      + set <name> <value> +

      + where value is one of:
      +
      +       on off
      +    
      + Examples: +
        + set motor1 on
        +
      +
      +
    +
+ +=end html +=cut diff --git a/fhem/contrib/sacha_gloor/23_WEBTHERM.pm b/fhem/contrib/sacha_gloor/23_WEBTHERM.pm new file mode 100644 index 000000000..5b5c4af74 --- /dev/null +++ b/fhem/contrib/sacha_gloor/23_WEBTHERM.pm @@ -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 . +# +################################################################ + +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 WEBTHERM " 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 + + +

WEBTHERM

+
    + This module connects a Web-Thermometer made by W&T to your FHEM installation.
    + Currently this module is no longer maintained, but it should work in its current state.
    + It is provided "as is" for backward compatibility.
    +
    + + Define +

      + define <name> WEBTHERM <ip-address> <port-nr> <interval>
      +
      + Defines a WEBTHERM device at given ip and port.
      + Values are polled periodically defined by given interval (in seconds).
      + Read temperature is written into reading "state".
      +
    +

    + + + Set +
      + N/A +
    +

    + + + Get +
      + N/A +
    +

    + + + Attr +
      + N/A +
    +
+=end html +=begin html_DE + + +

WEBTHERM

+
    +Sorry, keine deutsche Dokumentation vorhanden.

    +Die englische Doku gibt es hier: WEBTHERM
    +
+=end html_DE +=cut diff --git a/fhem/contrib/sacha_gloor/88_ALL4000T.pm b/fhem/contrib/sacha_gloor/88_ALL4000T.pm new file mode 100644 index 000000000..aa2944ba5 --- /dev/null +++ b/fhem/contrib/sacha_gloor/88_ALL4000T.pm @@ -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 + + +

ALL4000T

+
    + Note: this module requires the following perl modules: XML::Simple LWP::UserAgent + HTTP::Request. +

    + + Define +
      + define <name> ALL4000T <ip-address> <port> <delay> +

      + 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.

      + + Examples: +
        + define AUSSEN.POOL.TEMP.vorlauf ALL4000T 192.168.68.20 t2 120
        +
      +
    +
    +
+=end html +=cut diff --git a/fhem/contrib/sacha_gloor/88_Itach_Relay.pm b/fhem/contrib/sacha_gloor/88_Itach_Relay.pm new file mode 100644 index 000000000..2ac45c18d --- /dev/null +++ b/fhem/contrib/sacha_gloor/88_Itach_Relay.pm @@ -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 ITACH_RELAY " if(int(@a) != 4); + + $hash->{Host} = $host; + $hash->{Host_Port} = $host_port; + + return undef; +} + +1; + +=pod +=begin html + + +

ITACH_RELAY

+
    + Note: this module needs the Net::Telnet module. +

    + + Define +
      + define <name> ITACH_RELAY <ip-address> <port> +

      + Defines an Global Cache iTach Relay device (Box with 3 relays) via its ip address.

      + + + Examples: +
        + define motor1 ITACH_RELAY 192.168.8.200 1
        +
      +
    +
    + + + Set +
      + set <name> <value> +

      + where value is one of:
      +
      +    off
      +    on
      +    toggle
      +    
      + Examples: +
        + set motor1 on
        +
      +
      + Notes: +
        +
      • Toggle is special implemented. List name returns "on" or "off" even after a toggle command
      • +
      +
    +
+ +=end html +=cut diff --git a/fhem/contrib/sacha_gloor/88_LINDY_HDMI_SWITCH.pm b/fhem/contrib/sacha_gloor/88_LINDY_HDMI_SWITCH.pm new file mode 100644 index 000000000..11b72d30a --- /dev/null +++ b/fhem/contrib/sacha_gloor/88_LINDY_HDMI_SWITCH.pm @@ -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 LINDY_HDMI_SWITCH " 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 + + +

LINDY_HDMI_SWITCH

+
    + Note: this module needs the Net::Telnet module. +

    + + Define +
      + define <name> LINDY_HDMI_SWITCH <ip-address> <port> +

      + 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

      + + Examples: +
        + define livingroom.hdmi LINDY_HDMI_SWITCH 192.168.1.64 4999
        +
      +
    +
    + + + Set +
      + set <name> <value> +

      + where value is one of:
      +
      +	11 
      +	12
      +	13
      +	14
      +	21
      +	22
      +	23
      +	24
      +    
      + First digit is the output port, second digit is the input port. + Example: +
        + set livingroom.hdmi 12
        +
      +
      +
    +
+ +=end html +=cut diff --git a/fhem/contrib/sacha_gloor/88_VantagePro2.pm b/fhem/contrib/sacha_gloor/88_VantagePro2.pm new file mode 100644 index 000000000..850462ec1 --- /dev/null +++ b/fhem/contrib/sacha_gloor/88_VantagePro2.pm @@ -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 + + +

VantagePro2

+
    + Note: this module needs the Net::Telnet perl module. +

    + + Define +
      + define <name> <ip-address> <port> <delay> +

      + Defines a Davis VantagePro2 weatherstation attached on transparent ethernet/usb|serial server accessable by telnet.

      + + Examples: +
        + define AUSSEN.wetterstation VantagePro2 192.168.8.127 4999 60
        + + fhem> list AUSSEN.wetterstation
        + Internals:
        + DEF 192.168.8.127 4999 60
        + Host 192.168.8.127
        + NAME AUSSEN.wetterstation
        + NR 5
        + Port 4999
        + 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
        + TYPE VantagePro2
        + Readings:
        + 2010-08-04 10:15:17 10 min. average windspeed 1.61 (km/h)
        + 2010-08-04 10:15:17 UV 4.1 (UV/Index)
        + 2010-08-04 10:15:17 barometer 76.27 (Millimeters)
        + 2010-08-04 10:15:17 barometer trend Steady
        + 2010-08-04 10:15:17 day rain 0 (mm/day)
        + 2010-08-04 10:15:17 humidity inside 45 (%)
        + 2010-08-04 10:15:17 humidity outside 55 (%)
        + 2010-08-04 10:15:17 month rain 41 (mm/month)
        + 2010-08-04 10:15:17 rainrate 0.00 (mm/h)
        + 2010-08-04 10:15:17 solar 770 (Watt/m^2)
        + 2010-08-04 10:15:17 temperature-inside 26.50 (Celsius)
        + 2010-08-04 10:15:17 temperature-outside 22.78 (Celsius)
        + 2010-08-04 10:15:17 wind direction 257 (Degrees)
        + 2010-08-04 10:15:17 windspeed 1.61 (km/h)
        + 2010-08-04 10:15:17 year rain 241 (mm/year)
        +Attributes:
        + delay 60
        +

        +
      +
    +
+ +=end html +=cut diff --git a/fhem/contrib/sacha_gloor/88_WEBCOUNT.pm b/fhem/contrib/sacha_gloor/88_WEBCOUNT.pm new file mode 100644 index 000000000..c440e65c3 --- /dev/null +++ b/fhem/contrib/sacha_gloor/88_WEBCOUNT.pm @@ -0,0 +1,161 @@ +################################################################ +# +# Copyright notice +# +# (c) 2019 Christoph Morrison +# 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 & Theis 57652 Web-Count 6x Digital +=item summary_DE Unterstützung für Wiesemann & Theis 57652 Web-Count 6x Digital + +=begin html + + +

WEBCOUNT

+
    + Note: this module needs the HTTP::Request and LWP::UserAgent perl modules. +

    + + Define +
      + define <name> WEBCOUNT <ip-address> <port> <delay> +

      + Defines an WEBCOUNT device (Box with 6 count pulses, www.wut.de) via ip address. The device is pooled (delay interval).

      + + + Examples: +
        + define pump WEBCOUNT 192.168.8.200 1 60
        +
      +
    +
    +
+=end html +=cut