From d33c140aad21b9a8d03804be2eb71b5032af882d Mon Sep 17 00:00:00 2001 From: matscher Date: Thu, 8 Jan 2015 19:39:09 +0000 Subject: [PATCH] 09_CUL_FHTTK.pm: little improvements: added check of address code, adapted documentation git-svn-id: svn://svn.code.sf.net/p/fhem/code/trunk@7475 2b470e98-0d58-463d-a4d8-8e2adae1ed80 --- fhem/FHEM/09_CUL_FHTTK.pm | 122 +++++++++++++++++++++++++++----------- 1 file changed, 86 insertions(+), 36 deletions(-) diff --git a/fhem/FHEM/09_CUL_FHTTK.pm b/fhem/FHEM/09_CUL_FHTTK.pm index 921455b25..8524da3d9 100644 --- a/fhem/FHEM/09_CUL_FHTTK.pm +++ b/fhem/FHEM/09_CUL_FHTTK.pm @@ -98,9 +98,9 @@ my %fhttfk_translatedcodes = ( # set my %fhttfk_c2b; # command->button hash my %canset = ( - "01" => "Open", - "02" => "Closed", - "0c" => "Syncing"); + "01" => "Open", + "02" => "Closed", + "0c" => "Syncing"); # -wusel, 2009-11-06 # @@ -119,8 +119,8 @@ CUL_FHTTK_Initialize($) my ($hash) = @_; foreach my $k (keys %canset) { - my $v = $canset{$k}; - $fhttfk_c2b{$v} = $k; + my $v = $canset{$k}; + $fhttfk_c2b{$v} = $k; } $hash->{Match} = "^T[A-F0-9]{8}"; @@ -130,7 +130,7 @@ CUL_FHTTK_Initialize($) $hash->{ParseFn} = "CUL_FHTTK_Parse"; $hash->{AttrList} = "IODev do_not_notify:1,0 ignore:0,1 showtime:0,1 " . "model:FHT80TF,FHT80TF-2,dummy ". - $readingFnAttributes; + $readingFnAttributes; $hash->{AutoCreate}= { "CUL_FHTTK.*" => { GPLOT => "fht80tf:Window,", FILTER => "%NAME" } }; @@ -147,26 +147,39 @@ CUL_FHTTK_Set($@) return "\"set $a[0]\" needs at least two parameters" if(@a < 2); my $name = shift(@a); + my $opt = shift @a; # suppress SET option if(defined($attr{$name}) && defined($attr{$name}{"model"})) { - if($attr{$name}{"model"} ne "dummy") { - return $ret - } + if($attr{$name}{"model"} ne "dummy") { + return $ret; + } + + # check address of FHT TF + my $myaddr = hex($hash->{CODE}); + my $boundary = hex(690000); + + if($myaddr < $boundary) { + Log3 $name, 3, "$name wrong housecode: The first digit must be equal or greater than 0x69."; + if($opt eq "?") + { + return $ret; + } + return "$name wrong housecode: The first digit must be equal or greater than 0x69."; + } } else { - return $ret; - } - - my $opt = shift @a; + return $ret; + } + my $value = join("", @a); Log3 $name, 5, "$name option: $opt and value: $value"; if(!defined($fhttfk_c2b{$opt})) { - my @cList = keys %fhttfk_c2b; - return "Unknown argument $opt ($value), choose one of " . join(" ", @cList); - } + my @cList = keys %fhttfk_c2b; + return "Unknown argument $opt ($value), choose one of " . join(" ", @cList); + } if ($opt eq "Open" ) { Log3 $name, 3, "CUL_FHTTK ($name) changed window state to open."; @@ -179,11 +192,11 @@ CUL_FHTTK_Set($@) } elsif($opt eq "Syncing" ) { Log3 $name, 3, "CUL_FHTTK ($name) syncing with FHT80b."; - + IOWrite($hash, "", sprintf("T%s0c", $hash->{CODE})); # 0x0c - sync - # window state switch to closed through cul FW implementation - $opt = "Closed"; - + # window state switch to closed through cul FW implementation + $opt = "Closed"; + } else { return "Unknown argument $a[1], choose one of Syncing Open Closed" } @@ -208,9 +221,17 @@ CUL_FHTTK_Define($$) my $name = $a[0]; my $sensor = lc($a[2]); if($sensor !~ /^[0-9a-f]{6}$/) { - return "wrong sensor specification $sensor, need a 6 digit hex number"; + return "wrong sensor specification $sensor, need a 6 digit hex number!"; } + # check address of FHT TF at definition step + my $myaddr = hex($sensor); + my $boundary = hex(690000); + + if($myaddr < $boundary) { + return "wrong sensor specification $sensor, the fist two digits must be equal or greater than 0x69!"; + } + $hash->{CODE} = $sensor; $modules{CUL_FHTTK}{defptr}{$sensor} = $hash; @@ -248,8 +269,7 @@ CUL_FHTTK_Parse($$) return "" if(IsIgnored($name)); if(!defined($fhttfk_translatedcodes{$state})) { - Log3 $name, 1, sprintf("FHTTK $def Unknown state $state"); -# Log 3, sprintf("FHTTK $def Unknown state $state"); + Log3 $name, 1, sprintf("FHTTK $def Unknown state $state"); $defs{$name}{READINGS}{"Unknown"}{VAL} = $state; $defs{$name}{READINGS}{"Unknown"}{TIME} = TimeNow(); return ""; @@ -347,7 +367,13 @@ CUL_FHTTK_Parse($$) usually temperature+humidity sensors (no clue, why ELV didn't label this one "TFK" like with FS20 and HMS).

As said before, FHEM can receive FHT80 TF radio (868.35 MHz) messages only through an - CUL device, so this must be defined first.

+ CUL device, so this must be defined first. +

+ With the latest build on SVN + or next official version 1.62 or higher, it is possible to send out FHT80 TF data with a CUL or simular + devices. So it can be simulate up to four window sensor with one device + (see FHEM Wiki). To setup a window sensor, you have to + add and/or change the attribute "model" to dummy. The 6 digit hex number must start at 690000.

Define @@ -367,9 +393,18 @@ CUL_FHTTK_Parse($$)
- Set - -
+ Set + +
Get