From df848c8b7fe8caa1560c47868eab22e6d5851f2b Mon Sep 17 00:00:00 2001 From: wzut Date: Tue, 17 Mar 2015 17:46:11 +0000 Subject: [PATCH] http://forum.fhem.de/index.php/topic,34131.0.html git-svn-id: svn://svn.code.sf.net/p/fhem/code/trunk@8230 2b470e98-0d58-463d-a4d8-8e2adae1ed80 --- fhem/contrib/Infratec/98_InfratecOut.pm | 120 ++++++++++++++++++++++++ 1 file changed, 120 insertions(+) create mode 100644 fhem/contrib/Infratec/98_InfratecOut.pm diff --git a/fhem/contrib/Infratec/98_InfratecOut.pm b/fhem/contrib/Infratec/98_InfratecOut.pm new file mode 100644 index 000000000..8690a21c1 --- /dev/null +++ b/fhem/contrib/Infratec/98_InfratecOut.pm @@ -0,0 +1,120 @@ +################################################################ +# +# $Id:$ +# +# (c) 2015 Copyright: Wzut +# forum : http://forum.fhem.de/index.php/topic,34131.0.html +# All rights reserved +# +# This code 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. +# +################################################################ +# Changelog: + +package main; + +use strict; +use warnings; +use SetExtensions; + +sub InfratecOut_Initialize($) +{ + my ($hash) = @_; + $hash->{SetFn} = "InfratecOut_Set"; + $hash->{DefFn} = "InfratecOut_Define"; + $hash->{UndefFn} = "InfratecOut_Undef"; + $hash->{AttrList} = $readingFnAttributes; +} + +################################### + +sub InfratecOut_Define($$) +{ + my ($hash, $def) = @_; + my $name = $hash->{NAME}; + + my @a = split("[ \t][ \t]*", $def); + + return "wrong syntax: use define $name InfratecOut " if(int(@a) < 4); + + my $parent = $a[2]; + my $socket = $a[3]; + + $hash->{IODEV} = $parent; + $hash->{SOCKETNR} = $socket; + + $modules{InfratecOut}{defptr}{$parent.$socket} = $hash; + + if (defined($attr{$parent}{room})) { $attr{$name}{room} = $attr{$parent}{room}; } + + my $currentstate = ReadingsVal($parent, $name, "defined"); + $hash->{STATE} = $currentstate ; + return undef; +} + +################################### + +sub InfratecOut_Undef($$) +{ + my ($hash, undef) = @_; + my $parent = $hash->{IODEV}; + my $socket = $hash->{SOCKETNR}; + delete $modules{InfratecOut}{defptr}{$parent.$socket} ; + return undef; +} + +################################### + +sub InfratecOut_Set($@) +{ + my ($hash, $name , @a) = @_; + my $cmd = $a[0]; + + my $cmdList = "off:noArg on:noArg toggle:noArg"; + + return "$name, no set value specified" if(int(@a) < 1); + return "$name, I/O device not found please define InfratecPM device first" if(!defined($hash->{IODEV})); + + if($cmd =~ /^(on|off|toggle)$/) # nur diese drei Kommandos kennt es selbst + { + CommandSet(undef,$hash->{IODEV}." Out".$hash->{SOCKETNR}. " $cmd"); + return undef; + } + + return SetExtensions($hash,$cmdList,$name,@a); +} + +##################################### + +1; + +=pod +=begin html + + +

InfratecOut

+
    +
    + sub device for InfratecPM module +
    + + + Define +
      + define <name> InfratecOut <InfratecPM device> <Out #> +
    +
+ +=end html +