2
0
mirror of https://github.com/fhem/fhem-mirror.git synced 2025-01-31 06:39:11 +00:00

added unset for devicepair and status indication for commandstack for HM devices

git-svn-id: https://svn.fhem.de/fhem/trunk@1728 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
martinp876 2012-07-15 08:51:52 +00:00
parent d8bb67aff8
commit d8dfe4ce70
3 changed files with 69 additions and 20 deletions

View File

@ -1,4 +1,6 @@
- SVN
- feature: Status and length on cmdStack in webinterface for 10_CUL_HM
- feature: devicepair in 10_CUL_HM.pm supports unset
- feature: devicepair for single Button in 10_CUL_HM.pm (by MartinP)
- feature: new Modules 75_MSG.pm, 76_MSGFile.pm and 76_MSGMail.pm (by Rüdiger)
- feature: new Module 59_Twilight.pm to calculate current daylight

View File

@ -218,6 +218,7 @@ CUL_HM_Parse($$)
delete($dhash->{ackCmdSent});
delete($dhash->{ackWaiting});
delete($dhash->{cmdStack});
delete($attr{$dhash->{NAME}}{CmdPend});
$dhash->{STATE} = "MISSING ACK";
DoTrigger($dname, "MISSING ACK");
}
@ -266,6 +267,7 @@ CUL_HM_Parse($$)
if($p =~ m/^8/) {
delete($shash->{cmdStack});
delete($attr{$dhash->{NAME}}{CmdPend});
push @event, "state:NACK";
} else {
@ -908,10 +910,10 @@ my %culHmSubTypeSets = (
{ "on-for-timer"=>"sec", on =>"", off=>"", toggle=>"", pct=>"", stop=>"" },
remote =>
{ text => "<btn> [on|off] <txt1> <txt2>",
devicepair => "<btnNumber> device [single|dual]", },
devicepair => "<btnNumber> device [single|dual] [set|unset]", },
pushButton =>
{ text => "<btn> [on|off] <txt1> <txt2>",
devicepair => "<btnNumber> device [single|dual]", },
devicepair => "<btnNumber> device [single|dual] [set|unset]", },
smokeDetector =>
{ test => "", "alarmOn"=>"", "alarmOff"=>"" },
winMatic =>
@ -1408,12 +1410,14 @@ CUL_HM_Set($@)
} elsif($cmd eq "devicepair") { #####################################
return "$a[2] is not a button number" if($a[2] < 1);
my $dhash = $defs{$a[3]};
return "$a[3] is not a known fhem device" if(!$dhash);
return "$a[3] is not a CUL_HM device" if($dhash->{TYPE} ne "CUL_HM");
return "$a[4] must be single or dual"
if(defined($a[4]) && (($a[4] ne"single") &&($a[4] ne"dual")));
if(defined($a[4]) && (($a[4] ne"single") &&($a[4] ne"dual")));
return "$a[5] must be set or unset"
if(defined($a[5]) && (($a[5] ne"set") &&($a[5] ne"unset")));
my $b1;
my $b2;
@ -1427,6 +1431,8 @@ CUL_HM_Set($@)
$b2 = $b1;
$nrCh2Pair = 1;
}
my $cmd = ($a[5] ne "unset")?"01":"02";# do we set or remove?
my $dst2 = $dhash->{DEF};
my $chn2 = "01";
if(length($dst2) == 8) { # shadow switch device for multi-channel switch
@ -1440,12 +1446,11 @@ CUL_HM_Set($@)
my $b = ($i==1 ? $b1 : $b2);
# PEER_ADD, START, WRITE_INDEX, END
CUL_HM_PushCmdStack($hash, "++A001${id}${dst}${b}01${dst2}${chn2}00");
CUL_HM_PushCmdStack($hash, "++A001${id}${dst}${b}$cmd${dst2}${chn2}00");
CUL_HM_pushConfig($hash,$id, $dst,hex($b),$dst2,hex($chn2),4,"0100");
}
# Now the switch: PEER_ADD
CUL_HM_PushCmdStack($dhash, "++A001${id}${dst2}${chn2}01${dst}${b2}${b1}");
CUL_HM_PushCmdStack($dhash, "++A001${id}${dst2}${chn2}$cmd${dst}${b2}${b1}");
$hash = $dhash; # Exchange the hash, as the switch is always alive.
$isSender=0; # the other device is a switch. ahem.
}
@ -1549,7 +1554,6 @@ CUL_HM_Pair(@)
CUL_HM_pushConfig($hash, $id, $src, $chn,0,0,0, "0201$idstr");
CUL_HM_SendCmd($hash, shift @{$hash->{cmdStack}}, 1, 1);
return "";
}
@ -1600,6 +1604,9 @@ CUL_HM_PushCmdStack($$)
$hash->{cmdStack} = \@arr if(!$hash->{cmdStack});
push(@{$hash->{cmdStack}}, $cmd);
my $entries = scalar @{$hash->{cmdStack}};
$attr{$hash->{NAME}}{CmdPend} = $entries ." CMDs pending. Please activate learning"
if("sender" eq $attr{$hash->{NAME}}{hmClass});
}
###################################
@ -1613,9 +1620,11 @@ CUL_HM_ProcessCmdStack($)
if(@{$hash->{cmdStack}}) {
CUL_HM_SendCmd($hash, shift @{$hash->{cmdStack}}, 1, 1);
$sent = 1;
$attr{$hash->{NAME}}{CmdPend} = scalar @{$hash->{cmdStack}} ."CMDs pending";
}
if(!@{$hash->{cmdStack}}) {
delete($hash->{cmdStack});
delete($attr{$hash->{NAME}}{CmdPend});
}
}
return $sent;
@ -1632,6 +1641,7 @@ CUL_HM_Resend($)
delete($hash->{ackCmdSent});
delete($hash->{ackWaiting});
delete($hash->{cmdStack});
delete($attr{$hash->{NAME}}{CmdPend});
$hash->{STATE} = "MISSING ACK";
DoTrigger($name, "MISSING ACK");
return;
@ -1651,6 +1661,29 @@ CUL_HM_Id($)
return AttrVal($io->{NAME}, "hmId", "F1$fhtid");
}
###################################
sub
CUL_HM_id2Name($)
{ # get name for a HMid or a HMid channel combination
my ($p) = @_;
my $devId= substr($p, 0, 6);
my $chn;
my $chnId;
if (length($p) == 8){
$chn = substr($p, 6, 2);;
$chnId = $p;
}
my $name;
$name = "broadcast" if($devId eq "000000");
$name = $modules{CUL_HM}{defptr}{$chnId}->{NAME} if(!$name && $chnId);
if (!$name){
$name = $modules{CUL_HM}{defptr}{$devId}->{NAME};
$name = $devId if(!$name);
$name .= ($chn ? (" chn:".$chn):"");
}
return $name;
}
#############################
my %culHmBits = (
"8000" => { txt => "DEVICE_INFO", params => {
@ -1677,6 +1710,11 @@ my %culHmBits = (
PEER_ADDRESS => "04,6",
PEER_CHANNEL_A => "10,2",
PEER_CHANNEL_B => "12,2", } },
"A001;p11=02" => { txt => "CONFIG_PEER_REMOVE", params => {
CHANNEL => "00,2",
PEER_ADDRESS => '04,6,$val=CUL_HM_id2Name($val)',
PEER_CHANNEL_A => "10,2",
PEER_CHANNEL_B => "12,2", } },
"A001;p11=03" => { txt => "CONFIG_PEER_LIST_REQ", params => {
CHANNEL => "0,2", } },
"A001;p11=04" => { txt => "CONFIG_PARAM_REQ", params => {
@ -1701,10 +1739,10 @@ my %culHmBits = (
"A003" => { txt => "AES reply", params => {
DATA => "0," } },
"A010;p01=01" => { txt => "INFO_PEER_LIST", params => {
PEER_ADDR1 => "02,6", PEER_CH1 => "08,2",
PEER_ADDR2 => "10,6", PEER_CH2 => "16,2",
PEER_ADDR3 => "18,6", PEER_CH3 => "24,2",
PEER_ADDR4 => "26,6", PEER_CH4 => "32,2", } },
PEER1 => '02,8,$val=CUL_HM_id2Name($val)',
PEER2 => '10,8,$val=CUL_HM_id2Name($val)',
PEER3 => '18,8,$val=CUL_HM_id2Name($val)',
PEER4 => '26,8,$val=CUL_HM_id2Name($val)',} },
"A010;p01=02" => { txt => "INFO_PARAM_RESPONSE_PAIRS", params => {
DATA => "2,", } },
"A010;p01=03" => { txt => "INFO_PARAM_RESPONSE_SEQ", params => {
@ -1794,6 +1832,8 @@ CUL_HM_DumpProtocol($$@)
}
$txt = " ($txt)" if($txt);
}
$src=CUL_HM_id2Name($src);
$dst=CUL_HM_id2Name($dst);
my $msg ="$prefix L:$len N:$cnt CMD:$cmd SRC:$src DST:$dst $p$txt ($cmdBits)";
Log $l4, $msg;
DoTrigger($iname, $msg) if($ev);

View File

@ -3321,14 +3321,19 @@ A line ending with \ will be concatenated with the next one, so long lines
<li>remotes, pushButton
<ul>
* devicepair &lt;btn_no&gt; &lt;hmDevice&gt; [single|dual]<br>
Pair a sender device directly with a actuator. After pairing
commands sent by the remote are processed directly by the actuator.
* devicepair &lt;btn_no&gt; &lt;hmDevice&gt; [single|dual] [set|remove]<br>
Pair/unpair a sender-channel device directly with a actuator-channel.
Trigger from the sender-channel, e.g. button press, will be processed by the
actuator-channel without CCU interaction.
Remote must be set into learning mode first. <br>
&lt;hmDevice&gt; is the actuator's channel to be paired.<br>
&lt;btn_no&gt; is the button on the remote to be paired. If 'single'
Sender (remote or pushButton) must be set into learning after command execution.
Processing in the sender will be postponed until then.<br>
devicepair can be executed multiple times with the same settings - it will
cause the pairing specific parameter to be set to HM defaults. <br>
It is possible to devicepair one actuator-channel to multiple sender-channel
as well as one sender-channel to multiple Actuator-channel. <br>
&lt;hmDevice&gt; is the actuator-channel to be paired.<br>
&lt;btn_no&gt; is the sender-channel (button) to be paired. If 'single'
is choosen buttons are counted from 1. For 'dual' btn_no is the number
of the Button-pair to be used. I.e. '3'
in dual is the 3rd button pair correcponding to button 5 and 6 in
@ -3341,7 +3346,9 @@ A line ending with \ will be concatenated with the next one, so long lines
'single' uses only one button of the sender. It is useful for e.g. for
simple switch actuator to toggle on/off. Nevertheless
also dimmer can be learned to only one button. <br>
example: set myRemote devicepair 2 mySwitchActuator single
'set' will setup pairing for the channels<br>
'unset' will remove the pairing for the channels<br>
example: set myRemote devicepair 2 mySwitchActuator single set
</ul>
<br>