From 4f9946d45f1ab023f23b855d0c9a85db97f16e44 Mon Sep 17 00:00:00 2001 From: martinp876 <> Date: Tue, 10 Jul 2012 16:03:59 +0000 Subject: [PATCH] add devicepair for single Button for HM devices git-svn-id: https://svn.fhem.de/fhem/trunk@1716 2b470e98-0d58-463d-a4d8-8e2adae1ed80 --- fhem/CHANGED | 1 + fhem/FHEM/10_CUL_HM.pm | 38 +++++++++++++++++++++++++------------- fhem/docs/commandref.html | 27 +++++++++++++++++++++++---- 3 files changed, 49 insertions(+), 17 deletions(-) diff --git a/fhem/CHANGED b/fhem/CHANGED index e0eeb35d6..65f85c98e 100644 --- a/fhem/CHANGED +++ b/fhem/CHANGED @@ -1,4 +1,5 @@ - SVN + - 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 - feature: internal NotifyOrderPrefix: 98_average.pm is more straightforward diff --git a/fhem/FHEM/10_CUL_HM.pm b/fhem/FHEM/10_CUL_HM.pm index 2a12fbfa8..9d80bcf58 100755 --- a/fhem/FHEM/10_CUL_HM.pm +++ b/fhem/FHEM/10_CUL_HM.pm @@ -120,6 +120,8 @@ my %culHmModel=( "0062" => "HM-LC-SW2-DR", "0066" => "HM_LC_Sw4-WM", # Tested by peterp "0067" => "HM-LC_Dim1PWM-CV", # Tested by peterp + "0068" => "HM-LC_Dim1TPBU-FM", # Tested by martinp (2012-07-10) + "006A" => "HM-LC_Bl1PBU-FM", # Tested by martinp (2012-07-10) "006C" => "HM-LC-SW1-BA-PCB", # Tested by MartiMcFly ); @@ -906,7 +908,10 @@ my %culHmSubTypeSets = ( { "on-for-timer"=>"sec", on =>"", off=>"", toggle=>"", pct=>"", stop=>"" }, remote => { text => " [on|off] ", - devicepair => " device", }, + devicepair => " device [single|dual]", }, + pushButton => + { text => " [on|off] ", + devicepair => " device [single|dual]", }, smokeDetector => { test => "", "alarmOn"=>"", "alarmOff"=>"" }, winMatic => @@ -1402,14 +1407,26 @@ CUL_HM_Set($@) $dst,$dst, $1 eq "On" ? "0BC8" : "0C01"), 1, 0); } elsif($cmd eq "devicepair") { ##################################### - return "$a[2] is not a button number" if($a[2] !~ m/^\d$/ || $a[2] < 1); - my $b1 = sprintf("%02X", $a[2]*2-1); - my $b2 = sprintf("%02X", $a[2]*2); + 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"))); + my $b1; + my $b2; + my $nrCh2Pair; + if ($a[4] ne"single"){ #default to dual + $b1 = sprintf("%02X", $a[2]*2-1); + $b2 = sprintf("%02X", $a[2]*2); + $nrCh2Pair = 2; + }else{ + $b1 = sprintf("%02X",$a[2]); + $b2 = $b1; + $nrCh2Pair = 1; + } my $dst2 = $dhash->{DEF}; my $chn2 = "01"; if(length($dst2) == 8) { # shadow switch device for multi-channel switch @@ -1419,23 +1436,18 @@ CUL_HM_Set($@) } # First the remote (one loop for on, one for off) - for(my $i = 1; $i <= 2; $i++) { + for(my $i = 1; $i <= $nrCh2Pair; $i++) { 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}05${dst2}${chn2}04"); - CUL_HM_PushCmdStack($hash, "++A001${id}${dst}${b}080100"); - CUL_HM_PushCmdStack($hash, "++A001${id}${dst}${b}06"); + CUL_HM_PushCmdStack($hash, "++A001${id}${dst}${b}01${dst2}${chn2}00"); + CUL_HM_pushConfig($hash,$id, $dst,hex($b),$dst2,hex($chn2),4,"0100"); } - # Now the switch: PEER_ADD, PARAM_REQ:on, PARAM_REQ:off + # 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}04${dst}${b1}03"); - CUL_HM_PushCmdStack($dhash, "++A001${id}${dst2}${chn2}04${dst}${b2}03"); $hash = $dhash; # Exchange the hash, as the switch is always alive. $isSender=0; # the other device is a switch. ahem. - } $hash->{STATE} = $state if($state); diff --git a/fhem/docs/commandref.html b/fhem/docs/commandref.html index 267e3b5c6..87ef77565 100644 --- a/fhem/docs/commandref.html +++ b/fhem/docs/commandref.html @@ -3319,11 +3319,30 @@ A line ending with \ will be concatenated with the next one, so long lines
-
  • remotes +
  • remotes, pushButton
      - devicepair hmDevice
      - Pair a remote directly with a switch. The command for the switch is - sent out directly, the remote must be set into learning mode first. + * devicepair <btn_no> <hmDevice> [single|dual]
      + Pair a sender device directly with a actuator. After pairing + commands sent by the remote are processed directly by the actuator. + + + Remote must be set into learning mode first.
      + <hmDevice> is the actuator's channel to be paired.
      + <btn_no> is the button on the remote 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 + single mode.
      + [single|dual]: this mode impacts the default behavior of the + Actuator upon using this button. E.g. a dimmer can be learned to a + single button or to a button pair.
      + 'dual' (default) Button pairs two buttons to one actuator. With a + dimmer this means one button for dim-up and one for dim-down.
      + '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.
      + example: set myRemote devicepair 2 mySwitchActuator single +