From cae893bd58822c068b3c6c7da6c01cd744a1832e Mon Sep 17 00:00:00 2001 From: martinp876 <> Date: Mon, 25 Nov 2013 09:40:18 +0000 Subject: [PATCH] woraround for 4dis bug with read-register, implement powreMeter git-svn-id: https://svn.fhem.de/fhem/trunk@4288 2b470e98-0d58-463d-a4d8-8e2adae1ed80 --- fhem/FHEM/10_CUL_HM.pm | 38 ++++++- fhem/FHEM/HMConfig.pm | 221 +++++++++++++++++++++++------------------ 2 files changed, 163 insertions(+), 96 deletions(-) diff --git a/fhem/FHEM/10_CUL_HM.pm b/fhem/FHEM/10_CUL_HM.pm index 4386d396b..b03532fcd 100755 --- a/fhem/FHEM/10_CUL_HM.pm +++ b/fhem/FHEM/10_CUL_HM.pm @@ -1148,6 +1148,37 @@ sub CUL_HM_Parse($$) {############################## push @event,"state:$btnName $state$target"; } } + elsif($st eq "powerMeter") {########################## + if (($mTp eq "02" && $p =~ m/^01/) || # handle Ack_Status + ($mTp eq "10" && $p =~ m/^06/)) { # or Info_Status message here + + my ($subType,$chn,$val,$err) = ($1,hex($2),hex($3)/2,hex($4)) + if($p =~ m/^(..)(..)(..)(..)/); + $chn = sprintf("%02X",$chn&0x3f); + my $chId = $src.$chn; + $shash = $modules{CUL_HM}{defptr}{$chId} + if($modules{CUL_HM}{defptr}{$chId}); + my $vs = ($val==100 ? "on":($val==0 ? "off":"$val %")); # user string... + + push @event,"level:$val %"; + push @event,"pct:$val"; # duplicate to level - necessary for "slider" + push @event,"deviceMsg:$vs$target" if($chn ne "00"); + my $eventName = "switch"; + my $action; #determine action + push @event, "timedOn:".(($err&0x40)?"running":"off"); + } + elsif ($mTp eq "5E" ||$mTp eq "5F" ) { # POWER_EVENT_CYCLIC + $shash = $modules{CUL_HM}{defptr}{$src."02"} + if($modules{CUL_HM}{defptr}{$src."02"}); + my ($eCnt,$P,$I,$U,$F) = unpack 'A6A6A4A4A2',$p; + push @event, "energy:" .(hex($eCnt)&0x7fffff)/10;# 0.0 ..838860.7 Wh + push @event, "power:" . hex($P )/100; # 0.0 ..167772.15 W + push @event, "current:" . hex($I )/1; # 0.0 ..65535.0 mA + push @event, "voltage:" . hex($U )/10; # 0.0 ..6553.5 mV + push @event, "frequency:". hex($F )/100+50; # 48.72..51.27 Hz + push @event, "boot:" .((hex($eCnt)&0x800000)?"on":"off"); + } + } elsif($st eq "repeater"){ ################################################### if (($mTp eq "02" && $p =~ m/^01/) || # handle Ack_Status ($mTp eq "10" && $p =~ m/^06/)) { #or Info_Status message here @@ -1757,7 +1788,10 @@ sub CUL_HM_parseCommon(@){##################################################### elsif($subType eq "02" ||$subType eq "03"){ #ParamResp================== my $msgValid = 0; if ($pendType eq "RegisterRead"){ - if($shash->{helper}{prt}{rspWait}{mNo} == hex($mNo)){#next message + if($shash->{helper}{prt}{rspWait}{mNoSeq}){#ignore msgNumber + $msgValid = 1; + } + elsif($shash->{helper}{prt}{rspWait}{mNo} == hex($mNo)){#next message $shash->{helper}{prt}{rspWait}{mNo}++; $shash->{helper}{prt}{rspWait}{mNo} &= 0xff; $msgValid = 1; @@ -3524,10 +3558,12 @@ sub CUL_HM_responseSetup($$) {#store all we need to handle the response my ($peer, $list) = ($1,$2) if ($p =~ m/..04(........)(..)/); $peer = ($peer ne "00000000")?CUL_HM_peerChName($peer,$dst,""):""; #--- set messaging items + my $mNoSeq =(AttrVal($hash->{NAME},"model","") eq "HM-PB-4DIS-WM")?"1":"0"; CUL_HM_respWaitSu ($hash,"Pending:=RegisterRead" ,"cmd:=$cmd" ,"forChn:=$chn" ,"forList:=$list","forPeer:=$peer" ,"mNo:=".hex($mNo) + ,"mNoSeq:=$mNoSeq" ,"reSent:=1"); #--- remove channel entries that will be replaced my $chnhash = $modules{CUL_HM}{defptr}{"$dst$chn"}; diff --git a/fhem/FHEM/HMConfig.pm b/fhem/FHEM/HMConfig.pm index db30593b4..73cb1847b 100644 --- a/fhem/FHEM/HMConfig.pm +++ b/fhem/FHEM/HMConfig.pm @@ -207,8 +207,8 @@ my %culHmModel=( "00A8" => {name=>"HM-WDS30-OT2-SM" ,st=>'THSensor' ,cyc=>'00:10' ,rxt=>'c:w:f' ,lst=>'p' ,chn=>"T1:1:1,T2:2:2,T1_T2:3:3,T2_T1:4:4,Event:5:5",}, "00A9" => {name=>"HM-PB-6-WM55" ,st=>'remote' ,cyc=>'' ,rxt=>'c' ,lst=>'1,4' ,chn=>"Btn:1:6",}, "00AB" => {name=>"HM-LC-SW4-BA-PCB" ,st=>'switch' ,cyc=>'' ,rxt=>'b' ,lst=>'1,3' ,chn=>"Sw:1:4",}, - "00AC" => {name=>"HM-ES-PMSw1-Pl" ,st=>'powerMeter' ,cyc=>'00:10' ,rxt=>'' ,lst=>'1,1:2.3.4.5.6,3:1' - ,chn=>"Sw:1:4,Pwr:2:2,CondP:3:3,CondI:4:4,CondU:5:5,CondF:6:6",}, + "00AC" => {name=>"HM-ES-PMSw1-Pl" ,st=>'powerMeter' ,cyc=>'00:10' ,rxt=>'' ,lst=>'1:2.3.4.5.6,3:1p,4:3p.4p.5p.6p' + ,chn=>"Sw:1:1,Pwr:2:2,SenPwr:3:3,SenI:4:4,SenU:5:5,SenF:6:6"}, "00AD" => {name=>"HM-TC-IT-WM-W-EU" ,st=>'thermostat' ,cyc=>'00:10' ,rxt=>'c:w' ,lst=>'p:1p.2p.6p.7p,3:3p.6p,1,7:2,8:2,9:2' ,chn=>"Weather:1:1,Climate:2:2,WindowRec:3:3,remote:6:6,SwitchTr:7:7",}, "00AF" => {name=>"HM-OU-CM-PCB" ,st=>'outputUnit' ,cyc=>'' ,rxt=>'' ,lst=>'3' ,chn=>"",}, @@ -477,21 +477,28 @@ my %culHmRegDefine = ( meaLength =>{a=>108.0,s=>2 ,l=>1,min=>110,max=>310 ,c=>'' ,f=>'' ,u=>'cm' ,d=>1,t=>""}, useCustom =>{a=>110.0,s=>1 ,l=>1,min=>110,max=>310 ,c=>'lit' ,f=>'' ,u=>'' ,d=>1,t=>"use custom" ,lit=>{off=>0,on=>1}}, - averaging =>{a=>122.0,s=>1 ,l=>1,min=>1 ,max=>16 ,c=>'' ,f=>'' ,u=>'s' ,d=>1,t=>"averaging period"}, - txMinDly =>{a=>123.0,s=>0.7,l=>1,min=>0 ,max=>16 ,c=>'' ,f=>'' ,u=>'s' ,d=>1,t=>"min transmit delay"}, - txThrPwr =>{a=>124.0,s=>3 ,l=>1,min=>0.01 ,max=>3680 ,c=>'' ,f=>100 ,u=>'W' ,d=>1,t=>"threshold power"}, - txThrCur =>{a=>127.0,s=>2 ,l=>1,min=>1 ,max=>16000 ,c=>'' ,f=>'' ,u=>'mA' ,d=>1,t=>"threshold current"}, - txThrVlt =>{a=>129.0,s=>2 ,l=>1,min=>0.1 ,max=>230 ,c=>'' ,f=>10 ,u=>'V' ,d=>1,t=>"threshold voltage"}, - txThrFrq =>{a=>131.0,s=>1 ,l=>1,min=>0.01 ,max=>2.55 ,c=>'' ,f=>100 ,u=>'Hz' ,d=>1,t=>"threshold frequency"}, + averaging =>{a=>122.0,s=>1 ,l=>1,min=>1 ,max=>16 ,c=>'' ,f=>'' ,u=>'s' ,d=>1,t=>"averaging period"}, + txMinDly =>{a=>123.0,s=>0.7,l=>1,min=>0 ,max=>16 ,c=>'' ,f=>'' ,u=>'s' ,d=>1,t=>"min transmit delay"}, + txThrPwr =>{a=>124.0,s=>3 ,l=>1,min=>0.01 ,max=>3680 ,c=>'' ,f=>100 ,u=>'W' ,d=>1,t=>"threshold power"}, + txThrCur =>{a=>127.0,s=>2 ,l=>1,min=>1 ,max=>16000 ,c=>'' ,f=>'' ,u=>'mA' ,d=>1,t=>"threshold current"}, + txThrVlt =>{a=>129.0,s=>2 ,l=>1,min=>0.1 ,max=>230 ,c=>'' ,f=>10 ,u=>'V' ,d=>1,t=>"threshold voltage"}, + txThrFrq =>{a=>131.0,s=>1 ,l=>1,min=>0.01 ,max=>2.55 ,c=>'' ,f=>100 ,u=>'Hz' ,d=>1,t=>"threshold frequency"}, + + cndTxFalling =>{a=>132.0,s=>0.1,l=>1,min=>0 ,max=>1 ,c=>'lit' ,f=>'' ,u=>'' ,d=>1,t=>"trigger if falling" ,lit=>{off=>0,on=>1}}, + cndTxRising =>{a=>132.1,s=>0.1,l=>1,min=>0 ,max=>1 ,c=>'lit' ,f=>'' ,u=>'' ,d=>1,t=>"trigger if rising" ,lit=>{off=>0,on=>1}}, + cndTxCycBelow =>{a=>132.2,s=>0.1,l=>1,min=>0 ,max=>1 ,c=>'lit' ,f=>'' ,u=>'' ,d=>1,t=>"trigger if cond is below threshold",lit=>{off=>0,on=>1}}, + cndTxCycAbove =>{a=>132.3,s=>0.1,l=>1,min=>0 ,max=>1 ,c=>'lit' ,f=>'' ,u=>'' ,d=>1,t=>"trigger if cond is above threshold",lit=>{off=>0,on=>1}}, + cndTxCycAbove =>{a=>133 ,s=>1 ,l=>1,min=>0 ,max=>255 ,c=>'' ,f=>'' ,u=>'' ,d=>1,t=>"trigger if decission is above"}, + cndTxCycBelow =>{a=>134 ,s=>1 ,l=>1,min=>0 ,max=>255 ,c=>'' ,f=>'' ,u=>'' ,d=>1,t=>"trigger if decission is below"}, - txThrLoPwr =>{a=>135.0,s=>4 ,l=>1,min=>0 ,max=>3680 ,c=>'' ,f=>'100' ,u=>'W' ,d=>1,t=>"threshold low power"}, - txThrHiPwr =>{a=>139.0,s=>4 ,l=>1,min=>0 ,max=>3680 ,c=>'' ,f=>'100' ,u=>'W' ,d=>1,t=>"threshold high power"}, - txThrLoCur =>{a=>135.0,s=>4 ,l=>1,min=>0 ,max=>16000 ,c=>'' ,f=>'100' ,u=>'mA' ,d=>1,t=>"threshold low current"}, - txThrHiCur =>{a=>139.0,s=>4 ,l=>1,min=>0 ,max=>16000 ,c=>'' ,f=>'100' ,u=>'mA' ,d=>1,t=>"threshold high current"}, - txThrLoVlt =>{a=>135.0,s=>4 ,l=>1,min=>115 ,max=>255 ,c=>'' ,f=>'100' ,u=>'V' ,d=>1,t=>"threshold low voltage"}, - txThrHiVlt =>{a=>139.0,s=>4 ,l=>1,min=>115 ,max=>255 ,c=>'' ,f=>'100' ,u=>'V' ,d=>1,t=>"threshold high voltage"}, - txThrLoFrq =>{a=>135.0,s=>4 ,l=>1,min=>48.72,max=>51.27 ,c=>'' ,f=>'100' ,u=>'Hz' ,d=>1,t=>"threshold low frequency"}, - txThrHiFrq =>{a=>139.0,s=>4 ,l=>1,min=>48.72,max=>51.27 ,c=>'' ,f=>'100' ,u=>'Hz' ,d=>1,t=>"threshold high frequency"}, + txThrLoPwr =>{a=>135.0,s=>4 ,l=>1,min=>0 ,max=>3680 ,c=>'' ,f=>'100' ,u=>'W' ,d=>1,t=>"threshold low power"}, + txThrHiPwr =>{a=>139.0,s=>4 ,l=>1,min=>0 ,max=>3680 ,c=>'' ,f=>'100' ,u=>'W' ,d=>1,t=>"threshold high power"}, + txThrLoCur =>{a=>135.0,s=>4 ,l=>1,min=>0 ,max=>16000 ,c=>'' ,f=>'100' ,u=>'mA' ,d=>1,t=>"threshold low current"}, + txThrHiCur =>{a=>139.0,s=>4 ,l=>1,min=>0 ,max=>16000 ,c=>'' ,f=>'100' ,u=>'mA' ,d=>1,t=>"threshold high current"}, + txThrLoVlt =>{a=>135.0,s=>4 ,l=>1,min=>115 ,max=>255 ,c=>'' ,f=>'100' ,u=>'V' ,d=>1,t=>"threshold low voltage"}, + txThrHiVlt =>{a=>139.0,s=>4 ,l=>1,min=>115 ,max=>255 ,c=>'' ,f=>'100' ,u=>'V' ,d=>1,t=>"threshold high voltage"}, + txThrLoFrq =>{a=>135.0,s=>4 ,l=>1,min=>48.72,max=>51.27 ,c=>'' ,f=>'100' ,u=>'Hz' ,d=>1,t=>"threshold low frequency"}, + txThrHiFrq =>{a=>139.0,s=>4 ,l=>1,min=>48.72,max=>51.27 ,c=>'' ,f=>'100' ,u=>'Hz' ,d=>1,t=>"threshold high frequency"}, evtFltrPeriod =>{a=> 1.0,s=>0.4,l=>1,min=>0.5,max=>7.5 ,c=>'' ,f=>2 ,u=>'s' ,d=>1,t=>"event filter period"}, evtFltrNum =>{a=> 1.4,s=>0.4,l=>1,min=>1 ,max=>15 ,c=>'' ,f=>'' ,u=>'' ,d=>1,t=>"sensitivity - read each n-th puls"}, @@ -704,7 +711,7 @@ my %culHmRegType = ( }, sensRain =>{ transmDevTryMax =>1,localResDis =>1}, tipTronic =>{ cyclicInfoMsg =>1,cyclicInfoMsgDis=>1,localResDis =>1,RS485IdleTime =>1}, - powerMeter =>{ intKeyVisib =>1}, + powerMeter =>{ intKeyVisib =>1,localResDis =>1}, ); #clones - - - - - - - - - - - - - - - @@ -817,7 +824,6 @@ my %culHmRegModel = ( "HM-TC-IT-WM-W-EU" =>{ burstRx =>1,cyclicInfoMsgDis=>1,localResDis =>1,cyclicInfoMsg =>1 ,btnLock =>1,globalBtnLock =>1,modusBtnLock =>1,lowBatLimitRT =>1 }, - "HM-ES-PMSw1-Pl" =>{ localResDis =>1}, ); #clones - - - - - - - - - - - - - - - @@ -939,37 +945,36 @@ my %culHmRegChan = (# if channelspecific then enter them here ,noMinMax4Manu =>1,daylightSaveTime=>1,sendWeatherData =>1 ,modePrioParty =>1,modePrioManu =>1,weekPrgSel =>1 }, + "HM-ES-PMSw1-Pl01" =>{ OnTime =>1,OffTime =>1,OnDly =>1,OffDly =>1 + ,SwJtOn =>1,SwJtOff =>1,SwJtDlyOn =>1,SwJtDlyOff =>1 + ,CtValLo =>1,CtValHi =>1 + ,CtOn =>1,CtDlyOn =>1,CtOff =>1,CtDlyOff =>1 + ,ActionType =>1,OnTimeMode =>1,OffTimeMode =>1 + ,lgMultiExec =>1 + }, "HM-ES-PMSw1-Pl02" =>{ averaging =>1 ,txMinDly =>1,txThrPwr =>1,txThrCur =>1,txThrVlt =>1,txThrFrq =>1 - }, - "HM-ES-PMSw1-Pl04" =>{ txThrLoPwr =>1,txThrHiPwr =>1 - ,CtDlyOn =>1,CtDlyOff =>1,CtOn =>1,CtOff =>1 - ,CtValLo =>1,CtValHi =>1 - ,OnDly =>1,OnTime =>1,OffDly =>1,OffTime =>1 - ,SwJtOn =>1,SwJtOff =>1,SwJtDlyOn =>1,SwJtDlyOff =>1 - ,ActionType =>1 - }, - "HM-ES-PMSw1-Pl04" =>{ txThrLoCur =>1,txThrHiCur =>1 - ,CtDlyOn =>1,CtDlyOff =>1,CtOn =>1,CtOff =>1 - ,CtValLo =>1,CtValHi =>1 - ,OnDly =>1,OnTime =>1,OffDly =>1,OffTime =>1 - ,SwJtOn =>1,SwJtOff =>1,SwJtDlyOn =>1,SwJtDlyOff =>1 - ,ActionType =>1 - }, - "HM-ES-PMSw1-Pl05" =>{ txThrLoVlt =>1,txThrHiVlt =>1 - ,CtDlyOn =>1,CtDlyOff =>1,CtOn =>1,CtOff =>1 - ,CtValLo =>1,CtValHi =>1 - ,OnDly =>1,OnTime =>1,OffDly =>1,OffTime =>1 - ,SwJtOn =>1,SwJtOff =>1,SwJtDlyOn =>1,SwJtDlyOff =>1 - ,ActionType =>1 - }, - "HM-ES-PMSw1-Pl06" =>{ txThrLoFrq =>1,txThrHiFrq =>1 - ,CtDlyOn =>1,CtDlyOff =>1,CtOn =>1,CtOff =>1 - ,CtValLo =>1,CtValHi =>1 - ,OnDly =>1,OnTime =>1,OffDly =>1,OffTime =>1 - ,SwJtOn =>1,SwJtOff =>1,SwJtDlyOn =>1,SwJtDlyOff =>1 - ,ActionType =>1 - }, + }, + "HM-ES-PMSw1-Pl03" =>{ txThrLoPwr =>1,txThrHiPwr =>1,peerNeedsBurst =>1,expectAES =>1 + ,ledOnTime =>1,transmitTryMax =>1, + ,cndTxFalling =>1,cndTxRising =>1, + ,cndTxCycBelow =>1,cndTxCycAbove =>1,cndTxDecAbove =>1,cndTxDecBelow =>1, + }, + "HM-ES-PMSw1-Pl04" =>{ txThrLoCur =>1,txThrHiCur =>1,peerNeedsBurst =>1,expectAES =>1 + ,ledOnTime =>1,transmitTryMax =>1, + ,cndTxFalling =>1,cndTxRising =>1, + ,cndTxCycBelow =>1,cndTxCycAbove =>1,cndTxDecAbove =>1,cndTxDecBelow =>1, + }, + "HM-ES-PMSw1-Pl05" =>{ txThrLoVlt =>1,txThrHiVlt =>1,peerNeedsBurst =>1,expectAES =>1 + ,ledOnTime =>1,transmitTryMax =>1, + ,cndTxFalling =>1,cndTxRising =>1, + ,cndTxCycBelow =>1,cndTxCycAbove =>1,cndTxDecAbove =>1,cndTxDecBelow =>1, + }, + "HM-ES-PMSw1-Pl06" =>{ txThrLoFrq =>1,txThrHiFrq =>1,peerNeedsBurst =>1,expectAES =>1 + ,ledOnTime =>1,transmitTryMax =>1, + ,cndTxFalling =>1,cndTxRising =>1, + ,cndTxCycBelow =>1,cndTxCycAbove =>1,cndTxDecAbove =>1,cndTxDecBelow =>1, + }, ); #clones - - - - - - - - - - - - - - - @@ -1144,54 +1149,63 @@ $culHmModelSets{"HM-OU-CM-PCB"} = $culHmModelSets{"HM-OU-CFM-PL"}; #%{$culHmModelSets{"HM-RC-19-SW"}} = %{$culHmModelSets{"HM-RC-19"}}; copy my %culHmChanSets = ( - "HM-CC-TC00" =>{ "desired-temp" =>"[on|off|6.0..30.0]" - ,statusRequest =>"" - ,sysTime =>"" - ,getSerial => ""}, - "HM-CC-TC02" =>{ peerChan =>" 0 ... single [set|unset] [actor|remote|both]" - ,"desired-temp" =>"[on|off|6.0..30.0]" - ,tempListSat =>"[prep|exec] HH:MM temp ..." - ,tempListSun =>"[prep|exec] HH:MM temp ..." - ,tempListMon =>"[prep|exec] HH:MM temp ..." - ,tempListTue =>"[prep|exec] HH:MM temp ..." - ,tempListThu =>"[prep|exec] HH:MM temp ..." - ,tempListWed =>"[prep|exec] HH:MM temp ..." - ,tempListFri =>"[prep|exec] HH:MM temp ..." - ,partyMode =>"[prep|exec] HH:MM durationDays ..." - ,displayMode =>"[temp-only|temp-hum]" - ,displayTemp =>"[actual|setpoint]" - ,displayTempUnit=>"[celsius|fahrenheit]" - ,controlMode =>"[auto|manual|central|party]" - ,statusRequest =>"" - ,sysTime =>""}, - "HM-SEC-WIN01" =>{ stop =>"", - level =>" ..."}, - "HM-OU-CFM-PL01" =>{ led =>"[,...] []"}, - "HM-OU-CFM-PL02" =>{ playTone =>"[,...] []"}, - - "WDF-solar01" =>{ peerChan =>" 0 ... single [set|unset] [actor|remote|both]"}, - "HM-Sen-RD-O01" =>{ peerChan =>" 0 ... single [set|unset] [actor|remote|both]"}, - "HM-Sen-RD-O02" =>{ "on-for-timer" =>"" - ,"on-till" =>"