2
0
mirror of https://github.com/fhem/fhem-mirror.git synced 2025-03-13 11:16:36 +00:00

CUL_HM:bug fix for virtual dev HMkey, command parsing. Action detector autoTry streamline

git-svn-id: https://svn.fhem.de/fhem/trunk@22597 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
martinp876 2020-08-14 09:56:48 +00:00
parent 114b7d770c
commit ef37fa8e56

View File

@ -177,6 +177,7 @@ sub CUL_HM_Initialize($) {
$hash->{Attr}{dev} = "ignore:1,0 dummy:1,0 " # -- device only attributes $hash->{Attr}{dev} = "ignore:1,0 dummy:1,0 " # -- device only attributes
."IODev IOList IOgrp " ."IODev IOList IOgrp "
."hmKey hmKey2 hmKey3 " # required for VCCU
."actCycle " # also for action detector ."actCycle " # also for action detector
."readingOnDead:multiple,noChange,state,periodValues,periodString,channels " ."readingOnDead:multiple,noChange,state,periodValues,periodString,channels "
."subType:" .join(",",CUL_HM_noDup(map { $culHmModel->{$_}{st} } keys %{$culHmModel}))." " ."subType:" .join(",",CUL_HM_noDup(map { $culHmModel->{$_}{st} } keys %{$culHmModel}))." "
@ -186,7 +187,6 @@ sub CUL_HM_Initialize($) {
$hash->{Attr}{devPhy} = # -- physical device only attributes $hash->{Attr}{devPhy} = # -- physical device only attributes
"serialNr firmware .stc .devInfo " "serialNr firmware .stc .devInfo "
."actStatus " ."actStatus "
."hmKey hmKey2 hmKey3 "
."rssiLog:1,0 " # enable writing RSSI to Readings (device only) ."rssiLog:1,0 " # enable writing RSSI to Readings (device only)
."autoReadReg:0_off,1_restart,2_pon-restart,3_onChange,4_reqStatus,5_readMissing,8_stateOnly " ."autoReadReg:0_off,1_restart,2_pon-restart,3_onChange,4_reqStatus,5_readMissing,8_stateOnly "
."burstAccess:0_off,1_auto " ."burstAccess:0_off,1_auto "
@ -4268,8 +4268,8 @@ sub CUL_HM_SetList($$) {#+++++++++++++++++ get command basic list+++++++++++++++
my @cond = (); my @cond = ();
push @cond,map{$lvlStr{md}{$md}{$_}} keys%{$lvlStr{md}{$md}} if (defined $lvlStr{md}{$md}); push @cond,map{$lvlStr{md}{$md}{$_}} keys%{$lvlStr{md}{$md}} if (defined $lvlStr{md}{$md});
push @cond,map{$lvlStr{mdCh}{"$md$chn"}{$_}} keys%{$lvlStr{md}{$md}} if (defined $lvlStr{mdCh}{"$md$chn"}); push @cond,map{$lvlStr{mdCh}{"$md$chn"}{$_}} keys%{$lvlStr{md}{$md}} if (defined $lvlStr{mdCh}{"$md$chn"});
push @cond,map{$lvlStr{st}{$st}{$_}} keys%{$lvlStr{md}{$st}} if (defined $lvlStr{st}{$st}{$_}); push @cond,map{$lvlStr{st}{$st}{$_}} keys%{$lvlStr{md}{$st}} if (defined $lvlStr{st}{$st});
push @cond,"slider,0,1,100" if (!scalar @cond); push @cond,"slider,0,1,255" if (!scalar @cond);
$hash->{helper}{cmds}{lst}{condition} = join(",",grep /./,@cond); $hash->{helper}{cmds}{lst}{condition} = join(",",grep /./,@cond);
$hash->{helper}{cmds}{lst}{peer} = join",",grep/./,split",",InternalVal($name,"peerList",""); $hash->{helper}{cmds}{lst}{peer} = join",",grep/./,split",",InternalVal($name,"peerList","");
@ -4385,16 +4385,13 @@ sub CUL_HM_Set($@) {#+++++++++++++++++ set command+++++++++++++++++++++++++++++
} }
elsif($val =~ m/^(\[?)-([a-zA-Z]*?)-\]? *$/){ elsif($val =~ m/^(\[?)-([a-zA-Z]*?)-\]? *$/){
my ($null,$repl) = ($1,$2); my ($null,$repl) = ($1,$2);
if ($repl =~ m/^(ontime|sec|time)$/){ if (defined $hash->{helper}{cmds}{lst}{$repl}){
$val = ""; # nothing $null = $null ? "noArg," : "";
}
elsif (defined $hash->{helper}{cmds}{lst}{$repl}){
$null = defined $null && $null eq "[" ? "noArg," : "";
$val =~ s/\[?-$repl-\]?/:$null$hash->{helper}{cmds}{lst}{$repl}/; $val =~ s/\[?-$repl-\]?/:$null$hash->{helper}{cmds}{lst}{$repl}/;
next if ($hash->{helper}{cmds}{lst}{$repl} eq "");# no options - no command next if ($hash->{helper}{cmds}{lst}{$repl} eq "");# no options - no command
} }
else{ else{
$val = defined $null ?":noArg":""; $val = "";
} }
} }
elsif($val =~ m/^\[([a-zA-Z0-9_-|\.]*)\]$/){ elsif($val =~ m/^\[([a-zA-Z0-9_-|\.]*)\]$/){
@ -6719,12 +6716,19 @@ sub CUL_HM_Set($@) {#+++++++++++++++++ set command+++++++++++++++++++++++++++++
sub CUL_HM_Ping($) { sub CUL_HM_Ping($) {
my($defN) = @_; my($defN) = @_;
return 0 if (($defs{$defN}{helper}{rxType} & 0xe3) == 0); # no ping for config devices return 0 if (($defs{$defN}{helper}{rxType} & 0xe3) == 0); # no ping for config devices
my (undef, $nres) = CUL_HM_Set($defs{$defN},$defN,"sysTime"); # noansi: fix warnings my (undef, $nres) = CUL_HM_Set($defs{$defN},$defN,"sysTime");
return 1 if (defined($nres) && 1 == $nres); return 1 if (defined($nres) && 1 == $nres);
foreach my $chnN($defN,map{$defs{$defN}{$_}}grep(/^channel_/,keys %{$defs{$defN}})){ foreach my $chnN($defN,map{$defs{$defN}{$_}}grep(/^channel_/,keys %{$defs{$defN}})){
(undef, $nres) = CUL_HM_Set($defs{$chnN},$chnN,"statusRequest"); # noansi: fix warnings (undef, $nres) = CUL_HM_Set($defs{$chnN},$chnN,"statusRequest");
return 1 if (defined($nres) && 1 == $nres); return 1 if (defined($nres) && 1 == $nres);
} }
if (CUL_HM_SearchCmd($defN,"getSerial")){
CUL_HM_Set($defs{$defN},$defN,"getSerial");
return 1;
}
return 0; return 0;
} }
@ -9422,7 +9426,6 @@ sub CUL_HM_ActAdd($$) {# add an HMid to list for activity supervision
$actHash->{helper}{$devId}{start} =~ s/[\:\-\ ]//g; $actHash->{helper}{$devId}{start} =~ s/[\:\-\ ]//g;
if(defined $devHash->{READINGS}{".protLastRcv"}){ if(defined $devHash->{READINGS}{".protLastRcv"}){
my $x = $devHash->{READINGS}{".protLastRcv"}{VAL};
$devHash->{READINGS}{".protLastRcv"}{VAL} =~ s/[\:\-\ ]//g; $devHash->{READINGS}{".protLastRcv"}{VAL} =~ s/[\:\-\ ]//g;
} }
@ -9492,19 +9495,15 @@ sub CUL_HM_ActCheck($) {# perform supervision
if ($actHash->{helper}{$devId}{start} < $tSince){ if ($actHash->{helper}{$devId}{start} < $tSince){
if($autoTry) { #try to send a statusRequest? if($autoTry) { #try to send a statusRequest?
my $try = $actHash->{helper}{$devId}{try} ? $actHash->{helper}{$devId}{try} : 0; my $try = $actHash->{helper}{$devId}{try} ? $actHash->{helper}{$devId}{try} : 0;
$actHash->{helper}{$devId}{try} = $try + 1; $actHash->{helper}{$devId}{try} = $try + 1;
if ($try < 4 || !($try % 4)){#try 3 times, then reduce speed if ($try < 4 || !($try % 4)){#try 3 times, then reduce speed
if (CUL_HM_qStateUpdatIfEnab($devName,1)){ if (CUL_HM_Ping($devName)){
$state = $oldState eq "unset" ? "unknown"
: $oldState;
}
elsif (CUL_HM_SearchCmd($devName,"getSerial")){
CUL_HM_Set($defs{$devName},$devName,"getSerial");
$state = $oldState eq "unset" ? "unknown" $state = $oldState eq "unset" ? "unknown"
: $oldState; : $oldState;
} }
else{ else{
$actHash->{helper}{$devId}{try} = 99; $actHash->{helper}{$devId}{try} = 98;
$state = "dead"; $state = "dead";
} }
} }
@ -9570,19 +9569,11 @@ sub CUL_HM_ActInfo() {# print detailed status information
my (undef,$tSec)=CUL_HM_time2sec($attr{$devName}{actCycle}); my (undef,$tSec)=CUL_HM_time2sec($attr{$devName}{actCycle});
if ($tSec != 0){ if ($tSec != 0){
my $tLast = ReadingsVal($devName,".protLastRcv","00000000000000"); my $tLast = ReadingsVal($devName,".protLastRcv","00000000000000");
my $x; my ($Y,$M,$D,$H,$M,$S) = unpack 'A4A2A2A2A2A2',$tLast;
if($tLast =~ m/(\d+)-(\d+)-(\d+) (\d+):(\d+):(\d+)/){
$tLast =~ /(\d+)-(\d+)-(\d+) (\d+):(\d+):(\d+)/ ;
$x = $2*30*24*3600 + $3*24*3600 + $4*3600 + $5*60 +$6;
}
else{
$tLast =~ /(....)(..)(..)(..)(..)(..)/ ;
$x = $2*30*24*3600 + $3*24*3600 + $4*3600 + $5*60 +$6;
}
my @t = localtime($tod - $tSec); #time since when a trigger is expected my @t = localtime($tod - $tSec); #time since when a trigger is expected
my $y = $x - my $y = $M*30*24*3600 + $D*24*3600 + $H*3600 + $M*60 +$S -
(( $t[4]+1)*30*24*3600 (( $t[4]+1)*30*24*3600
+ $t[3]*24*3600 + $t[3]*24*3600
+ $t[2]*3600 + $t[2]*3600
@ -10092,7 +10083,7 @@ sub CUL_HM_procQs($){#process non-wakeup queues
last; last;
} }
} }
next if(!defined $devN);# no device found next if(!defined $devN);# no device found for this queue
my $dq = $devH->{helper}{q}; my $dq = $devH->{helper}{q};
my @chns = split(",",$dq->{$q}); my @chns = split(",",$dq->{$q});
@ -10109,10 +10100,12 @@ sub CUL_HM_procQs($){#process non-wakeup queues
CUL_HM_Set($defs{$eN},$eN,"getConfig"); CUL_HM_Set($defs{$eN},$eN,"getConfig");
} }
else{ else{
if (!CUL_HM_getAttrInt($eN,"ignore")){
CUL_HM_Set($defs{$eN},$eN,"statusRequest"); CUL_HM_Set($defs{$eN},$eN,"statusRequest");
CUL_HM_unQEntity($eN,"qReqStat") if (!$dq->{$q});
InternalTimer(gettimeofday()+20,"CUL_HM_readStateTo","sUpdt:$eN",0); InternalTimer(gettimeofday()+20,"CUL_HM_readStateTo","sUpdt:$eN",0);
} }
CUL_HM_unQEntity($eN,"qReqStat") if (!$dq->{$q});
}
$Qexec = $q; $Qexec = $q;
last; # execute only one! last; # execute only one!
} }