mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-04-21 07:56:03 +00:00
change logs for actionDetector, keep peerIDs in action detector, introduce press function, change toggle for switches
git-svn-id: https://svn.fhem.de/fhem/trunk@2738 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
5193b9d643
commit
949dc5dfde
@ -286,13 +286,13 @@ sub CUL_HM_updateConfig($){
|
|||||||
CUL_HM_ActAdd(CUL_HM_hash2Id($hash),$actCycle) if ($actCycle);# re-read start values
|
CUL_HM_ActAdd(CUL_HM_hash2Id($hash),$actCycle) if ($actCycle);# re-read start values
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
delete $attr{$name}{peerIDs}; # remove historical data
|
;#delete $attr{$name}{peerIDs}; # remove historical data
|
||||||
}
|
}
|
||||||
|
|
||||||
# convert variables, delete obsolete, move to hidden level
|
# convert variables, delete obsolete, move to hidden level
|
||||||
$attr{$name}{".devInfo"} = $attr{$name}{devInfo} if ($attr{$name}{devInfo});
|
$attr{$name}{".devInfo"} = $attr{$name}{devInfo} if ($attr{$name}{devInfo});
|
||||||
delete $attr{$name}{devInfo};
|
# delete $attr{$name}{devInfo};
|
||||||
delete $attr{$name}{hmClass};
|
# delete $attr{$name}{hmClass};
|
||||||
|
|
||||||
# add default web-commands
|
# add default web-commands
|
||||||
my $webCmd;
|
my $webCmd;
|
||||||
@ -1611,7 +1611,6 @@ my %culHmRegChan = (# if channelspecific then enter them here
|
|||||||
##--------------- Conversion routines for register settings
|
##--------------- Conversion routines for register settings
|
||||||
my %fltCvT = (0.1=>3.1,1=>31,5=>155,10=>310,60=>1860,300=>9300,
|
my %fltCvT = (0.1=>3.1,1=>31,5=>155,10=>310,60=>1860,300=>9300,
|
||||||
600=>18600,3600=>111600);
|
600=>18600,3600=>111600);
|
||||||
|
|
||||||
sub CUL_HM_Attr(@) {#############################
|
sub CUL_HM_Attr(@) {#############################
|
||||||
my ($cmd,$name, $attrName,$attrVal) = @_;
|
my ($cmd,$name, $attrName,$attrVal) = @_;
|
||||||
my @hashL;
|
my @hashL;
|
||||||
@ -1998,10 +1997,13 @@ my %culHmGlobalSets = (
|
|||||||
);
|
);
|
||||||
my %culHmSubTypeSets = (
|
my %culHmSubTypeSets = (
|
||||||
switch =>{ "on-for-timer"=>"sec", "on-till"=>"time",
|
switch =>{ "on-for-timer"=>"sec", "on-till"=>"time",
|
||||||
on=>"", off=>"", toggle=>"" },
|
on=>"", off=>"", toggle=>"",
|
||||||
|
press => "[long|short] [on|off] ..."},
|
||||||
dimmer =>{ "on-for-timer"=>"sec", "on-till"=>"time",
|
dimmer =>{ "on-for-timer"=>"sec", "on-till"=>"time",
|
||||||
on=>"", off=>"", toggle=>"", pct=>"", stop=>""},
|
on=>"", off=>"", toggle=>"", pct=>"", stop=>"",
|
||||||
blindActuator =>{ on=>"", off=>"", toggle=>"", pct=>"", stop=>""},
|
press => "[long|short] [on|off] ..."},
|
||||||
|
blindActuator =>{ on=>"", off=>"", toggle=>"", pct=>"", stop=>"",
|
||||||
|
press => "[long|short] [on|off] ..."},
|
||||||
remote =>{ devicepair => "<btnNumber> device ... [single|dual] [set|unset] [actor|remote|both]",},
|
remote =>{ devicepair => "<btnNumber> device ... [single|dual] [set|unset] [actor|remote|both]",},
|
||||||
pushButton =>{ devicepair => "<btnNumber> device ... [single|dual] [set|unset] [actor|remote|both]",},
|
pushButton =>{ devicepair => "<btnNumber> device ... [single|dual] [set|unset] [actor|remote|both]",},
|
||||||
threeStateSensor =>{ devicepair => "<btnNumber> device ... single [set|unset] [actor|remote|both]",},
|
threeStateSensor =>{ devicepair => "<btnNumber> device ... single [set|unset] [actor|remote|both]",},
|
||||||
@ -2468,17 +2470,9 @@ sub CUL_HM_Set($@) {
|
|||||||
CUL_HM_PushCmdStack($hash,'++'.$flag.'11'.$id.$dst.'02'.$chn.'C80000'.$tval);
|
CUL_HM_PushCmdStack($hash,'++'.$flag.'11'.$id.$dst.'02'.$chn.'C80000'.$tval);
|
||||||
}
|
}
|
||||||
elsif($cmd eq "toggle") { ###################################################
|
elsif($cmd eq "toggle") { ###################################################
|
||||||
if($st eq "dimmer"){;
|
|
||||||
CUL_HM_PushCmdStack($hash,'++'.$flag.'11'.$id.$dst.'02'.$chn.
|
CUL_HM_PushCmdStack($hash,'++'.$flag.'11'.$id.$dst.'02'.$chn.
|
||||||
(ReadingsVal($name,"state","on") eq "off" ?"C80000":"000000"));
|
(ReadingsVal($name,"state","on") eq "off" ?"C80000":"000000"));
|
||||||
}
|
}
|
||||||
else{
|
|
||||||
$hash->{toggleIndex} = 1 if(!$hash->{toggleIndex});
|
|
||||||
$hash->{toggleIndex} = (($hash->{toggleIndex}+1) % 128);
|
|
||||||
CUL_HM_PushCmdStack($hash, sprintf("++%s3E%s%s%s40%s%02X",$flag,$id,
|
|
||||||
$dst,$dst, $chn, $hash->{toggleIndex}));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
elsif($cmd eq "lock") { #####################################################
|
elsif($cmd eq "lock") { #####################################################
|
||||||
CUL_HM_PushCmdStack($hash,'++'.$flag.'11'.$id.$dst.'800100FF'); # LEVEL_SET
|
CUL_HM_PushCmdStack($hash,'++'.$flag.'11'.$id.$dst.'800100FF'); # LEVEL_SET
|
||||||
}
|
}
|
||||||
@ -2800,37 +2794,39 @@ sub CUL_HM_Set($@) {
|
|||||||
if (hex($chNo) > $maxBtnNo);
|
if (hex($chNo) > $maxBtnNo);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
elsif($cmd eq "actiondetect"){################################################todo Updt3 remove
|
elsif($cmd eq "actiondetect"){###############################################todo Updt3 remove
|
||||||
return "outdated - use attr <name> actCycle instead";
|
return "outdated - use attr <name> actCycle instead";
|
||||||
}
|
}
|
||||||
elsif($cmd eq "press") { ####################################################
|
elsif($cmd eq "press") { ####################################################
|
||||||
my (undef,undef,$mode) = @a;
|
my (undef,undef,$mode,$vChn) = @a;
|
||||||
my ($srcId,$srcChn) = ($1,$2) if ($hash->{DEF} =~ m/(......)(..)/);
|
my $pressCnt = (!$hash->{helper}{count}?1:$hash->{helper}{count}+1)%256;
|
||||||
return "invalid channel:".$srcId.$srcChn if (!$srcChn);
|
$hash->{helper}{count}=$pressCnt;# remember for next round
|
||||||
my $rcvId = "000000"; #may have to change
|
|
||||||
my $btn = sprintf("%02X",$srcChn+(($mode && $mode eq "long")?64:0));
|
|
||||||
my $pressCnt = (!$hash->{helper}{count})?1:$hash->{helper}{count}+1;
|
|
||||||
$pressCnt %= 256;
|
|
||||||
my @peerList;
|
my @peerList;
|
||||||
|
if ($st eq 'virtual'){#serve all peers of virtual button
|
||||||
foreach my $peer (sort(split(',',AttrVal($name,"peerIDs","")))) {
|
foreach my $peer (sort(split(',',AttrVal($name,"peerIDs","")))) {
|
||||||
push (@peerList,substr($peer,0,6));
|
push (@peerList,substr($peer,0,6));
|
||||||
}
|
}
|
||||||
|
@peerList = CUL_HM_noDup(@peerList);
|
||||||
my $oldPeer = " "; # only once to device, not channel!
|
push @peerList,'00000000' if (!@peerList);#send to broadcast if no peer
|
||||||
foreach my $peer (sort @peerList){
|
foreach my $peer (sort @peerList){
|
||||||
next if ($oldPeer eq $peer);
|
my $peerFlag = $peer eq '00000000'?'A4':
|
||||||
|
CUL_HM_getFlag(CUL_HM_id2Hash($peer));
|
||||||
my $peerHash = $modules{CUL_HM}{defptr}{$peer};
|
$peerFlag =~ s/0/4/;# either 'A4' or 'B4'
|
||||||
my $peerSt = AttrVal($peerHash->{NAME}, "subType", "");
|
CUL_HM_PushCmdStack($hash, sprintf("++%s40%s%s%02X%02X",
|
||||||
my $peerFlag = ($peerSt ne "keyMatic") ? "A4" : "B4";
|
$peerFlag,$dst,$peer,
|
||||||
CUL_HM_PushCmdStack($hash, sprintf("++%s40%s%s%s%02X",
|
$chn+(($mode && $mode eq "long")?64:0),
|
||||||
$peerFlag,$srcId,$peer,$btn,$pressCnt));
|
$pressCnt));
|
||||||
$oldPeer = $peer;
|
}
|
||||||
|
}
|
||||||
|
else{#serve internal channels for actor
|
||||||
|
my $pChn = $chn; # simple device, only one button per channel
|
||||||
|
$pChn = (($vChn && $vChn eq "off")?-1:0) + $chn*2 if($st ne 'switch');
|
||||||
|
CUL_HM_PushCmdStack($hash, sprintf("++%s3E%s%s%s40%02X%02X",$flag,
|
||||||
|
$id,$dst,$dst,
|
||||||
|
$pChn+(($mode && $mode eq "long")?64:0),
|
||||||
|
$pressCnt));
|
||||||
}
|
}
|
||||||
|
|
||||||
CUL_HM_PushCmdStack($hash, sprintf("++%s40%s000000%s%02X",
|
|
||||||
$flag,$srcId,$btn,$pressCnt))if (!@peerList);
|
|
||||||
$hash->{helper}{count}=$pressCnt;
|
|
||||||
}
|
}
|
||||||
elsif($cmd eq "devicepair") { ###############################################
|
elsif($cmd eq "devicepair") { ###############################################
|
||||||
#devicepair <btnN> device ... [single|dual] [set|unset] [actor|remote|both]
|
#devicepair <btnN> device ... [single|dual] [set|unset] [actor|remote|both]
|
||||||
@ -3095,7 +3091,7 @@ sub CUL_HM_responseSetup($$) {#store all we need to handle the response
|
|||||||
my ($msgId, $msgFlag,$msgType,$dst,$p) = ($2,hex($3),$4,$6,$7)
|
my ($msgId, $msgFlag,$msgType,$dst,$p) = ($2,hex($3),$4,$6,$7)
|
||||||
if ($cmd =~ m/As(..)(..)(..)(..)(......)(......)(.*)/);
|
if ($cmd =~ m/As(..)(..)(..)(..)(......)(......)(.*)/);
|
||||||
my ($chn,$subType) = ($1,$2) if($p =~ m/^(..)(..)/);
|
my ($chn,$subType) = ($1,$2) if($p =~ m/^(..)(..)/);
|
||||||
my $rTo = rand(20)/10+2; #default response timeout
|
my $rTo = rand(20)/10+4; #default response timeout
|
||||||
if ($msgType eq "01" && $subType){
|
if ($msgType eq "01" && $subType){
|
||||||
if ($subType eq "03"){ #PeerList-------------
|
if ($subType eq "03"){ #PeerList-------------
|
||||||
#--- remember request params in device level
|
#--- remember request params in device level
|
||||||
@ -3231,7 +3227,6 @@ sub CUL_HM_respPendTout($) {
|
|||||||
}
|
}
|
||||||
sub CUL_HM_respPendToutProlong($) {#used when device sends part responses
|
sub CUL_HM_respPendToutProlong($) {#used when device sends part responses
|
||||||
my ($hash) = @_;
|
my ($hash) = @_;
|
||||||
|
|
||||||
RemoveInternalTimer("respPend:$hash->{DEF}");
|
RemoveInternalTimer("respPend:$hash->{DEF}");
|
||||||
InternalTimer(gettimeofday()+1, "CUL_HM_respPendTout", "respPend:$hash->{DEF}", 0);
|
InternalTimer(gettimeofday()+1, "CUL_HM_respPendTout", "respPend:$hash->{DEF}", 0);
|
||||||
}
|
}
|
||||||
@ -4115,7 +4110,7 @@ sub CUL_HM_ActAdd($$) {# add an HMid to list for activity supervision
|
|||||||
($actHash->{helper}{peers}?$actHash->{helper}{peers}:"")
|
($actHash->{helper}{peers}?$actHash->{helper}{peers}:"")
|
||||||
.",$devId");
|
.",$devId");
|
||||||
|
|
||||||
Log GetLogLevel($actHash->{NAME},3),"Device ".$devName." added to ActionDetector with "
|
Log 3,"Device ".$devName." added to ActionDetector with "
|
||||||
.$cycleString." time";
|
.$cycleString." time";
|
||||||
#run ActionDetector
|
#run ActionDetector
|
||||||
RemoveInternalTimer("ActionDetector");
|
RemoveInternalTimer("ActionDetector");
|
||||||
@ -4135,7 +4130,7 @@ sub CUL_HM_ActDel($) {# delete HMid for activity supervision
|
|||||||
my $peerIDs = $actHash->{helper}{peers};
|
my $peerIDs = $actHash->{helper}{peers};
|
||||||
$peerIDs =~ s/$devId//g if($peerIDs);
|
$peerIDs =~ s/$devId//g if($peerIDs);
|
||||||
$actHash->{helper}{peers} = CUL_HM_noDupInString($peerIDs);
|
$actHash->{helper}{peers} = CUL_HM_noDupInString($peerIDs);
|
||||||
Log GetLogLevel($actHash->{NAME},3),"Device ".$devName
|
Log 3,"Device ".$devName
|
||||||
." removed from ActionDetector";
|
." removed from ActionDetector";
|
||||||
RemoveInternalTimer("ActionDetector");
|
RemoveInternalTimer("ActionDetector");
|
||||||
CUL_HM_ActCheck();
|
CUL_HM_ActCheck();
|
||||||
@ -4195,7 +4190,7 @@ sub CUL_HM_ActCheck() {# perform supervision
|
|||||||
if ($oldState ne $state){
|
if ($oldState ne $state){
|
||||||
readingsSingleUpdate($devHash,"Activity:",$state,1);
|
readingsSingleUpdate($devHash,"Activity:",$state,1);
|
||||||
$attr{$devName}{actStatus} = $state;
|
$attr{$devName}{actStatus} = $state;
|
||||||
Log GetLogLevel($actName,4),"Device ".$devName." is ".$state;
|
Log 4,"Device ".$devName." is ".$state;
|
||||||
}
|
}
|
||||||
push @event, "status_".$devName.":".$state;
|
push @event, "status_".$devName.":".$state;
|
||||||
}
|
}
|
||||||
@ -4574,6 +4569,12 @@ sub CUL_HM_noDupInString($) {#return string with no duplicates, comma separated
|
|||||||
<ul><code>set <name> on-till 20:32:10<br></code></ul>
|
<ul><code>set <name> on-till 20:32:10<br></code></ul>
|
||||||
Currently a max of 24h is supported with endtime.<br>
|
Currently a max of 24h is supported with endtime.<br>
|
||||||
</li>
|
</li>
|
||||||
|
<li><B>press <[short|long]><[on|off]></B><a name="CUL_HMpress"></a>
|
||||||
|
simulate a press of the local button or direct connected switch of the actor.<br>
|
||||||
|
[short|long] choose whether to simulate a short or long press of the button.<br>
|
||||||
|
[on|off] is relevant only for devices with direct buttons per channel.
|
||||||
|
Those are available for dimmer and blind-actor, usually not for switches<br>
|
||||||
|
</li>
|
||||||
<li><B>toggle</B> - toggle the switch.</li>
|
<li><B>toggle</B> - toggle the switch.</li>
|
||||||
</ul>
|
</ul>
|
||||||
<br>
|
<br>
|
||||||
@ -4589,6 +4590,7 @@ sub CUL_HM_noDupInString($) {#return string with no duplicates, comma separated
|
|||||||
</li>
|
</li>
|
||||||
<li><B>on</B> set level to 100%<br></li>
|
<li><B>on</B> set level to 100%<br></li>
|
||||||
<li><B>off</B> set level to 0%<br></li>
|
<li><B>off</B> set level to 0%<br></li>
|
||||||
|
<li><B><a href="#CUL_HMpress">press <[short|long]><[on|off]></B></li>
|
||||||
<li><B>toggle</B> - toggle between off and the last on-value</li>
|
<li><B>toggle</B> - toggle between off and the last on-value</li>
|
||||||
<li><B><a href="#CUL_HMonForTimer">on-for-timer <sec></a></B> - Dimmer only! <br></li>
|
<li><B><a href="#CUL_HMonForTimer">on-for-timer <sec></a></B> - Dimmer only! <br></li>
|
||||||
<li><B><a href="#CUL_HMonForTimer">on-till <time></a></B> - Dimmer only! <br></li>
|
<li><B><a href="#CUL_HMonForTimer">on-till <time></a></B> - Dimmer only! <br></li>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user