From 4cce5cc3d94ef73067f2b15b90a5d2d9a4bcf8de Mon Sep 17 00:00:00 2001 From: matscher Date: Mon, 10 Mar 2014 19:18:35 +0000 Subject: [PATCH] update of module 09_CUL_FHTTK.pm (documentation and modullist) git-svn-id: svn://svn.code.sf.net/p/fhem/code/trunk@5191 2b470e98-0d58-463d-a4d8-8e2adae1ed80 --- fhem/CHANGED | 2 ++ fhem/FHEM/09_CUL_FHTTK.pm | 71 +++++++++++++++++++++++++++++++++++---- 2 files changed, 67 insertions(+), 6 deletions(-) diff --git a/fhem/CHANGED b/fhem/CHANGED index 35681f428..c657b0991 100644 --- a/fhem/CHANGED +++ b/fhem/CHANGED @@ -1,6 +1,8 @@ # Add changes at the top of the list. Keep it in ASCII, and 80-char wide. # Do not insert empty lines here, update check depends on it. - SVN + - change: 09_CUL_FHTTK.pm: extend module list to FHT80TF and FHT80TF-2 + and update of documentation (matscher) - feature: disabledForIntervals attribute added for at/notify/watchdog - feature: jsonlist2 added, jsonlist is deprecated. - change: renamed 98_configDB to 98_configDBwrap diff --git a/fhem/FHEM/09_CUL_FHTTK.pm b/fhem/FHEM/09_CUL_FHTTK.pm index eb38e5397..c7433426d 100644 --- a/fhem/FHEM/09_CUL_FHTTK.pm +++ b/fhem/FHEM/09_CUL_FHTTK.pm @@ -95,6 +95,13 @@ my %fhttfk_translatedcodes = ( "91" => "11", "92" => "12"); +# set +my %fhttfk_c2b; # command->button hash +my %canset = ( + "01" => "Open", + "02" => "Closed", + "0c" => "Syncing"); + # -wusel, 2009-11-06 # # Parse messages from FHT80TK, normally interpreted only by FHT80 @@ -110,19 +117,71 @@ sub CUL_FHTTK_Initialize($) { my ($hash) = @_; + + foreach my $k (keys %canset) { + my $v = $canset{$k}; + $fhttfk_c2b{$v} = $k; + } - $hash->{Match} = "^T[A-F0-9]{8}", + $hash->{Match} = "^T[A-F0-9]{8}"; + $hash->{SetFn} = "CUL_FHTTK_Set"; $hash->{DefFn} = "CUL_FHTTK_Define"; $hash->{UndefFn} = "CUL_FHTTK_Undef"; $hash->{ParseFn} = "CUL_FHTTK_Parse"; $hash->{AttrList} = "IODev do_not_notify:1,0 ignore:0,1 showtime:0,1 " . - "model:FHT80TF ". + "model:FHT80TF,FHT80TF-2,dummy ". $readingFnAttributes; $hash->{AutoCreate}= { "CUL_FHTTK.*" => { GPLOT => "fht80tf:Window,", FILTER => "%NAME" } }; } +############################# + +sub +CUL_FHTTK_Set($@) +{ + my ($hash, @a) = @_; + my $ret = ""; + + return "\"set $a[0]\" needs at least two parameters" if(@a < 2); + + my $name = shift(@a); + + # return here to supress set at cul_fhttk devices + if(defined($attr{$name}) && defined($attr{$name}{"model"})) { + if($attr{$name}{"model"} ne "dummy") { + return $ret + } + } + + my $opt = shift @a; + my $value = join("", @a); + + Log3 $name, 5, "$name $opt a ist $a[0] und $a[1] und value: $value"; + + if(!defined($fhttfk_c2b{$opt})) { + my @cList = keys %fhttfk_c2b; + return "Unknown argument $opt ($value), choose one of " . join(" ", @cList); + } + + # add T as prefix, because of protocol like TCCCCCXX + my $arg = "T" . $hash->{CODE}; + + # fhttfk_c2b + $arg .= $fhttfk_c2b{$opt}; + Log3 $name, 5, "$name $opt message with option code: $arg"; + + # write msg to CUL/CUNO + CUL_SimpleWrite($hash, $arg); + Log3 $name, 2, "CUL_FHTTK set $name $opt"; + + # update new state + readingsSingleUpdate($hash, "state", $opt, 1); + readingsSingleUpdate($hash, "Window", $opt, 1); + + return $ret; +} ############################# sub @@ -308,8 +367,8 @@ CUL_FHTTK_Parse($$) Attributes