diff --git a/fhem/FHEM/10_CUL_HM.pm b/fhem/FHEM/10_CUL_HM.pm index 6b3282bfb..f31fc24a6 100755 --- a/fhem/FHEM/10_CUL_HM.pm +++ b/fhem/FHEM/10_CUL_HM.pm @@ -93,7 +93,7 @@ sub CUL_HM_Initialize($) { "rawToReadable unit ".#"KFM-Sensor" only "peerIDs repPeers ". "actCycle actStatus ". - "autoReadReg:1_restart,0_off,2_pon-restart,3_onChange ". + "autoReadReg:1_restart,0_off,2_pon-restart,3_onChange,4_reqStatus ". "expert:0_off,1_on,2_full ". "hmClass:obsolete devInfo:obsolete ". #unused @@ -108,6 +108,16 @@ sub CUL_HM_Initialize($) { CUL_HM_noDup(map { $culHmModel{$_}{st} } keys %culHmModel)); CUL_HM_initRegHash(); } + +sub CUL_HM_reqStatus($){ + while(@{$modules{CUL_HM}{helper}{reqStatus}}){ + my $name = shift(@{$modules{CUL_HM}{helper}{reqStatus}}); + my $hash = CUL_HM_name2Hash($name); + CUL_HM_Set($hash,$name,"statusRequest"); + InternalTimer(gettimeofday()+4,"CUL_HM_reqStatus","CUL_HM_reqStatus",0); + last; + } +} sub CUL_HM_autoReadConfig($){ # will trigger a getConfig and statusrequest for each device assigned. # @@ -1487,7 +1497,10 @@ sub CUL_HM_parseCommon(@){##################################################### (-1)*(hex($rssi))) if ($rssi && $rssi ne '00' && $rssi ne'80'); #todo = what is the answer to a status request - if ($pendType eq "StatusReq"){#it is the answer to our request + my $name = $shash->{NAME}; + @{$modules{CUL_HM}{helper}{reqStatus}} = grep { $_ != $name } + @{$modules{CUL_HM}{helper}{reqStatus}}; + if ($pendType eq "StatusReq"){#it is the answer to our request my $chnSrc = $src.$shash->{helper}{respWait}{forChn}; my $chnhash = $modules{CUL_HM}{defptr}{$chnSrc}; $chnhash = $shash if (!$chnhash); @@ -1918,6 +1931,7 @@ sub CUL_HM_Set($@) { $adList .= sprintf("%02X%02X",hex($addr),hex($data)) if ($addr ne "00"); return "wrong addr or data:".$ad if (hex($addr)>255 || hex($data)>255); } + $chn = 0 if ($list == 0); CUL_HM_pushConfig($hash,$id,$dst,$chn,$peerID,$peerChn,$list,$adList); } } @@ -2412,7 +2426,7 @@ sub CUL_HM_Set($@) { } 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'); + $pChn = (($vChn && $vChn eq "off")?-1:0) + $chn*2 if($st eq 'blindActuator'||$st eq 'dimmer'); CUL_HM_PushCmdStack($hash, sprintf("++%s3E%s%s%s40%02X%02X",$flag, $id,$dst,$dst, $pChn+(($mode && $mode eq "long")?64:0), @@ -2496,7 +2510,6 @@ sub CUL_HM_Set($@) { readingsSingleUpdate($hash,"state",$state,1) if($state); - $rxType = CUL_HM_getRxType($devHash); Log GetLogLevel($name,2), "CUL_HM set $name " . join(" ", @a[1..$#a])." rxt:".$rxType; @@ -2688,8 +2701,9 @@ sub CUL_HM_responseSetup($$) {#store all we need to handle the response my ($msgId, $msgFlag,$msgType,$dst,$p) = ($2,hex($3),$4,$6,$7) if ($cmd =~ m/As(..)(..)(..)(..)(......)(......)(.*)/); my ($chn,$subType) = ($1,$2) if($p =~ m/^(..)(..)/); +# my ($subType,$chn) = ($1,$2) if($p =~ m/^(..)(..)/); my $rTo = rand(20)/10+4; #default response timeout - if ($msgType eq "01" && $subType){ + if ($msgType eq "01" && $subType){ if ($subType eq "03"){ #PeerList------------- #--- remember request params in device level $hash->{helper}{respWait}{Pending} = "PeerList"; @@ -2741,6 +2755,15 @@ sub CUL_HM_responseSetup($$) {#store all we need to handle the response # return; # } } + elsif($msgType eq '11' && $chn =~ m/^(02|81)$/){#!!! chn is subtype!!! + my $name = CUL_HM_hash2Name($hash); + if (substr(AttrVal($name,"autoReadReg",0),0,1) > 3){ + @{$modules{CUL_HM}{helper}{reqStatus}}= + CUL_HM_noDup(@{$modules{CUL_HM}{helper}{reqStatus}},$name); + RemoveInternalTimer("CUL_HM_reqStatus"); + InternalTimer(gettimeofday()+120,"CUL_HM_reqStatus","CUL_HM_reqStatus", 0); + } + } if (($msgFlag & 0x20) && ($dst ne '000000')){ $hash->{helper}{respWait}{cmd} = $cmd; @@ -2874,9 +2897,10 @@ sub CUL_HM_pushConfig($$$$$$$$) {#generate messages to cnfig data to register my ($hash,$src,$dst,$chn,$peerAddr,$peerChn,$list,$content) = @_; my $flag = CUL_HM_getFlag($hash); my $tl = length($content); - $chn = sprintf("%02X",$chn); +# $chn = $list?sprintf("%02X",$chn):"00";# channel = 00 for List 0 + $chn = sprintf("%02X",$chn); $peerChn = sprintf("%02X",$peerChn); - $list = sprintf("%02X",$list); + $list = sprintf("%02X",$list); # --store pending changes in shadow to handle bit manipulations cululativ-- $peerAddr = "000000" if(!$peerAddr); @@ -4548,6 +4572,7 @@ sub CUL_HM_putHash($) {# provide data for HMinfo '1' will execute a getConfig for the device automatically after each reboot of FHEM.
'2' like '1' plus execute after power_on.
'3' includes '2' plus updates on writes to the device
+ '4' includes '3' plus tries to request status if it seems to be missing
Execution will be delayed in order to prevent congestion at startup. Therefore the update of the readings and the display will be delayed depending on the sice of the database.
Recommendations and constrains upon usage:
diff --git a/fhem/FHEM/HMConfig.pm b/fhem/FHEM/HMConfig.pm index f7fcba487..22de360b1 100644 --- a/fhem/FHEM/HMConfig.pm +++ b/fhem/FHEM/HMConfig.pm @@ -245,8 +245,8 @@ my %culHmRegDefShLg = (# register that are available for short AND long button p #output Unit ActTypeMp3 =>{a=> 36 ,s=>1 ,l=>3,min=>0 ,max=>255 ,c=>'' ,f=>'' ,u=>'' ,d=>0,t=>"Tone or MP3 to be played"}, ActTypeLed =>{a=> 36 ,s=>1 ,l=>3,min=>0 ,max=>255 ,c=>'lit' ,f=>'' ,u=>'' ,d=>0,t=>"LED color" ,lit=>{no=>0x00,red_short=>0x11,red_long=>0x12,green_short=>0x21,green_long=>0x22,orange_short=>0x31,orange_long=>0x32}}, - ActNum =>{a=> 37 ,s=>1 ,l=>3,min=>1 ,max=>255 ,c=>'' ,f=>'' ,u=>'' ,d=>0,t=>"Action Number"}, - Intense =>{a=> 43 ,s=>1 ,l=>3,min=>10 ,max=>255 ,c=>'lit' ,f=>'' ,u=>'' ,d=>0,t=>"Volume",lit=>{vol_0=>255,vol_1=>250,vol_2=>246,vol_3=>240,vol_4=>234,vol_5=>227,vol_6=>218,vol_7=>207,vol_8=>190,vol_9=>162,vol_00=>10}}, + ActNum =>{a=> 37 ,s=>1 ,l=>3,min=>1 ,max=>255 ,c=>'' ,f=>'' ,u=>'' ,d=>0,t=>"Number of repetitions"}, + Intense =>{a=> 43 ,s=>1 ,l=>3,min=>10 ,max=>255 ,c=>'lit' ,f=>'' ,u=>'' ,d=>0,t=>"Volume",lit=>{vol_100=>255,vol_90=>250,vol_80=>246,vol_70=>240,vol_60=>234,vol_50=>227,vol_40=>218,vol_30=>207,vol_20=>190,vol_10=>162,vol_00=>10}}, # statemachines BlJtOn =>{a=> 11.0,s=>0.4,l=>3,min=>0 ,max=>9 ,c=>'lit' ,f=>'' ,u=>'' ,d=>0,t=>"Jump from on" ,lit=>{no=>0,dlyOn=>1,refOn=>2,on=>3,dlyOff=>4,refOff=>5,off=>6,rampOn=>8,rampOff=>9}}, BlJtOff =>{a=> 11.4,s=>0.4,l=>3,min=>0 ,max=>9 ,c=>'lit' ,f=>'' ,u=>'' ,d=>0,t=>"Jump from off" ,lit=>{no=>0,dlyOn=>1,refOn=>2,on=>3,dlyOff=>4,refOff=>5,off=>6,rampOn=>8,rampOff=>9}}, @@ -254,8 +254,8 @@ my %culHmRegDefShLg = (# register that are available for short AND long button p BlJtDlyOff =>{a=> 12.4,s=>0.4,l=>3,min=>0 ,max=>9 ,c=>'lit' ,f=>'' ,u=>'' ,d=>0,t=>"Jump from delayOff",lit=>{no=>0,dlyOn=>1,refOn=>2,on=>3,dlyOff=>4,refOff=>5,off=>6,rampOn=>8,rampOff=>9}}, BlJtRampOn =>{a=> 13.0,s=>0.4,l=>3,min=>0 ,max=>9 ,c=>'lit' ,f=>'' ,u=>'' ,d=>0,t=>"Jump from rampOn" ,lit=>{no=>0,dlyOn=>1,refOn=>2,on=>3,dlyOff=>4,refOff=>5,off=>6,rampOn=>8,rampOff=>9}}, BlJtRampOff =>{a=> 13.4,s=>0.4,l=>3,min=>0 ,max=>9 ,c=>'lit' ,f=>'' ,u=>'' ,d=>0,t=>"Jump from rampOff" ,lit=>{no=>0,dlyOn=>1,refOn=>2,on=>3,dlyOff=>4,refOff=>5,off=>6,rampOn=>8,rampOff=>9}}, - BlJtRefOn =>{a=> 28.0,s=>0.4,l=>3,min=>0 ,max=>9 ,c=>'lit' ,f=>'' ,u=>'' ,d=>0,t=>"Jump from refOn" ,lit=>{no=>0,dlyOn=>1,refOn=>2,on=>3,dlyOff=>4,refOff=>5,off=>6,rampOn=>8,rampOff=>9}}, - BlJtRefOff =>{a=> 28.4,s=>0.4,l=>3,min=>0 ,max=>9 ,c=>'lit' ,f=>'' ,u=>'' ,d=>0,t=>"Jump from refOff" ,lit=>{no=>0,dlyOn=>1,refOn=>2,on=>3,dlyOff=>4,refOff=>5,off=>6,rampOn=>8,rampOff=>9}}, + BlJtRefOn =>{a=> 30.0,s=>0.4,l=>3,min=>0 ,max=>9 ,c=>'lit' ,f=>'' ,u=>'' ,d=>0,t=>"Jump from refOn" ,lit=>{no=>0,dlyOn=>1,refOn=>2,on=>3,dlyOff=>4,refOff=>5,off=>6,rampOn=>8,rampOff=>9}}, + BlJtRefOff =>{a=> 30.4,s=>0.4,l=>3,min=>0 ,max=>9 ,c=>'lit' ,f=>'' ,u=>'' ,d=>0,t=>"Jump from refOff" ,lit=>{no=>0,dlyOn=>1,refOn=>2,on=>3,dlyOff=>4,refOff=>5,off=>6,rampOn=>8,rampOff=>9}}, DimJtOn =>{a=> 11.0,s=>0.4,l=>3,min=>0 ,max=>6 ,c=>'lit' ,f=>'' ,u=>'' ,d=>0,t=>"Jump from on" ,lit=>{no=>0,dlyOn=>1,rampOn=>2,on=>3,dlyOff=>4,rampOff=>5,off=>6}}, DimJtOff =>{a=> 11.4,s=>0.4,l=>3,min=>0 ,max=>6 ,c=>'lit' ,f=>'' ,u=>'' ,d=>0,t=>"Jump from off" ,lit=>{no=>0,dlyOn=>1,rampOn=>2,on=>3,dlyOff=>4,rampOff=>5,off=>6}}, @@ -417,7 +417,7 @@ my %culHmRegDefine = ( brightFilter =>{a=> 2.4,s=>0.4,l=>1,min=>0 ,max=>7 ,c=>'' ,f=>'' ,u=>'' ,d=>1,t=>"brightness filter - ignore light at night"}, eventDlyTime =>{a=> 33 ,s=>1 ,l=>1,min=>0 ,max=>7620 ,c=>'fltCvT' ,f=>'' ,u=>'s' ,d=>1,t=>"event delay time"}, ledOnTime =>{a=> 34 ,s=>1 ,l=>1,min=>0 ,max=>1.275 ,c=>'factor' ,f=>200 ,u=>'s' ,d=>0,t=>"LED ontime"}, - eventFilterTime =>{a=> 35 ,s=>1 ,l=>1,min=>0 ,max=>7620 ,c=>'fltCvT' ,f=>'' ,u=>'s' ,d=>0,t=>"event filter time"}, + eventFilterTime =>{a=> 35 ,s=>0.7,l=>1,min=>0 ,max=>7620 ,c=>'fltCvT' ,f=>'' ,u=>'s' ,d=>0,t=>"event filter time"}, # - different range evtFltrTime =>{a=> 35.0,s=>1 ,l=>1,min=>600,max=>1200 ,c=>'fltCvT' ,f=>'' ,u=>'s' ,d=>0,t=>"event filter time"}, @@ -772,22 +772,17 @@ $culHmSubTypeSets{pushButton} = $culHmSubTypeSets{remote}; $culHmSubTypeSets{motionDetector} = $culHmSubTypeSets{threeStateSensor}; my %culHmModelSets = (# channels of this subtype------------- - "HM-CC-VD" =>{ - valvePos => "position"}, - "HM-RC-19" =>{ - service => "", - alarm => "", - display => " [comma,no] [unit] [off|1|2|3] [off|on|slow|fast] "}, - "HM-PB-4DIS-WM"=>{ - text => " [on|off] "}, - "HM-OU-LED16" =>{ - led =>"[off|red|green|orange]" , - ilum =>"[0-15] [0-127]" }, - "HM-OU-CFM-PL" =>{ - led => "[,..]", - playTone => "[,..]"}, - "HM-Sys-sRP-Pl"=>{ - setRepeat => "[no1..36] [bdcast-yes|no]"}, + "HM-CC-VD" =>{valvePos => "position"}, + "HM-RC-19" =>{service => "", + alarm => "", + display => " [comma,no] [unit] [off|1|2|3] [off|on|slow|fast] "}, + "HM-PB-4DIS-WM"=>{text => " [on|off] "}, + "HM-OU-LED16" =>{led =>"[off|red|green|orange]" , + ilum =>"[0-15] [0-127]" }, + "HM-OU-CFM-PL" =>{led => "[,..]", + playTone => "[,..]", + press => "[long|short] [on|off] ..."}, + "HM-Sys-sRP-Pl"=>{setRepeat => "[no1..36] [bdcast-yes|no]"}, ); # clones- - - - - - - - - - - - - - - - - $culHmModelSets{"HM-RC-19-B"} = $culHmModelSets{"HM-RC-19"}; @@ -928,18 +923,25 @@ my %culHmBits = ( STATUS => '4,2', UNKNOWN => "6,2", RSSI => '08,02,$val=(-1)*(hex($val))' } }, - "11;p02=0400" => { txt => "RESET" }, - "11;p01=02" => { txt => "SET" , params => { + "11;p01=02" => { txt => "SET" , params => { CHANNEL => "02,2", VALUE => "04,2", RAMPTIME => '06,4,$val=CUL_HM_decodeTime16($val)', DURATION => '10,4,$val=CUL_HM_decodeTime16($val)', } }, - "11;p01=80" => { txt => "LED" , params => { + "11;p01=03" => { txt => "STOP_change" , params => { + CHANNEL => "02,2"} }, + "11;p02=0400" => { txt => "RESET" }, + "11;p01=80" => { txt => "LED" , params => { CHANNEL => "02,2", COLOR => "04,2", } }, - "11;p01=81" => { txt => "LEDall" , params => { + "11;p02=8100" => { txt => "LEDall" , params => { Led1To16 => '04,8,$val= join(":",sprintf("%b",hex($val))=~ /(.{2})/g)', } }, + "11;p01=81" => { txt => "LEVEL" , params => { + CHANNEL => "02,2", + TIME => '04,2,$val=hex($val)', + SPEED => '06,2,$val=hex($val)', + } }, "12" => { txt => "HAVE_DATA"}, "3E" => { txt => "SWITCH", params => { DST => "00,6",