2
0
mirror of https://github.com/fhem/fhem-mirror.git synced 2025-04-20 01:06:04 +00:00

10_CUL_HM:bug in update readings

git-svn-id: https://svn.fhem.de/fhem/trunk@8548 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
martinp876 2015-05-09 08:46:46 +00:00
parent c9b9f4c6ff
commit 8a104c5a53
2 changed files with 1463 additions and 1401 deletions

View File

@ -1005,6 +1005,7 @@ sub CUL_HM_Parse($$) {#########################################################
# return "" if($src eq $id);# mirrored messages - covered by !$shash # return "" if($src eq $id);# mirrored messages - covered by !$shash
if(!$shash){ # Unknown source if(!$shash){ # Unknown source
$evtDly = 0;# switch delay trigger off
return "" if ($msg =~ m/998112......000001/);# HMLAN internal message, consum return "" if ($msg =~ m/998112......000001/);# HMLAN internal message, consum
my $ccu =InternalVal($ioName,"owner_CCU",""); my $ccu =InternalVal($ioName,"owner_CCU","");
CUL_HM_DumpProtocol("RCV",$iohash,$len,$mNo,$mFlg,$mTp,$src,$dst,$p); CUL_HM_DumpProtocol("RCV",$iohash,$len,$mNo,$mFlg,$mTp,$src,$dst,$p);
@ -1020,7 +1021,6 @@ sub CUL_HM_Parse($$) {#########################################################
my $ioId = CUL_HM_h2IoId($devH->{IODev}); my $ioId = CUL_HM_h2IoId($devH->{IODev});
$ioId = $id if(!$ioId); $ioId = $id if(!$ioId);
if (CUL_HM_getAttrInt($name,"ignore")){ if (CUL_HM_getAttrInt($name,"ignore")){
CUL_HM_pushEvnts();
$defs{$_}{".noDispatchVars"} = 1 foreach (grep !/^$devH->{NAME}$/,@entities); $defs{$_}{".noDispatchVars"} = 1 foreach (grep !/^$devH->{NAME}$/,@entities);
return (CUL_HM_pushEvnts(),$name,@entities); return (CUL_HM_pushEvnts(),$name,@entities);
} }
@ -2408,7 +2408,6 @@ sub CUL_HM_Parse($$) {#########################################################
#------------ process events ------------------ #------------ process events ------------------
push @evtEt,[$shash,1,"noReceiver:src:$src ".$mFlg.$mTp." $p"] push @evtEt,[$shash,1,"noReceiver:src:$src ".$mFlg.$mTp." $p"]
if(!@entities && !@evtEt); if(!@entities && !@evtEt);
push @entities,CUL_HM_pushEvnts(); push @entities,CUL_HM_pushEvnts();
@entities = CUL_HM_noDup(@entities,$shash->{NAME}); @entities = CUL_HM_noDup(@entities,$shash->{NAME});
$defs{$_}{".noDispatchVars"} = 1 foreach (grep !/^$devH->{NAME}$/,@entities); $defs{$_}{".noDispatchVars"} = 1 foreach (grep !/^$devH->{NAME}$/,@entities);
@ -2979,9 +2978,9 @@ sub CUL_HM_updtSDTeam(@){#in: TeamName, optional caller name and its new state
sub CUL_HM_pushEvnts(){######################################################## sub CUL_HM_pushEvnts(){########################################################
#write events to Readings and collect touched devices #write events to Readings and collect touched devices
my @ent = (); my @ent = ();
$evtDly = 0;# switch delay trigger off
if (scalar(@evtEt) > 0){ if (scalar(@evtEt) > 0){
@evtEt = sort {($a->[0] cmp $b->[0])|| ($a->[1] cmp $b->[1])} @evtEt; @evtEt = sort {($a->[0] cmp $b->[0])|| ($a->[1] cmp $b->[1])} @evtEt;
$evtDly = 0;# switch delay trigger off
my ($h,$x) = ("",""); my ($h,$x) = ("","");
my @evts = (); my @evts = ();
foreach my $e(@evtEt){ foreach my $e(@evtEt){
@ -3260,6 +3259,9 @@ sub CUL_HM_Get($@) {#+++++++++++++++++ get command+++++++++++++++++++++++++++++
} }
} }
} }
elsif($cmd eq "info"){ ###############################################
return CUL_HM_ActInfo();
}
Log3 $name,3,"CUL_HM get $name " . join(" ", @a[1..$#a]); Log3 $name,3,"CUL_HM get $name " . join(" ", @a[1..$#a]);
@ -4478,15 +4480,19 @@ sub CUL_HM_Set($@) {#+++++++++++++++++ set command+++++++++++++++++++++++++++++
} }
CUL_HM_UpdtCentral($name) if ($md eq "CCU_FHEM"); CUL_HM_UpdtCentral($name) if ($md eq "CCU_FHEM");
} }
elsif($cmd eq "update") { ################################################## elsif($cmd eq "update") { ###################################################
$state = ""; $state = "";
if ($md eq "ActionDetector"){
CUL_HM_ActCheck("ActionDetector");
}
else{
CUL_HM_UpdtCentral($name); CUL_HM_UpdtCentral($name);
} }
}
elsif($cmd eq "press") { #################################################### elsif($cmd eq "press") { ####################################################
# [long|short] [<peer>] [<repCount(long only)>] [<repDelay>] [<forceTiming[0|1]>] ... # [long|short] [<peer>] [<repCount(long only)>] [<repDelay>] [<forceTiming[0|1]>] ...
my $mode = 0; my ($repCnt,$repDly,$forceTiming,$mode) = (0,0,0,0);
my ($repCnt,$repDly,$forceTiming) = (0,0,0);
if ($a[2]){ if ($a[2]){
############################## ##############################
if ($a[2] eq "long"){ if ($a[2] eq "long"){
@ -4565,7 +4571,7 @@ sub CUL_HM_Set($@) {#+++++++++++++++++ set command+++++++++++++++++++++++++++++
$id,$dst,$pDev, $id,$dst,$pDev,
hex($pCh)+$mode, hex($pCh)+$mode,
$pressCnt); $pressCnt);
for (my $cnt = 0;$cnt < $repCnt; $cnt++ ){ for (my $cnt = 1;$cnt < $repCnt; $cnt++ ){
CUL_HM_SndCmd($hash, "++80$msg"); CUL_HM_SndCmd($hash, "++80$msg");
select(undef, undef, undef, $repDly); select(undef, undef, undef, $repDly);
} }
@ -7068,9 +7074,65 @@ sub CUL_HM_ActCheck($) {# perform supervision
CUL_HM_UpdtReadBulk($actHash,1,@event); CUL_HM_UpdtReadBulk($actHash,1,@event);
$actHash->{helper}{actCycle} = AttrVal($actName,"actCycle",600); $actHash->{helper}{actCycle} = AttrVal($actName,"actCycle",600);
RemoveInternalTimer("ActionDetector");
InternalTimer(gettimeofday()+$actHash->{helper}{actCycle} InternalTimer(gettimeofday()+$actHash->{helper}{actCycle}
,"CUL_HM_ActCheck", "ActionDetector", 0); ,"CUL_HM_ActCheck", "ActionDetector", 0);
} }
sub CUL_HM_ActInfo() {# print detailed status information
my $actHash = CUL_HM_ActGetCreateHash();
my $tod = int(gettimeofday());
my $peerIDs = $actHash->{helper}{peers}?$actHash->{helper}{peers}:"";
my @info;
foreach my $devId (split(",",$peerIDs)){
next if (!$devId);
my $devName = CUL_HM_id2Name($devId);
next if(!$devName || !defined($attr{$devName}{actCycle}));
next if(AttrVal($devName,"ignore",0));
my $state;
my (undef,$tSec)=CUL_HM_time2sec($attr{$devName}{actCycle});
if ($state ne "switchedOff"){
my $tLast = ReadingsVal($devName,".protLastRcv",0);
$tLast =~ /(\d+)-(\d+)-(\d+) (\d+):(\d+):(\d+)/;
my $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 $y = $x -
(( $t[4]+1)*30*24*3600
+ $t[3]*24*3600
+ $t[2]*3600
+ $t[1]*60
+ $t[0]);
my $sign = "next ";
if ($y < 0){
$sign = "late -";
$y *= -1;
}
my @c;
$c[1] = int($y/3600);$y -= $c[1] * 3600;
$c[0] = int($y/60) ;$y -= $c[0] * 60;
$state .= sprintf("%-8s %s %s %3d:%02d:%02d %s"
,ReadingsVal($devName,"Activity","")
,$tLast,$sign,$c[1],$c[0],$y
,$devName);
}
else{
$state = sprintf ("%-8s :%30s : "
,ReadingsVal($devName,"Activity","")
,$devName);
}
push @info,$state;
}
return sprintf ("%-8s %-19s %s %s\n\n","state"
,"last"
,"next h:mm:ss"
,"name").
join("\n", sort @info);
}
#+++++++++++++++++ helper +++++++++++++++++++++++++++++++++++++++++++++++++++++ #+++++++++++++++++ helper +++++++++++++++++++++++++++++++++++++++++++++++++++++
sub CUL_HM_UpdtReadBulk(@) { #update a bunch of readings and trigger the events sub CUL_HM_UpdtReadBulk(@) { #update a bunch of readings and trigger the events
@ -7752,15 +7814,11 @@ sub CUL_HM_tempListTmpl(@) { ##################################################
=pod =pod
=begin html =begin html
<a name="CUL_HM"></a> <a name="CUL_HM"></a><h3>CUL_HM</h3>
<h3>CUL_HM</h3>
<ul> <ul>
Support for eQ-3 HomeMatic devices via the <a href="#CUL">CUL</a> or the <a Support for eQ-3 HomeMatic devices via the <a href="#CUL">CUL</a> or the <a href="#HMLAN">HMLAN</a>.<br>
href="#HMLAN">HMLAN</a>.<br>
<br> <br>
<a name="CUL_HMdefine"></a> <a name="CUL_HMdefine"></a><b>Define</b>
<b>Define</b>
<ul> <ul>
<code><B>define &lt;name&gt; CUL_HM &lt;6-digit-hex-code|8-digit-hex-code&gt;</B></code> <code><B>define &lt;name&gt; CUL_HM &lt;6-digit-hex-code|8-digit-hex-code&gt;</B></code>
@ -7868,13 +7926,11 @@ sub CUL_HM_tempListTmpl(@) { ##################################################
</li> </li>
</ul> </ul>
</ul><br> </ul><br>
<a name="CUL_HMset"></a><b>Set</b> <a name="CUL_HMset"></a><b>Set</b>
<ul> <ul>
Note: devices which are normally send-only (remote/sensor/etc) must be set Note: devices which are normally send-only (remote/sensor/etc) must be set
into pairing/learning mode in order to receive the following commands. into pairing/learning mode in order to receive the following commands.
<br> <br><br>
<br>
Universal commands (available to most hm devices): Universal commands (available to most hm devices):
<ul> <ul>
@ -8023,7 +8079,8 @@ sub CUL_HM_tempListTmpl(@) { ##################################################
set myblind regBulk 01 0B:10<br> set myblind regBulk 01 0B:10<br>
set myblind regBulk 01 0C:00<br> set myblind regBulk 01 0C:00<br>
</code></ul> </code></ul>
myblind will set the max drive time up for a blind actor to 25,6sec</li> myblind will set the max drive time up for a blind actor to 25,6sec
</li>
<li><B>regSet [prep|exec] &lt;regName&gt; &lt;value&gt; &lt;peerChannel&gt;</B><a name="CUL_HMregSet"></a><br> <li><B>regSet [prep|exec] &lt;regName&gt; &lt;value&gt; &lt;peerChannel&gt;</B><a name="CUL_HMregSet"></a><br>
For some major register a readable version is implemented supporting For some major register a readable version is implemented supporting
register names &lt;regName&gt; and value conversionsing. Only a subset register names &lt;regName&gt; and value conversionsing. Only a subset
@ -8242,19 +8299,17 @@ sub CUL_HM_tempListTmpl(@) { ##################################################
Defaults to both.<br> Defaults to both.<br>
Example: Example:
<ul> <ul><code>
<code>
set myRemote peerChan 2 mySwActChn single set #peer second button to an actuator channel<br> set myRemote peerChan 2 mySwActChn single set #peer second button to an actuator channel<br>
set myRmtBtn peerChan 0 mySwActChn single set #myRmtBtn is a button of the remote. '0' is not processed here<br> set myRmtBtn peerChan 0 mySwActChn single set #myRmtBtn is a button of the remote. '0' is not processed here<br>
set myRemote peerChan 2 mySwActChn dual set #peer button 3 and 4<br> set myRemote peerChan 2 mySwActChn dual set #peer button 3 and 4<br>
set myRemote peerChan 3 mySwActChn dual unset #remove peering for button 5 and 6<br> set myRemote peerChan 3 mySwActChn dual unset #remove peering for button 5 and 6<br>
set myRemote peerChan 3 mySwActChn dual unset aktor #remove peering for button 5 and 6 in actor only<br> set myRemote peerChan 3 mySwActChn dual unset aktor #remove peering for button 5 and 6 in actor only<br>
set myRemote peerChan 3 mySwActChn dual set remote #peer button 5 and 6 on remote only. Link settings il mySwActChn will be maintained<br> set myRemote peerChan 3 mySwActChn dual set remote #peer button 5 and 6 on remote only. Link settings il mySwActChn will be maintained<br>
</code> </code></ul>
</ul> </li>
</li> </li>
</ul> </ul>
</li>
<li>virtual<a name="CUL_HMvirtual"></a><br> <li>virtual<a name="CUL_HMvirtual"></a><br>
<ul> <ul>
<li><B><a href="#CUL_HMpeerChan">peerChan</a></B> see remote</li> <li><B><a href="#CUL_HMpeerChan">peerChan</a></B> see remote</li>
@ -8262,14 +8317,10 @@ sub CUL_HM_tempListTmpl(@) { ##################################################
<ul> <ul>
simulates button press for an actor from a peered sensor. simulates button press for an actor from a peered sensor.
will be sent of type "long". will be sent of type "long".
<li>[long|short] defines whether long or short press shall be simulated. Defaults to short <li>[long|short] defines whether long or short press shall be simulated. Defaults to short</li>
</li> <li>[&lt;peer&gt;] define which peer's trigger shall be simulated.Defaults to self(channelNo).</li>
<li>[&lt;peer&gt;] define which peer's trigger shall be simulated.Defaults to self(channelNo). <li>[&lt;repCount&gt;] Valid for long press only. How long shall the button be pressed? Number of repetition of the messages is defined. Defaults to 1</li>
</li> <li>[&lt;repDelay&gt;] Valid for long press only. defines wait time between the single messages. </li>
<li>[&lt;repCount&gt;] Valid for long press only. How long shall the button be pressed? Number of repetition of the messages is defined. Defaults to 1
</li>
<li>[&lt;repDelay&gt;] Valid for long press only. defines wait time between the single messages.
</li>
</ul> </ul>
</li> </li>
<li><B>virtTemp &lt;[off -10..50]&gt;<a name="CUL_HMvirtTemp"></a></B> <li><B>virtTemp &lt;[off -10..50]&gt;<a name="CUL_HMvirtTemp"></a></B>
@ -8310,14 +8361,12 @@ sub CUL_HM_tempListTmpl(@) { ##################################################
If used on a channel btn_no and on|off must not be given but only pure text.<br> If used on a channel btn_no and on|off must not be given but only pure text.<br>
\_ will be replaced by blank character.<br> \_ will be replaced by blank character.<br>
Example: Example:
<ul> <ul><code>
<code>
set 4Dis text 1 on On Lamp<br> set 4Dis text 1 on On Lamp<br>
set 4Dis text 1 off Kitchen Off<br> set 4Dis text 1 off Kitchen Off<br>
<br> <br>
set 4Dis_chn4 text Kitchen Off<br> set 4Dis_chn4 text Kitchen Off<br>
</code> </code></ul>
</ul>
</li> </li>
</ul> </ul>
<br></li> <br></li>
@ -8376,7 +8425,6 @@ sub CUL_HM_tempListTmpl(@) { ##################################################
set time in climate channel to system time</li> set time in climate channel to system time</li>
</ul><br> </ul><br>
</li> </li>
<li>Climate-Control (HM-CC-RT-DN|HM-CC-RT-DN-BoM) <li>Climate-Control (HM-CC-RT-DN|HM-CC-RT-DN-BoM)
<ul> <ul>
<li><B>fwUpdate &lt;filename&gt; [&lt;waitTime&gt;] </B><br> <li><B>fwUpdate &lt;filename&gt; [&lt;waitTime&gt;] </B><br>
@ -8603,7 +8651,8 @@ sub CUL_HM_tempListTmpl(@) { ##################################################
immediately sent, the next one after the previous one is acked by immediately sent, the next one after the previous one is acked by
the target. The length will be computed automatically, and the the target. The length will be computed automatically, and the
message counter will be incremented if the first two charcters are message counter will be incremented if the first two charcters are
++. Example (enable AES):<pre> ++. Example (enable AES):
<pre>
set hm1 raw ++A001F100001234560105000000001\ set hm1 raw ++A001F100001234560105000000001\
++A001F10000123456010802010AF10B000C00\ ++A001F10000123456010802010AF10B000C00\
++A001F1000012345601080801\ ++A001F1000012345601080801\
@ -8699,6 +8748,12 @@ sub CUL_HM_tempListTmpl(@) { ##################################################
</li> </li>
</ul> </ul>
</li> </li>
<li><B>info</B><br>
<ul>
<li>provides information about entities using ActionDetector<br>
</li>
</ul>
</li>
</ul><br> </ul><br>
<a name="CUL_HMattr"></a><b>Attributes</b> <a name="CUL_HMattr"></a><b>Attributes</b>
@ -9809,7 +9864,6 @@ sub CUL_HM_tempListTmpl(@) { ##################################################
</li> </li>
</ul><br> </ul><br>
</li> </li>
<li>keyMatic<br><br> <li>keyMatic<br><br>
<ul>Keymatic verwendet eine AES-signierte Kommunikation. Deshalb ist die Steuerung von Keymatic <ul>Keymatic verwendet eine AES-signierte Kommunikation. Deshalb ist die Steuerung von Keymatic
nur mit dem HM-LAN m&ouml;glich. But nur mit dem HM-LAN m&ouml;glich. But
@ -9850,7 +9904,6 @@ sub CUL_HM_tempListTmpl(@) { ##################################################
</li> </li>
</ul> </ul>
</li> </li>
<br>
<li>HM-Sys-sRP-Pl<br> <li>HM-Sys-sRP-Pl<br>
legt Eintr&auml;ge f&uuml;r den Repeater an. Bis zu 36 Eintr&auml;ge k&ouml;nnen angelegt werden. legt Eintr&auml;ge f&uuml;r den Repeater an. Bis zu 36 Eintr&auml;ge k&ouml;nnen angelegt werden.
<ul> <ul>
@ -10152,8 +10205,7 @@ sub CUL_HM_tempListTmpl(@) { ##################################################
ACHTUNG: Die Anpassung betrifft nur Readings und Kommandos. <B>Register sind nicht betroffen.</B><br> ACHTUNG: Die Anpassung betrifft nur Readings und Kommandos. <B>Register sind nicht betroffen.</B><br>
</li> </li>
</ul><br> </ul><br>
<a name="CUL_HMevents"></a> <a name="CUL_HMevents"><b>Erzeugte Events:</b></a>
<b>Erzeugte Events:</b>
<ul> <ul>
<li><B>Allgemein</B><br> <li><B>Allgemein</B><br>
recentStateType:[ack|info] # kann nicht verwendet werden um Nachrichten zu triggern<br> recentStateType:[ack|info] # kann nicht verwendet werden um Nachrichten zu triggern<br>
@ -10371,6 +10423,12 @@ sub CUL_HM_tempListTmpl(@) { ##################################################
[unlocked|locked|uncertain]<br> [unlocked|locked|uncertain]<br>
</li> </li>
</ul> </ul>
<a name="CUL_HMinternals"><b>Internals</b></a>
<ul>
<li><B>aesCommToDev</B><br>
Information über Erfolg und Fehler der AES Kommunikation zwischen IO-device und HM-Device<br>
</li>
</ul><br>
<br> <br>
</ul> </ul>
=end html =end html

View File

@ -1354,7 +1354,9 @@ $culHmRegChan{"ROTO_ZEL-STG-RM-FWT03"}= $culHmRegChan{"HM-CC-TC03"};
); );
%culHmModelGets = ( %culHmModelGets = (
"CCU-FHEM" =>{ "listDevice"=>"" }, "CCU-FHEM" =>{ "listDevice"=>"" },
ActionDetector =>{ "listDevice"=>"[all|alive|unknown|dead|notAlive] ..." }, ActionDetector =>{ "listDevice"=>"[all|alive|unknown|dead|notAlive] ..."
,"info" =>""
},
); );
##############################---set---######################################## ##############################---set---########################################
@ -1492,7 +1494,9 @@ $culHmSubTypeSets{motionDetector} = $culHmSubTypeSets{threeStateSensor};
} }
,"HM-TC-IT-WM-W-EU" =>{ inhibit =>"[on|off]"} ,"HM-TC-IT-WM-W-EU" =>{ inhibit =>"[on|off]"}
,"HM-SEC-SD" =>{ statusRequest =>""} ,"HM-SEC-SD" =>{ statusRequest =>""}
,"ActionDetector" =>{ clear => "[readings|all]"} ,"ActionDetector" =>{ clear => "[readings|all]"
,update => ""
}
); );
# clones- - - - - - - - - - - - - - - - - # clones- - - - - - - - - - - - - - - - -
$culHmModelSets{"HM-CC-RT-DN-BoM"} = $culHmModelSets{"HM-CC-RT-DN"}; $culHmModelSets{"HM-CC-RT-DN-BoM"} = $culHmModelSets{"HM-CC-RT-DN"};