From ab13c376b762e1ef756ccd6465dbcc18de9de19b Mon Sep 17 00:00:00 2001 From: martinp876 <> Date: Sat, 1 Feb 2014 10:42:52 +0000 Subject: [PATCH] add virtHum, change timing for ACK in HMLAN to 50ms min delay git-svn-id: https://svn.fhem.de/fhem/trunk@4780 2b470e98-0d58-463d-a4d8-8e2adae1ed80 --- fhem/FHEM/00_HMLAN.pm | 10 +++---- fhem/FHEM/10_CUL_HM.pm | 66 ++++++++++++++++++++++++++---------------- fhem/FHEM/HMConfig.pm | 42 ++++++++++++++------------- 3 files changed, 68 insertions(+), 50 deletions(-) diff --git a/fhem/FHEM/00_HMLAN.pm b/fhem/FHEM/00_HMLAN.pm index 1b29764e3..1a443d254 100755 --- a/fhem/FHEM/00_HMLAN.pm +++ b/fhem/FHEM/00_HMLAN.pm @@ -686,14 +686,14 @@ sub HMLAN_SimpleWrite(@) {##################################################### my $hDst = $hash->{helper}{$dst};# shortcut my $tn = gettimeofday(); - if($typ ne "02" && - $modules{CUL_HM}{defptr}{$dst} && + if($modules{CUL_HM}{defptr}{$dst} && $modules{CUL_HM}{defptr}{$dst}{helper}{io} && $modules{CUL_HM}{defptr}{$dst}{helper}{io}{nextSend} ){ - my $DevDelay = $modules{CUL_HM}{defptr}{$dst}{helper}{io}{nextSend} - $tn; - select(undef, undef, undef, (($DevDelay > 0.1)?0.1:$DevDelay)) - if ($DevDelay > 0.01); + my $dDly = $modules{CUL_HM}{defptr}{$dst}{helper}{io}{nextSend} - $tn; + $dDly -= 0.05 if ($typ eq "02");# delay at least 50ms for ACK, but not 100 + select(undef, undef, undef, (($dDly > 0.1)?0.1:$dDly)) + if ($dDly > 0.01); } if ($dst ne $hmId){ #delay send if answer is pending if ( $hDst->{flg} && #HMLAN's ack pending diff --git a/fhem/FHEM/10_CUL_HM.pm b/fhem/FHEM/10_CUL_HM.pm index 558f8061a..cf66bdb6b 100755 --- a/fhem/FHEM/10_CUL_HM.pm +++ b/fhem/FHEM/10_CUL_HM.pm @@ -290,7 +290,7 @@ sub CUL_HM_updateConfig($){ if ($st eq "virtual" ){ if ($hash->{helper}{fkt} eq "sdLead") {$webCmd="teamCall:alarmOn:alarmOff";} elsif($hash->{helper}{fkt} eq "vdCtrl") {$webCmd="valvePos";} - elsif($hash->{helper}{fkt} eq "virtThSens"){$webCmd="virtTemp";} + elsif($hash->{helper}{fkt} eq "virtThSens"){$webCmd="virtTemp:virtHum";} elsif ($hash->{helper}{role}{chn}) {$webCmd="press short:press long";} else {$webCmd="virtual";} @@ -3162,20 +3162,30 @@ sub CUL_HM_Set($@) { my $s2000 = sprintf("%02X", CUL_HM_secSince2000()); CUL_HM_PushCmdStack($hash,"++A03F$id${dst}0204$s2000"); } - elsif($cmd =~ m/^(valvePos|virtTemp)$/) { ################################### - my $val = $a[2]; - if ($val eq "off"){ - $state = "ValveAdjust:stopped"; - RemoveInternalTimer("valvePos:$dst$chn");# remove responsePending timer - RemoveInternalTimer("valveTmr:$dst$chn");# remove responsePending timer - delete($hash->{helper}{virtTC}); + elsif($cmd =~ m/^(valvePos|virtTemp|virtHum)$/) { ########################### + my $valu = $a[2]; + my %lim = (valvePos =>{min=>0 ,max=>100,rd =>"valvePosTC" ,u =>" %"}, + virtTemp =>{min=>-20,max=>50 ,rd =>"temperature",u =>"" }, + virtHum =>{min=>0 ,max=>99 ,rd =>"humidity" ,u =>"" },); + if ($valu eq "off"){ + if ($cmd eq "virtHum") {$hash->{helper}{vd}{vinH} = "";} + else {$hash->{helper}{vd}{vin} = "";} + if ((!$hash->{helper}{vd}{vinH} || $hash->{helper}{vd}{vinH} eq "") && + (!$hash->{helper}{vd}{vin} || $hash->{helper}{vd}{vin} eq "") ){ + $state = "$cmd:stopped"; + RemoveInternalTimer("valvePos:$dst$chn");# remove responsePending timer + RemoveInternalTimer("valveTmr:$dst$chn");# remove responsePending timer + delete($hash->{helper}{virtTC}); + } } - else { - my %lim = (valvePos =>{min=>0 ,max=>100}, - virtTemp =>{min=>-20,max=>50 }); - return "level between $lim{$cmd}{min} and $lim{$cmd}{max} or 'off' allowed" - if (!($val+0 ne $val || - $val <=$lim{$cmd}{max}||$val >=$lim{$cmd}{min} )); + if ($hash->{helper}{virtTC} || $valu ne "off") { + if ($valu ne "off"){ + return "level between $lim{$cmd}{min} and $lim{$cmd}{max} or 'off' allowed" + if ($valu !~ m/^[+-]?\d+\.?\d?$/|| + $valu > $lim{$cmd}{max}||$valu < $lim{$cmd}{min} ); + if ($cmd eq "virtHum") {$hash->{helper}{vd}{vinH} = $valu;} + else {$hash->{helper}{vd}{vin} = $valu;} + } if ($cmd eq "valvePos"){ my @pId = grep !/^$/,split(',',AttrVal($name,"peerIDs","")); return "virtual TC support one VD only. Correct number of peers" @@ -3186,19 +3196,20 @@ sub CUL_HM_Set($@) { $hash->{helper}{vd}{id} = $pId[0]; $hash->{helper}{vd}{cmd} = "A258$dst".substr($pId[0],0,6); CUL_HM_UpdtReadBulk($ph,1, - "state:set_$val %", - "ValveDesired:$val %"); - CUL_HM_UpdtReadSingle($hash,"valvePosTC","$val %",1); - $hash->{helper}{vd}{val} = sprintf("%02X",($val * 2.56)%256); - $state = "ValveAdjust:$val %"; + "state:set_$valu %", + "ValveDesired:$valu %"); + $hash->{helper}{vd}{val} = sprintf("%02X",($valu * 2.56)%256); + $state = "ValveAdjust:$valu %"; } - else{#virtTemp - CUL_HM_UpdtReadSingle($hash,"temperature",$val,1); + else{#virtTemp || virtHum $hash->{helper}{vd}{typ} = 2; #virtTemp $hash->{helper}{vd}{cmd} = "8670$dst"."000000"; - $val *=10; - $val -= 0x8000 if ($val < 0); - $hash->{helper}{vd}{val} = sprintf("%04X", $val & 0x7fff); + my $t = $hash->{helper}{vd}{vin}?$hash->{helper}{vd}{vin}:0; + $t *=10; + $t -= 0x8000 if ($t < 0); + $hash->{helper}{vd}{val} = sprintf("%04X", $t & 0x7fff); + $hash->{helper}{vd}{val} .= sprintf("%02X", $hash->{helper}{vd}{vinH}) + if ($hash->{helper}{vd}{vinH} && $hash->{helper}{vd}{vinH} ne ""); } $hash->{helper}{vd}{idh} = hex(substr($dst,2,2))*20077; @@ -3215,6 +3226,7 @@ sub CUL_HM_Set($@) { }; $hash->{helper}{virtTC} = ($cmd eq "valvePos")?"03":"00"; } + CUL_HM_UpdtReadSingle($hash,$lim{$cmd}{rd},$valu.$lim{$cmd}{u},1); } elsif($cmd eq "matic") { #################################################### # Trigger pre-programmed action in the winmatic. These actions must be @@ -6210,7 +6222,11 @@ sub CUL_HM_complConfig($) {# read config if enabled and not complete
  • virtTemp <[off -10..50]> simulates a thermostat. If peered to a device it periodically sends the - temperature until "off" is given
    + temperature until "off" is given. See also virtHum
    +
  • +
  • virtHum <[off -10..50]> + simulates the humidity part of a thermostat. If peered to a device it periodically sends + the temperature and humidity until both are "off". See also virtTemp
  • valvePos <[off 0..100]> stimulates a VD
    diff --git a/fhem/FHEM/HMConfig.pm b/fhem/FHEM/HMConfig.pm index c464f2f40..a86f5377f 100644 --- a/fhem/FHEM/HMConfig.pm +++ b/fhem/FHEM/HMConfig.pm @@ -258,9 +258,10 @@ my $K_actDetID = '000000'; # id of actionDetector "00C2" => {name=>"HM-PB-2-WM55-2" ,st=>'pushButton' ,cyc=>'' ,rxt=>'c:w:l' ,lst=>'1,4' ,chn=>"Btn:1:2",}, "8001" => {name=>"PS-switch" ,st=>'switch' ,cyc=>'' ,rxt=>'' ,lst=>'1,3' ,chn=>"Sw:1:4",}, "8002" => {name=>"PS-Th-Sens" ,st=>'THSensor' ,cyc=>'' ,rxt=>'' ,lst=>'1,4' ,chn=>"Sen:1:4",}, - #263 167 HM Smoke Detector Schueco - #"HM-RC-Key4-2" - #"HM-RC-Sec4-2" + +# "xxxx" => {name=>"HM-LC-SW4-DR-2" ,st=>'switch' ,cyc=>'' ,rxt=>'' ,lst=>'1,3' ,chn=>"Sw:1:4",}, +# "xxxx" => {name=>"HM-LC-Sw1-Pl-3" ,st=>'switch' ,cyc=>'' ,rxt=>'' ,lst=>'1,3' ,chn=>"",}, + # "HM-LGW-O-TW-W-EU" #Funk LAN Gateway ); ##----------definitions for register settings----------------- @@ -513,7 +514,7 @@ my $K_actDetID = '000000'; # id of actionDetector 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=>"cyclic trigger if level is below cndTxCycBelow",lit=>{off=>0,on=>1}}, @@ -1018,13 +1019,13 @@ foreach (2..16){ $culHmRegChan{"HM-RC-19-B$c"} = $culHmRegChan{"HM-RC-1901"}; $culHmRegChan{"HM-RC-19-SW$c"} = $culHmRegChan{"HM-RC-1901"}; } - + $culHmRegChan{"WDF-solar02"} = $culHmRegType{"dimmer"}; - + $culHmRegChan{"HM-CC-RT-DN-BoM03"} = $culHmRegType{"HM-CC-RT-DN03"}; $culHmRegChan{"HM-CC-RT-DN-BoM04"} = $culHmRegType{"HM-CC-RT-DN04"}; $culHmRegChan{"HM-CC-RT-DN-BoM06"} = $culHmRegType{"HM-CC-RT-DN06"}; - + $culHmRegChan{"HM-TC-IT-WM-W-EU03"} = $culHmRegType{"HM-CC-RT-DN03"}; $culHmRegChan{"HM-TC-IT-WM-W-EU06"} = $culHmRegType{"HM-CC-RT-DN06"}; @@ -1216,7 +1217,7 @@ $culHmModelSets{"ROTO_ZEL-STG-RM-FWT"} = $culHmModelSets{"HM-CC-TC"}; level =>" ..."}, "HM-OU-CFM-PL01" =>{ led =>"[,...] []"}, "HM-OU-CFM-PL02" =>{ playTone =>"[,...] []"}, - + "HM-Sen-RD-O02" =>{ "on-for-timer" =>"" ,"on-till" =>"