mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-04-22 02:10:32 +00:00
empty cmd-Q before pairing, improve autoReadReg details
git-svn-id: https://svn.fhem.de/fhem/trunk@4029 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
f228ed84f6
commit
4561c8b3c7
@ -34,6 +34,7 @@ my %sets = ( "hmPairForSec" => "HomeMatic"
|
|||||||
my %HMcond = ( 0 =>'ok'
|
my %HMcond = ( 0 =>'ok'
|
||||||
,2 =>'Warning-HighLoad'
|
,2 =>'Warning-HighLoad'
|
||||||
,4 =>'ERROR-Overload'
|
,4 =>'ERROR-Overload'
|
||||||
|
,252=>'timeout'
|
||||||
,253=>'disconnected'
|
,253=>'disconnected'
|
||||||
,254=>'Overload-released'
|
,254=>'Overload-released'
|
||||||
,255=>'init');
|
,255=>'init');
|
||||||
@ -50,6 +51,7 @@ sub HMLAN_Initialize($) {
|
|||||||
$hash->{WriteFn} = "HMLAN_Write";
|
$hash->{WriteFn} = "HMLAN_Write";
|
||||||
$hash->{ReadyFn} = "HMLAN_Ready";
|
$hash->{ReadyFn} = "HMLAN_Ready";
|
||||||
$hash->{SetFn} = "HMLAN_Set";
|
$hash->{SetFn} = "HMLAN_Set";
|
||||||
|
$hash->{NotifyFn}= "HMLAN_Notify";
|
||||||
$hash->{AttrFn} = "HMLAN_Attr";
|
$hash->{AttrFn} = "HMLAN_Attr";
|
||||||
$hash->{Clients} = ":CUL_HM:";
|
$hash->{Clients} = ":CUL_HM:";
|
||||||
my %mc = (
|
my %mc = (
|
||||||
@ -138,7 +140,17 @@ sub HMLAN_RemoveHMPair($) {####################################################
|
|||||||
my $hash = $defs{$name};
|
my $hash = $defs{$name};
|
||||||
delete($hash->{hmPair});
|
delete($hash->{hmPair});
|
||||||
}
|
}
|
||||||
sub HMLAN_Attr(@) {#################################
|
sub HMLAN_Notify(@) {##########################################################
|
||||||
|
my ($hash,$dev) = @_;
|
||||||
|
return if ($dev->{NAME} ne $hash->{NAME}); # looking for our own connect/disconnect
|
||||||
|
|
||||||
|
foreach (grep (m/CONNECTED$/,@{$dev->{CHANGED}})) { # connect/disconnect
|
||||||
|
if ($_ eq "DISCONNECTED") {HMLAN_condUpdate($hash,253);}
|
||||||
|
# elsif ($_ eq "CONNECTED") {covered by init;}
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
sub HMLAN_Attr(@) {############################################################
|
||||||
my ($cmd,$name, $attrName,$aVal) = @_;
|
my ($cmd,$name, $attrName,$aVal) = @_;
|
||||||
if ($attrName eq "wdTimer"){#allow between 5 and 25 second
|
if ($attrName eq "wdTimer"){#allow between 5 and 25 second
|
||||||
return "select wdTimer between 5 and 25 seconds" if ($aVal>25 || $aVal<5);
|
return "select wdTimer between 5 and 25 seconds" if ($aVal>25 || $aVal<5);
|
||||||
@ -195,14 +207,14 @@ sub HMLAN_Attr(@) {#################################
|
|||||||
return "please add plain integer between 100 and 600"
|
return "please add plain integer between 100 and 600"
|
||||||
if ( $aVal !~ m/^(\d+)$/
|
if ( $aVal !~ m/^(\d+)$/
|
||||||
||$aVal<100
|
||$aVal<100
|
||||||
||$aVal >300 );
|
||$aVal >600 );
|
||||||
$attr{$name}{hmMsgLowLimit} =$aVal;
|
$attr{$name}{hmMsgLowLimit} =$aVal;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
sub HMLAN_UpdtMsgCnt($) {#################################
|
sub HMLAN_UpdtMsgCnt($) {######################################################
|
||||||
# update HMLAN capacity counter
|
# update HMLAN capacity counter
|
||||||
# HMLAN will raise high-load after ~610 msgs per hour
|
# HMLAN will raise high-load after ~610 msgs per hour
|
||||||
# overload with send-stop after 670 msgs
|
# overload with send-stop after 670 msgs
|
||||||
@ -215,7 +227,7 @@ sub HMLAN_UpdtMsgCnt($) {#################################
|
|||||||
InternalTimer(gettimeofday()+100, "HMLAN_UpdtMsgCnt", "UpdtMsg:".$name, 0);
|
InternalTimer(gettimeofday()+100, "HMLAN_UpdtMsgCnt", "UpdtMsg:".$name, 0);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
sub HMLAN_UpdtMsgLoad($$) {#################################
|
sub HMLAN_UpdtMsgLoad($$) {####################################################
|
||||||
my($name,$incr) = @_;
|
my($name,$incr) = @_;
|
||||||
my $hash = $defs{$name};
|
my $hash = $defs{$name};
|
||||||
my $hCap = $hash->{helper}{q}{cap};
|
my $hCap = $hash->{helper}{q}{cap};
|
||||||
@ -572,7 +584,6 @@ sub HMLAN_SimpleWrite(@) {#####################################################
|
|||||||
my ($hash, $msg, $nonl) = @_;
|
my ($hash, $msg, $nonl) = @_;
|
||||||
|
|
||||||
return if(!$hash || AttrVal($hash->{NAME}, "dummy", undef));
|
return if(!$hash || AttrVal($hash->{NAME}, "dummy", undef));
|
||||||
HMLAN_condUpdate($hash,253) if ($hash->{STATE} eq "disconnected");#closed?
|
|
||||||
|
|
||||||
my $name = $hash->{NAME};
|
my $name = $hash->{NAME};
|
||||||
my $ll5 = GetLogLevel($name,5);
|
my $ll5 = GetLogLevel($name,5);
|
||||||
@ -700,8 +711,8 @@ sub HMLAN_KeepAliveCheck($) {##################################################
|
|||||||
my $hash = $defs{$name};
|
my $hash = $defs{$name};
|
||||||
if ($hash->{helper}{q}{keepAliveRec} != 1){# no answer
|
if ($hash->{helper}{q}{keepAliveRec} != 1){# no answer
|
||||||
if ($hash->{helper}{q}{keepAliveRpt} >2){# give up here
|
if ($hash->{helper}{q}{keepAliveRpt} >2){# give up here
|
||||||
|
HMLAN_condUpdate($hash,252);# trigger timeout event
|
||||||
DevIo_Disconnected($hash);
|
DevIo_Disconnected($hash);
|
||||||
HMLAN_condUpdate($hash,253);
|
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
$hash->{helper}{q}{keepAliveRpt}++;
|
$hash->{helper}{q}{keepAliveRpt}++;
|
||||||
|
@ -52,7 +52,6 @@ sub CUL_HM_Set($@);
|
|||||||
sub CUL_HM_valvePosUpdt(@);
|
sub CUL_HM_valvePosUpdt(@);
|
||||||
sub CUL_HM_infoUpdtDevData($$$);
|
sub CUL_HM_infoUpdtDevData($$$);
|
||||||
sub CUL_HM_infoUpdtChanData(@);
|
sub CUL_HM_infoUpdtChanData(@);
|
||||||
sub CUL_HM_Pair(@);
|
|
||||||
sub CUL_HM_getConfig($$$$$);
|
sub CUL_HM_getConfig($$$$$);
|
||||||
sub CUL_HM_SndCmd($$);
|
sub CUL_HM_SndCmd($$);
|
||||||
sub CUL_HM_responseSetup($$);
|
sub CUL_HM_responseSetup($$);
|
||||||
@ -140,7 +139,7 @@ sub CUL_HM_Initialize($) {
|
|||||||
"rawToReadable unit ".#"KFM-Sensor" only
|
"rawToReadable unit ".#"KFM-Sensor" only
|
||||||
"peerIDs repPeers ".
|
"peerIDs repPeers ".
|
||||||
"actCycle actStatus ".
|
"actCycle actStatus ".
|
||||||
"autoReadReg:1_restart,0_off,2_pon-restart,3_onChange,4_reqStatus ".
|
"autoReadReg:0_off,1_restart,2_pon-restart,3_onChange,4_reqStatus ".
|
||||||
"expert:0_off,1_on,2_full ".
|
"expert:0_off,1_on,2_full ".
|
||||||
"param msgRepeat ".
|
"param msgRepeat ".
|
||||||
".stc .devInfo ".
|
".stc .devInfo ".
|
||||||
@ -177,43 +176,40 @@ sub CUL_HM_autoReadConfig($){
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
while(@{$modules{CUL_HM}{helper}{autoRdCfgLst}}){
|
while(@{$modules{CUL_HM}{helper}{autoRdCfgLst}}){
|
||||||
|
|
||||||
if ( $modules{CUL_HM}{helper}{autoRdActive} # predecisor is stored
|
if ( $modules{CUL_HM}{helper}{autoRdActive} # predecisor is stored
|
||||||
&& $defs{$modules{CUL_HM}{helper}{autoRdActive}}){
|
&& $defs{$modules{CUL_HM}{helper}{autoRdActive}}){
|
||||||
my $dName = CUL_HM_getDeviceName($modules{CUL_HM}{helper}{autoRdActive});
|
my $dName = CUL_HM_getDeviceName($modules{CUL_HM}{helper}{autoRdActive});
|
||||||
if ($defs{$dName}{helper}{prt}{sProc}){ # predecisor still working
|
last if ($defs{$dName}{helper}{prt}{sProc}); # predecisor still working
|
||||||
InternalTimer(gettimeofday()+$modules{CUL_HM}{hmAutoReadScan}
|
|
||||||
,"CUL_HM_autoReadConfig"
|
|
||||||
,"autoRdCfg",0);
|
|
||||||
last;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
my $tName = CUL_HM_getDeviceName(${$modules{CUL_HM}{helper}{autoRdCfgLst}}[0]);
|
my $tName = CUL_HM_getDeviceName(${$modules{CUL_HM}{helper}{autoRdCfgLst}}[0]);
|
||||||
my $ioName = $defs{$tName}{IODev}{NAME};
|
my $ioName = $defs{$tName}{IODev}{NAME};
|
||||||
if (ReadingsVal($ioName,"cond","") !~ m /^(ok|Overload-released|init)$/
|
if (ReadingsVal($ioName,"cond","") !~ m /^(ok|Overload-released|init)$/
|
||||||
|| ( $defs{$ioName}{helper}{q}
|
|| ( $defs{$ioName}{helper}{q}
|
||||||
&& $defs{$ioName}{helper}{q}{cap}{sum}>AttrVal($ioName,"hmMsgLowLimit",500))){
|
&& $defs{$ioName}{helper}{q}{cap}{sum}>AttrVal($ioName,"hmMsgLowLimit",500))){
|
||||||
InternalTimer(gettimeofday()+$modules{CUL_HM}{hmAutoReadScan}
|
|
||||||
,"CUL_HM_autoReadConfig"
|
|
||||||
,"autoRdCfg",0);
|
|
||||||
last;
|
last;
|
||||||
}
|
}
|
||||||
#--- unqueue and process---
|
#--- unqueue and process---
|
||||||
my $name = shift(@{$modules{CUL_HM}{helper}{autoRdCfgLst}});
|
my $name = shift(@{$modules{CUL_HM}{helper}{autoRdCfgLst}});
|
||||||
my $hash = $defs{$name};
|
my $hash = $defs{$name};
|
||||||
delete $hash->{autoRead};
|
delete $hash->{autoRead};
|
||||||
|
next if (AttrVal($name,"subType","") eq "virtual");
|
||||||
|
|
||||||
if (0 != CUL_HM_getAttrInt($name,"autoReadReg")){
|
if (0 != CUL_HM_getAttrInt($name,"autoReadReg")){
|
||||||
#CUL_HM_Set($hash,$name,"getSerial");
|
#CUL_HM_Set($hash,$name,"getSerial");
|
||||||
CUL_HM_Set($hash,$name,"getConfig");
|
CUL_HM_Set($hash,$name,"getConfig");
|
||||||
CUL_HM_Set($hash,$name,"statusRequest");
|
CUL_HM_Set($hash,$name,"statusRequest");
|
||||||
InternalTimer(gettimeofday()+$modules{CUL_HM}{hmAutoReadScan}
|
my $mId = CUL_HM_getMId($hash);
|
||||||
,"CUL_HM_autoReadConfig"
|
$modules{CUL_HM}{helper}{autoRdActive} = $name
|
||||||
,"autoRdCfg",0);
|
if ( CUL_HM_getRxType($hash) & 0xEB # 0x14 invers, if mode other then config
|
||||||
$modules{CUL_HM}{helper}{autoRdActive} = $name;#remember name
|
||( $culHmModel{$mId}{cyc}
|
||||||
|
&& $culHmModel{$mId}{cyc} !~ m/^28:/));
|
||||||
last;
|
last;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
InternalTimer(gettimeofday()+$modules{CUL_HM}{hmAutoReadScan}
|
||||||
|
,"CUL_HM_autoReadConfig"
|
||||||
|
,"autoRdCfg",0);
|
||||||
}
|
}
|
||||||
sub CUL_HM_updateConfig($){
|
sub CUL_HM_updateConfig($){
|
||||||
# this routine is called 5 sec after the last define of a restart
|
# this routine is called 5 sec after the last define of a restart
|
||||||
@ -230,7 +226,8 @@ sub CUL_HM_updateConfig($){
|
|||||||
my $actCycle = AttrVal($name,"actCycle",undef);
|
my $actCycle = AttrVal($name,"actCycle",undef);
|
||||||
CUL_HM_ActAdd($id,$actCycle) if ($actCycle);# add to ActionDetect?
|
CUL_HM_ActAdd($id,$actCycle) if ($actCycle);# add to ActionDetect?
|
||||||
# --- set default attrubutes if missing ---
|
# --- set default attrubutes if missing ---
|
||||||
if ($hash->{helper}{role}{dev}){
|
if ( $hash->{helper}{role}{dev}
|
||||||
|
&& AttrVal($name,"subType","") ne "virtual"){
|
||||||
$attr{$name}{expert} = AttrVal($name,"expert" ,"2_full");
|
$attr{$name}{expert} = AttrVal($name,"expert" ,"2_full");
|
||||||
$attr{$name}{autoReadReg}= AttrVal($name,"autoReadReg","4_reqStatus")
|
$attr{$name}{autoReadReg}= AttrVal($name,"autoReadReg","4_reqStatus")
|
||||||
if(CUL_HM_getRxType($hash)&0xEB);
|
if(CUL_HM_getRxType($hash)&0xEB);
|
||||||
@ -1629,16 +1626,36 @@ sub CUL_HM_parseCommon(@){#####################################################
|
|||||||
$ret = $reply;
|
$ret = $reply;
|
||||||
}
|
}
|
||||||
elsif($mTp eq "00"){######################################
|
elsif($mTp eq "00"){######################################
|
||||||
if ($pendType eq "PairSerial"){
|
|
||||||
if($shash->{helper}{prt}{rspWait}{forChn} = substr($p,6,20)){
|
|
||||||
CUL_HM_respPendRm($shash);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
CUL_HM_ProcessCmdStack($shash) if(CUL_HM_getRxType($shash) & 0x04);#config
|
|
||||||
CUL_HM_infoUpdtDevData($shash->{NAME}, $shash,$p);#update data
|
CUL_HM_infoUpdtDevData($shash->{NAME}, $shash,$p);#update data
|
||||||
|
|
||||||
if(!$shash->{cmdStack} || !(CUL_HM_getRxType($shash) & 0x04)) {
|
|
||||||
CUL_HM_Pair($shash->{NAME}, $shash,$mFlg.$mTp,$src,$dst,$p);
|
my $iohash = $shash->{IODev};
|
||||||
|
my $id = CUL_HM_Id($iohash);
|
||||||
|
|
||||||
|
if( $dst =~ m /(000000|$id)/ #--- see if we need to pair
|
||||||
|
&&($iohash->{hmPair}
|
||||||
|
||( $iohash->{hmPairSerial}
|
||||||
|
&& $iohash->{hmPairSerial} eq $attr{$shash->{NAME}}{serialNr}))
|
||||||
|
&&( $mFlg.$mTp ne "0400") ) {
|
||||||
|
#-- try to pair
|
||||||
|
Log GetLogLevel($shash->{NAME},3), "CUL_HM pair: $shash->{NAME} "
|
||||||
|
."$attr{$shash->{NAME}}{subType}, "
|
||||||
|
."model $attr{$shash->{NAME}}{model} "
|
||||||
|
."serialNr $attr{$shash->{NAME}}{serialNr}";
|
||||||
|
delete $iohash->{hmPairSerial};
|
||||||
|
CUL_HM_respPendRm($shash); # remove all pending messages
|
||||||
|
delete $shash->{cmdStack};
|
||||||
|
delete $shash->{EVENTS};
|
||||||
|
delete $shash->{helper}{prt}{rspWait};
|
||||||
|
delete $shash->{helper}{prt}{rspWaitSec};
|
||||||
|
|
||||||
|
my ($idstr, $s) = ($id, 0xA);
|
||||||
|
$idstr =~ s/(..)/sprintf("%02X%s",$s++,$1)/ge;
|
||||||
|
CUL_HM_pushConfig($shash, $id, $src,0,0,0,0, "0201$idstr");
|
||||||
|
CUL_HM_ProcessCmdStack($shash); # start processing immediately
|
||||||
|
}
|
||||||
|
elsif(CUL_HM_getRxType($shash) & 0x04){# nothing to pair - maybe send config
|
||||||
|
CUL_HM_ProcessCmdStack($shash) ;#config
|
||||||
}
|
}
|
||||||
$ret = "done";
|
$ret = "done";
|
||||||
}
|
}
|
||||||
@ -2056,7 +2073,8 @@ sub CUL_HM_Set($@) {
|
|||||||
my $ret;
|
my $ret;
|
||||||
return "no set value specified" if(@a < 2);
|
return "no set value specified" if(@a < 2);
|
||||||
my $name = $hash->{NAME};
|
my $name = $hash->{NAME};
|
||||||
return "device ignored due to attr 'ignore'" if (CUL_HM_getAttrInt($name,"ignore"));
|
return "device ignored due to attr 'ignore'"
|
||||||
|
if (CUL_HM_getAttrInt($name,"ignore"));
|
||||||
my $devName = $hash->{device}?$hash->{device}:$name;
|
my $devName = $hash->{device}?$hash->{device}:$name;
|
||||||
my $st = AttrVal($devName, "subType", "");
|
my $st = AttrVal($devName, "subType", "");
|
||||||
my $md = AttrVal($devName, "model" , "");
|
my $md = AttrVal($devName, "model" , "");
|
||||||
@ -3197,7 +3215,6 @@ sub CUL_HM_infoUpdtDevData($$$) {#autoread config
|
|||||||
CUL_HM_ActAdd($hash->{DEF},AttrVal($name,"actCycle",
|
CUL_HM_ActAdd($hash->{DEF},AttrVal($name,"actCycle",
|
||||||
$culHmModel{$mId}{cyc}));
|
$culHmModel{$mId}{cyc}));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
sub CUL_HM_infoUpdtChanData(@) {# verify attributes after reboot
|
sub CUL_HM_infoUpdtChanData(@) {# verify attributes after reboot
|
||||||
my($in ) = @_;
|
my($in ) = @_;
|
||||||
@ -3205,40 +3222,6 @@ sub CUL_HM_infoUpdtChanData(@) {# verify attributes after reboot
|
|||||||
DoTrigger("global", 'UNDEFINED '.$chnName.' CUL_HM '.$chnId);
|
DoTrigger("global", 'UNDEFINED '.$chnName.' CUL_HM '.$chnId);
|
||||||
$attr{CUL_HM_id2Name($chnId)}{model} = $model;
|
$attr{CUL_HM_id2Name($chnId)}{model} = $model;
|
||||||
}
|
}
|
||||||
sub CUL_HM_Pair(@) {
|
|
||||||
my ($name, $hash,$cmd,$src,$dst,$p) = @_;
|
|
||||||
my $iohash = $hash->{IODev};
|
|
||||||
my $id = CUL_HM_Id($iohash);
|
|
||||||
my $serNo = $attr{$name}{serialNr};
|
|
||||||
|
|
||||||
Log GetLogLevel($name,3), "CUL_HM pair: $name $attr{$name}{subType}, "
|
|
||||||
."model $attr{$name}{model} serialNr $serNo";
|
|
||||||
|
|
||||||
# Abort if we are not authorized
|
|
||||||
if($dst eq "000000") {
|
|
||||||
if(!$iohash->{hmPair} &&
|
|
||||||
(!$iohash->{hmPairSerial} || $iohash->{hmPairSerial} ne $serNo)) {
|
|
||||||
Log GetLogLevel($name,3),
|
|
||||||
$iohash->{NAME}. " pairing (hmPairForSec) not enabled";
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
elsif($dst ne $id) {
|
|
||||||
return "" ;
|
|
||||||
}
|
|
||||||
elsif($cmd eq "0400") { # WDC7000
|
|
||||||
return "" ;
|
|
||||||
}
|
|
||||||
elsif($iohash->{hmPairSerial}) {
|
|
||||||
delete($iohash->{hmPairSerial});
|
|
||||||
}
|
|
||||||
|
|
||||||
my ($idstr, $s) = ($id, 0xA);
|
|
||||||
$idstr =~ s/(..)/sprintf("%02X%s",$s++,$1)/ge;
|
|
||||||
CUL_HM_pushConfig($hash, $id, $src,0,0,0,0, "0201$idstr");
|
|
||||||
CUL_HM_ProcessCmdStack($hash); # start processing immediately
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
sub CUL_HM_getConfig($$$$$){
|
sub CUL_HM_getConfig($$$$$){
|
||||||
my ($hash,$chnhash,$id,$dst,$chn) = @_;
|
my ($hash,$chnhash,$id,$dst,$chn) = @_;
|
||||||
my $flag = CUL_HM_getFlag($hash);
|
my $flag = CUL_HM_getFlag($hash);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user