From 10885385a44f3445a138916cf09381a927128264 Mon Sep 17 00:00:00 2001 From: martinp876 <> Date: Fri, 21 Dec 2012 22:01:53 +0000 Subject: [PATCH] threestate sensor devicepair, HMLAN prepare for improvement with wakeup git-svn-id: https://svn.fhem.de/fhem/trunk@2350 2b470e98-0d58-463d-a4d8-8e2adae1ed80 --- fhem/FHEM/00_HMLAN.pm | 18 +++++++++------- fhem/FHEM/10_CUL_HM.pm | 47 ++++++++++++++++++++---------------------- 2 files changed, 33 insertions(+), 32 deletions(-) diff --git a/fhem/FHEM/00_HMLAN.pm b/fhem/FHEM/00_HMLAN.pm index b38016fb4..d81e9048d 100755 --- a/fhem/FHEM/00_HMLAN.pm +++ b/fhem/FHEM/00_HMLAN.pm @@ -132,7 +132,8 @@ HMLAN_Set($@) $hash->{hmPair} = 1; InternalTimer(gettimeofday()+$arg, "HMLAN_RemoveHMPair", "hmPairForSec:".$hash, 1); - } elsif($type eq "hmPairSerial") { ################################ + } + elsif($type eq "hmPairSerial") { ################################ return "Usage: set $name hmPairSerial <10-character-serialnumber>" if(!$arg || $arg !~ m/^.{10}$/); @@ -194,7 +195,7 @@ HMLAN_ReadAnswer($$$) } } -my %lhash; +my %lhash = ""; # remember which ID is assigned to this HMLAN ##################################### sub @@ -221,8 +222,10 @@ HMLAN_Write($$$) my $IDadd = '+'.$dst; # guess: add ID? my $IDsub = '-'.$dst; # guess: ID remove? - HMLAN_SimpleWrite($hash, $IDadd) if (!$lhash{$dst} && $dst ne "000000"); - $lhash{$dst} = 1; + if (!$lhash{$dst} && $dst ne "000000"){ + HMLAN_SimpleWrite($hash, $IDadd); + $lhash{$dst} = 1; + } my $tm = int(gettimeofday()*1000) % 0xffffffff; $msg = sprintf("S%08X,00,00000000,01,%08X,%s",$tm, $tm, substr($msg, 4)); @@ -317,7 +320,7 @@ HMLAN_Parse($$) # HMLAN_SimpleWrite($hash, '-'.$src); # HMLAN_SimpleWrite($hash, '+'.$src); # } - $dmsg .= "NACK" if($mFld[1] !~ m/00(01|02|21)/ && $letter eq 'R'); + $dmsg .= ":NACK" if($mFld[1] !~ m/00(01|02|21)/ && $letter eq 'R'); $hash->{uptime} = HMLAN_uptime($mFld[2]); $hash->{RSSI} = hex($mFld[4])-65536; @@ -335,7 +338,7 @@ HMLAN_Parse($$) $hash->{helper}{keepAliveRec} = 1; Log $ll5, 'HMLAN_Parse: '.$name. ' V:'.$mFld[1] .' sNo:'.$mFld[2].' d:'.$mFld[3] - .' O:' .$mFld[4].' m:'.$mFld[5].' d2:'.$mFld[6]; + .' O:' .$mFld[4].' m:'.$mFld[5].' IDcnt:'.$mFld[6]; my $myId = AttrVal($name, "hmId", $mFld[4]); if(lc($mFld[4]) ne lc($myId) && !AttrVal($name, "dummy", 0)) { Log 1, 'HMLAN setting owner to '.$myId.' from '.$mFld[4]; @@ -436,7 +439,8 @@ HMLAN_DoInit($) HMLAN_SimpleWrite($hash, "Y03,00,"); HMLAN_SimpleWrite($hash, "Y03,00,"); HMLAN_SimpleWrite($hash, "T$s2000,04,00,00000000"); - + + %lhash = '';# clear IDs - HMLAN might have a reset $hash->{helper}{keepAliveRec} = 1; # ok for first time RemoveInternalTimer( "keepAlive:".$name);# avoid duplicate timer InternalTimer(gettimeofday()+25, "HMLAN_KeepAlive", "keepAlive:".$name, 0); diff --git a/fhem/FHEM/10_CUL_HM.pm b/fhem/FHEM/10_CUL_HM.pm index 1d9d37557..4f708354c 100755 --- a/fhem/FHEM/10_CUL_HM.pm +++ b/fhem/FHEM/10_CUL_HM.pm @@ -8,7 +8,6 @@ package main; # the lines can be removed after some soak time - around version 2600 use strict; use warnings; -#use Time::HiRes qw(gettimeofday); sub CUL_HM_Initialize($); sub CUL_HM_Define($$); @@ -354,8 +353,9 @@ CUL_HM_Parse($$) ($dst eq "000000" ? "broadcast" : ($dst eq $id ? $iohash->{NAME} : $dst)); my $target = " (to $dname)"; - - return "" if($p =~ m/NACK$/);#discard TCP errors from HMlan. Resend will cover it + my $msgStat; + ($p,$msgStat) = split(":",$p,2); + return "" if($msgStat && $msgStat eq 'NACK');#discard TCP errors from HMlan. Resend will cover it return "" if($src eq $id);#discard mirrored messages $respRemoved = 0; #set to 'no response in this message' at start @@ -366,7 +366,7 @@ CUL_HM_Parse($$) # prefer subType over model to make autocreate easier # model names are quite cryptic anyway my $model = substr($p, 2, 4); - my $stc = substr($p, 26, 2); # subTypeCode + my $stc = substr($p, 26, 2); # subTypeCode if($culHmDevProps{$stc}) { $sname = "CUL_HM_".$culHmDevProps{$stc}{st} . "_" . $src; } @@ -391,7 +391,7 @@ CUL_HM_Parse($$) if($shash->{lastMsg} && $shash->{lastMsg} eq $msgX) { Log GetLogLevel($name,4), "CUL_HM $name dup mesg"; if(($id eq $dst)&& (hex($msgFlag)&0x20)){ - CUL_HM_SndCmd($shash, $msgcnt."8002".$id.$src."0101C800"); # Send Ack +# CUL_HM_SndCmd($shash, $msgcnt."8002".$id.$src."00"); # Send Ack Log GetLogLevel($name,4), "CUL_HM $name dup mesg - ack and ignore"; } else{ @@ -1623,6 +1623,8 @@ my %culHmSubTypeSets = ( { devicepair => " device ... [single|dual] [set|unset] [actor|remote|both]",}, pushButton => { devicepair => " device ... [single|dual] [set|unset] [actor|remote|both]",}, + threeStateSensor => + { devicepair => " device ... single [set|unset] [actor|remote|both]",}, virtual => { raw => "data ...", devicepair => " device ... [single|dual] [set|unset] [actor|remote|both]", @@ -1639,37 +1641,32 @@ my %culHmSubTypeSets = ( keyMatic =>{lock =>"", unlock =>"[sec] ...", open =>"[sec] ...", - inhibit=>"[on|off]", - }, + inhibit=>"[on|off]"}, ); my %culHmModelSets = ( "HM-CC-VD"=>{ - valvePos => "position",}, + valvePos => "position"}, "HM-RC-19"=> { service => "", alarm => "", - display => " [comma,no] [unit] [off|1|2|3] [off|on|slow|fast] ",}, + display => " [comma,no] [unit] [off|1|2|3] [off|on|slow|fast] "}, "HM-RC-19-B"=> { service => "", alarm => "", - display => " [comma,no] [unit] [off|1|2|3] [off|on|slow|fast] ",}, + display => " [comma,no] [unit] [off|1|2|3] [off|on|slow|fast] "}, "HM-RC-19-SW"=> { service => "", alarm => "", - display => " [comma,no] [unit] [off|1|2|3] [off|on|slow|fast] ",}, + display => " [comma,no] [unit] [off|1|2|3] [off|on|slow|fast] "}, "HM-PB-4DIS-WM"=>{ - text => " [on|off] ",}, + text => " [on|off] "}, "HM-OU-LED16" =>{ led =>"[off|red|green|orange]" , ilum =>"[0-15] [0-127]" }, "HM-OU-CFM-PL"=>{ led => "[,..]", - playTone => "[,..]",}, - "ROTO_ZEL-STG-RM-FDK"=>{ - devicepair => " device ... single [set|unset] [actor|remote|both]",}, - "HM-SEC-RHS"=>{ - devicepair => " device ... single [set|unset] [actor|remote|both]",}, + playTone => "[,..]"}, ); my %culHmChanSets = ( @@ -2416,10 +2413,8 @@ CUL_HM_Set($@) return "$target must be [actor|remote|both]" if(defined($target) && (($target ne"actor") && ($target ne"remote")&&($target ne"both"))); return "use climate chan to pair TC" if($md eq "HM-CC-TC" &&$chn ne "02"); - return "use - single [set|unset] actor - for smoke detector" if($st eq "smokeDetector" && - (!$single || $single ne "single" || $target ne "actor")); - return "use - single - for this sensor" if(($md eq "ROTO_ZEL-STG-RM-FDK" || $md eq "HM-SEC-RHS") && - (!$single || $single ne "single")); + return "use - single [set|unset] actor - for smoke detector" if($st eq "smokeDetector" && (!$single || $single ne "single" || $target ne "actor")); + return "use - single - for threeStateSensor" if($st eq "threeStateSensor" && (!$single || $single ne "single")); $single = ($single eq "single")?1:"";#default to dual $set = ($set eq "unset")?0:1; @@ -2427,9 +2422,10 @@ CUL_HM_Set($@) my ($b1,$b2,$nrCh2Pair); $b1 = ($isChannel) ? hex($chn):(!$bNo?"01":sprintf("%02X",$bNo)); $b1 = $b1*2 - 1 if(!$single && !$isChannel); - if ($single){ - $b2 = $b1; - $nrCh2Pair = 1; + if ($single){ + $b2 = $b1; + $b1 = 0 if ($st eq "smokeDetector"); + $nrCh2Pair = 1; } else{ $b2 = $b1 + 1; @@ -2458,7 +2454,8 @@ CUL_HM_Set($@) } if (!$target || $target eq "actor" || $target eq "both"){ if (AttrVal( CUL_HM_id2Name($peerDst), "subType", "") eq "virtual"){ - CUL_HM_ID2PeerList ($peerN,$dst.sprintf("%02X",$b1),$set); #update peerlist + CUL_HM_ID2PeerList ($peerN,$dst.sprintf("%02X",$b2),$set); #update peerlist + CUL_HM_ID2PeerList ($peerN,$dst.sprintf("%02X",$b1),$set) if ($b1 & !$single); #update peerlist } else{ my $peerFlag = CUL_HM_getFlag($peerHash);