From 734754ee6f485b3ad4e54eff72563258388344c9 Mon Sep 17 00:00:00 2001 From: martinp876 <> Date: Sat, 31 Oct 2015 16:33:48 +0000 Subject: [PATCH] HMinfo: template enhacement git-svn-id: https://svn.fhem.de/fhem/trunk@9737 2b470e98-0d58-463d-a4d8-8e2adae1ed80 --- fhem/FHEM/10_CUL_HM.pm | 14 +++--- fhem/FHEM/98_HMinfo.pm | 107 ++++++++++++++++++++--------------------- fhem/FHEM/HMConfig.pm | 1 + 3 files changed, 61 insertions(+), 61 deletions(-) diff --git a/fhem/FHEM/10_CUL_HM.pm b/fhem/FHEM/10_CUL_HM.pm index b81b9881f..a20823954 100755 --- a/fhem/FHEM/10_CUL_HM.pm +++ b/fhem/FHEM/10_CUL_HM.pm @@ -246,8 +246,9 @@ sub CUL_HM_updateConfig($){ my $chn = substr($id."00",6,2); my $st = CUL_HM_Get($hash,$name,"param","subType"); my $md = CUL_HM_Get($hash,$name,"param","model"); - - $hash->{helper}{role}{prs} = 1 if(CUL_HM_Set($hash,$name,"?") =~ m /press/ && $st ne "virtual"); + + my $dHash = CUL_HM_getDeviceHash($hash); + $dHash->{helper}{role}{prs} = 1 if(CUL_HM_Set($hash,$name,"?") =~ m /press/ && $st ne "virtual"); foreach my $rName ("D-firmware","D-serialNr",".D-devInfo",".D-stc"){ # move certain attributes to readings for future handling my $aName = $rName; @@ -4561,7 +4562,8 @@ sub CUL_HM_Set($@) {#+++++++++++++++++ set command+++++++++++++++++++++++++++++ return "invalid temp:$a[2]" if($temp <9 ||$temp > 61); $temp = sprintf ("%02X",$temp); CUL_HM_PushCmdStack($hash,'++'.$flag."11$id$dst"."8604$temp"); - foreach my $team ( split(",",InternalVal(CUL_HM_id2Name($dst."05"),"peerList","")) + my $idTch = ($md =~ m/HM-CC-RT-DN/ ? $dst."05" : $dst."02"); + foreach my $team ( split(",",InternalVal(CUL_HM_id2Name($idTch),"peerList","")) ,$name){ next if (!defined $defs{$team} ); my $tId = substr(CUL_HM_name2Id($team),0,6); @@ -4870,7 +4872,7 @@ sub CUL_HM_Set($@) {#+++++++++++++++++ set command+++++++++++++++++++++++++++++ } } if(!$snd){# send 2 broadcast if no relevant peers - CUL_HM_PushCmdStack($hash,"++8440${dst}000000$pc"); + CUL_HM_SndCmd($hash,"++8440${dst}000000$pc"); } } else{#serve internal channels for actor @@ -4896,10 +4898,10 @@ sub CUL_HM_Set($@) {#+++++++++++++++++ set command+++++++++++++++++++++++++++++ hex($pCh)+$mode, $pressCnt); for (my $cnt = 1;$cnt < $repCnt; $cnt++ ){ - CUL_HM_SndCmd($hash, "++80$msg"); + CUL_HM_SndCmd($hash, "++80$msg"); # send direct Wont work for burst! select(undef, undef, undef, $repDly); } - CUL_HM_SndCmd($hash, "++${flag}$msg"); + CUL_HM_PushCmdStack($hash, "++${flag}$msg"); # send thru commandstack } } elsif($cmd eq "fwUpdate") { ################################################# diff --git a/fhem/FHEM/98_HMinfo.pm b/fhem/FHEM/98_HMinfo.pm index e5e288e35..b8f5828af 100644 --- a/fhem/FHEM/98_HMinfo.pm +++ b/fhem/FHEM/98_HMinfo.pm @@ -1931,16 +1931,21 @@ sub HMinfo_templateDef(@){##################################################### foreach my $rdN (grep !/^\.?R-.*-(sh|lg)/,grep /^\.?R-/,keys %{$defs{$master}{READINGS}}){ my $rdP = $rdN; $rdP =~ s/^\.?R-//; - push @regs,"$rdP:$defs{$master}{READINGS}{$rdN}{VAL}"; + my ($val) = map{s/ .*//;$_;}$defs{$master}{READINGS}{$rdN}{VAL}; + push @regs,"$rdP:$val"; } } else{ my ($peer,$shlg) = split(":",$pl,2); - $shlg = ($shlg eq "short"?"sh":($shlg eq "long"?"lg":"")); + return "peersegment not allowed. use :(both|short|long)" if($shlg != m/(short|long|both)/); + $shlg = ($shlg eq "short"?"sh" + :($shlg eq "long" ?"lg" + :"")); foreach my $rdN (grep /^\.?R-$peer-$shlg/,keys %{$defs{$master}{READINGS}}){ my $rdP = $rdN; $rdP =~ s/^\.?R-$peer-$shlg//; - push @regs,"$rdP:$defs{$master}{READINGS}{$rdN}{VAL}"; + my ($val) = map{s/ .*//;$_;}$defs{$master}{READINGS}{$rdN}{VAL}; + push @regs,"$rdP:$val"; } } $param = "0"; @@ -1979,9 +1984,11 @@ sub HMinfo_templateDef(@){##################################################### delete $HMConfig::culHmTpl{$name}; return " empty reg value for $r"; } - elsif($v =~ m/^p(.)/){ - return ($1+1)." params are necessary, only $paramNo given" - if (($1+1)>$paramNo); + elsif($v =~ m/^p(\d)/){ + if (($1+1)>$paramNo){ + delete $HMConfig::culHmTpl{$name}; + return ($1+1)." params are necessary, only $paramNo given"; + } } $HMConfig::culHmTpl{$name}{reg}{$r} = $v; } @@ -1995,8 +2002,11 @@ sub HMinfo_templateSet(@){##################################################### my $tmplID = "$pSet>$tmpl"; $pSet = ":" if (!$pSet || $pSet eq "none"); my ($pName,$pTyp) = split(":",$pSet); - return "give :[short|long] with peer, not $pSet" if($pName && $pTyp !~ m/(short|long)/); - $pSet = $pTyp ? ($pTyp eq "long"?"lg":"sh"):""; + return "give :[short|long|both] with peer, not $pSet $pName,$pTyp" if($pName && $pTyp !~ m/(short|long|both)/); + $pSet = $pTyp ? ($pTyp eq "long" ?"lg" + :($pTyp eq "short"?"sh" + :"")) # could be "both" + :""; my $aHash = $defs{$aName}; my @regCh; @@ -2074,61 +2084,48 @@ sub HMinfo_templateUsg(@){##################################################### } sub HMinfo_templateChk(@){##################################################### my ($aName,$tmpl,$pSet,@p) = @_; - $pSet = ":" if (!$pSet || $pSet eq "none"); - my ($pName,$pTyp) = split(":",$pSet); + # pset: 0 = template w/o peers + # peer / peer:both = template for peer, not extending Long/short + # peer:short|long = template for peerlong or short + return "template undefined $tmpl\n" if(!$HMConfig::culHmTpl{$tmpl}); return "aktor $aName unknown\n" if(!$defs{$aName}); - return "give :[short|long|all] wrong:$pTyp\n" if($pTyp && $pTyp !~ m/(short|long|all)/); - - my @pNames; - if ($pName eq "all"){ - my $dId = substr(CUL_HM_name2Id($aName),0,6); - foreach (grep !/00000000/,split(",",AttrVal($aName,"peerIDs",""))){ - push @pNames,CUL_HM_peerChName($_,$dId).":long" if (!$pTyp || $pTyp ne "short"); - push @pNames,CUL_HM_peerChName($_,$dId).":short" if (!$pTyp || $pTyp ne "long"); - } - } - elsif(($pName && !$pTyp) || $pTyp eq "all"){ - push @pNames,$pName.":long"; - push @pNames,$pName.":short"; + return "give :[short|long|both] wrong:$pSet\n" if($pSet && $pSet !~ m/:(short|long|both)$/); + $pSet = "0:0" if (!$pSet); + + my $repl = ""; + my($pName,$pTyp) = split(":",$pSet); + if($pName && (grep !/$pName/,ReadingsVal($aName,"peerList" ,""))){ + $repl = " no peer:$pName\n"; } else{ - push @pNames,$pSet; - } - - my $repl = ""; - foreach my $pS (@pNames){ - ($pName,$pTyp) = split(":",$pS); - my $replPeer=""; - if($pName && (grep !/$pName/,ReadingsVal($aName,"peerList" ,""))){ - $replPeer=" no peer:$pName\n"; - } - else{ - my $pRnm = $pName?($pName."-".($pTyp eq "long"?"lg":"sh")):""; - foreach my $rn (keys%{$HMConfig::culHmTpl{$tmpl}{reg}}){ - my $regV; - if ($pRnm){ - $regV = ReadingsVal($aName,"R-$pRnm$rn" ,ReadingsVal($aName,".R-$pRnm$rn",undef)); - } - $regV = ReadingsVal($aName,"R-".$rn ,ReadingsVal($aName,".R-".$rn ,undef)) if (!defined $regV); - if (defined $regV){ - $regV =~s/ .*//;#strip unit - my $tplV = $HMConfig::culHmTpl{$tmpl}{reg}{$rn}; - if ($tplV =~m /^p(.)$/) {#replace with User parameter - return "insufficient data - at least ".$HMConfig::culHmTpl{p}." are $1 necessary" - if (@p < ($1+1)); - $tplV = $p[$1]; - } - $replPeer .= " $rn :$regV should $tplV \n" if ($regV ne $tplV); - } - else{ - $replPeer .= " reg not found: $rn\n"; + my $pRnm = $pName ? $pName."-" : ""; + my $pRnmLS = $pTyp eq "long"?"lg":($pTyp eq "short"?"sh":""); + foreach my $rn (keys%{$HMConfig::culHmTpl{$tmpl}{reg}}){ + my $regV; + my $pRnmChk = $pRnm.($rn !~ m/^(lg|sh)/ ? $pRnmLS :""); + if ($pRnm){ + $regV = ReadingsVal($aName,"R-$pRnmChk$rn" ,ReadingsVal($aName,".R-$pRnmChk$rn",undef)); + } + $regV = ReadingsVal($aName,"R-".$rn ,ReadingsVal($aName,".R-".$rn ,undef)) if (!defined $regV); + if (defined $regV){ + $regV =~s/ .*//;#strip unit + my $tplV = $HMConfig::culHmTpl{$tmpl}{reg}{$rn}; + if ($tplV =~m /^p(.)$/) {#replace with User parameter + return "insufficient data - at least ".$HMConfig::culHmTpl{p}." are $1 necessary" + if (@p < ($1+1)); + $tplV = $p[$1]; } + $repl .= " $rn :$regV should $tplV \n" if ($regV ne $tplV); + } + else{ + $repl .= " reg not found: $rn :$pRnm\n"; } } - $repl .= "$aName $pS-> failed\n$replPeer" if($replPeer); } - return ($repl?$repl:""); + $repl .= "$aName $pSet-> failed\n$repl" if($repl); + + return $repl; } sub HMinfo_templateList($){#################################################### my $templ = shift; diff --git a/fhem/FHEM/HMConfig.pm b/fhem/FHEM/HMConfig.pm index 87f1aa517..534215693 100644 --- a/fhem/FHEM/HMConfig.pm +++ b/fhem/FHEM/HMConfig.pm @@ -1698,6 +1698,7 @@ $culHmChanSets{"WDF-solar02"} = $culHmSubTypeSets{blindActuator}; $culHmChanSets{"HM-OU-CM-PCB01"} = $culHmChanSets{"HM-OU-CFM-PL02"}; $culHmChanSets{"HM-CC-RT-DN02"} = $culHmChanSets{"HM-CC-RT-DN00"}; +$culHmChanSets{"HM-CC-RT-DN03"} = $culHmChanSets{"HM-CC-RT-DN06"}; $culHmChanSets{"HM-ES-PMSw1-Pl04"} = $culHmChanSets{"HM-ES-PMSw1-Pl03"}; $culHmChanSets{"HM-ES-PMSw1-Pl05"} = $culHmChanSets{"HM-ES-PMSw1-Pl03"};