2
0
mirror of https://github.com/fhem/fhem-mirror.git synced 2025-02-07 16:59:18 +00:00

VD simulation

git-svn-id: https://svn.fhem.de/fhem/trunk@4558 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
martinp876 2014-01-04 11:43:45 +00:00
parent 03120b170a
commit 16b1e44d68
2 changed files with 43 additions and 52 deletions

View File

@ -3096,7 +3096,18 @@ sub CUL_HM_Set($@) {
}
else {
my $vp = $a[2];
foreach my $peer (split(',',AttrVal($name,"peerIDs",""))) {
next if (length($peer) != 8);
my $ph = CUL_HM_id2Hash($peer);
CUL_HM_UpdtReadBulk($ph,1,
"state:set_$vp %",
"ValveDesired:$vp %")
if ($ph);
}
readingsSingleUpdate($hash,"valvePosTC","$vp %",0);
$hash->{helper}{vd}{idh} = hex(substr($dst,2,2))*20077;
$hash->{helper}{vd}{idl} = hex(substr($dst,4,2))*256;
$hash->{helper}{vd}{msgCnt} = 1;
CUL_HM_valvePosUpdt("valvePos:$dst$chn") if (!$hash->{helper}{virtTC});
$hash->{helper}{virtTC} = "03";
$state = "ValveAdjust:$vp %";
@ -3402,24 +3413,24 @@ sub CUL_HM_valvePosUpdt(@) {#update valve position periodically to please valve
my(undef,$vId) = split(':',$in);
my $hash = CUL_HM_id2Hash($vId);
my $vDevId = substr($vId,0,6);
my $nextTimer = 150;
# if ($updtValveCnt++ %2){
# $nextTimer = 20;
# CUL_HM_PushCmdStack($hash,"++8670".$vDevId."00000000D036");# some weather event -
# }
# else{
my $name = $hash->{NAME};
my $vp = ReadingsVal($name,"valvePosTC","15 %");
$vp =~ s/ %//;
$vp *=2.56;
foreach my $peer (sort(split(',',AttrVal($name,"peerIDs","")))) {
next if (length($peer) != 8);
$peer = substr($peer,0,6);
CUL_HM_PushCmdStack($hash,sprintf("++A258%s%s%s%02X",$vDevId
,$peer,$hash->{helper}{virtTC},$vp));
}
# }
my $msgCnt = ($hash->{helper}{vd}{msgCnt} + 1)%255;
my $idl = $hash->{helper}{vd}{idl}+$msgCnt;
my $lo = int(($idl*20077+12345)/65536)&0xff;
my $hi = ($hash->{helper}{vd}{idh}+$idl*198)&0xff;
my $nextTimer = (($lo+$hi)&0xff)/4 +120;
my $name = $hash->{NAME};
my $vp = ReadingsVal($name,"valvePosTC","15 %");
$vp =~ s/ %//;
$vp *=2.56;
foreach my $peer (sort(split(',',AttrVal($name,"peerIDs","")))) {
next if (length($peer) != 8);
$peer = substr($peer,0,6);
CUL_HM_PushCmdStack($hash,sprintf("%02XA258%s%s%s%02X",$msgCnt,$vDevId
,$peer,$hash->{helper}{virtTC},$vp));
}
$hash->{helper}{vd}{msgCnt} = $msgCnt;
$hash->{helper}{virtTC} = "00";
CUL_HM_ProcessCmdStack($hash);
InternalTimer(gettimeofday()+$nextTimer,"CUL_HM_valvePosUpdt","valvePos:$vId",0);
@ -4148,12 +4159,16 @@ sub CUL_HM_ID2PeerList ($$$) {
my $st = AttrVal($dHash->{NAME},"subType","");
if ($st eq "virtual"){
#if any of the peers is an SD we are team master
my $tMstr = 0;
my ($tMstr,$tcSim) = (0,0);
foreach (split(",",$peerNames)){
$tMstr = 1 if(AttrVal($_,"subType","") eq "smokeDetector");
$tcSim = 1 if(AttrVal($_,"model","") eq "HM-CC-VD");
}
if($tMstr){$hash->{sdTeam}="sdLead";$hash->{helper}{fkt}="sdLead";}
else {delete $hash->{sdTeam}; delete $hash->{helper}{fkt};}
if ($tMstr){$hash->{helper}{fkt}="sdLead";$hash->{sdTeam}="sdLead";}
elsif($tcSim){$hash->{helper}{fkt}="vdCtrl";}
else {delete $hash->{helper}{fkt};}
if(!$tMstr) {delete $hash->{sdTeam};}
}
elsif ($st eq "smokeDetector"){
foreach (split(",",$peerNames)){
@ -5316,10 +5331,13 @@ sub CUL_HM_autoReadReady($){# capacity for autoread available?
sub CUL_HM_getAttrInt($@){#return attrValue as integer
my ($name,$attrName,$default) = @_;
my $val = $attr{$name}{$attrName}?$attr{$name}{$attrName}:"";
$default = 0 if (!defined $default);
my $val = ($attr{$name} &&
$attr{$name}{$attrName})
?$attr{$name}{$attrName}
:"";
no warnings 'numeric';
my $devN = $defs{$name}{device}?$defs{$name}{device}:$name;
$default = 0 if (!defined $default);
$val = int($attr{$devN}{$attrName}?$attr{$devN}{$attrName}:$default)+0
if($val eq "");
use warnings 'numeric';

View File

@ -1122,7 +1122,6 @@ $culHmRegChan{"HM-TC-IT-WM-W-EU06"}= $culHmRegType{"HM-CC-RT-DN06"};
,press =>"[long|short]..."
,postEvent =>"<condition>"
,postWeather =>"<off| -80..80 degree>"
# ,valvePos =>"<position>"
},
smokeDetector =>{ peerChan =>"<btnNumber> <actChn> ... single [set|unset] actor"},
winMatic =>{ matic =>"<btn>"
@ -1259,6 +1258,8 @@ $culHmChanSets{"HM-ES-PMSw1-Pl06"} = $culHmChanSets{"HM-ES-PMSw1-Pl03"};
sdLead =>{ alarmOn =>""
,alarmOff =>""
,teamCall =>""
},
vdCtrl =>{ valvePos =>"<position>"
}
);
@ -1463,32 +1464,4 @@ $culHmChanSets{"HM-ES-PMSw1-Pl06"} = $culHmChanSets{"HM-ES-PMSw1-Pl03"};
HUM => '04,2,$val=(hex($val))', } },
);
#sub HMConfig_getHash($){
# my $hn = shift;
# return %culHmModel if($hn eq "culHmModel" );
# return %culHmRegDefShLg if($hn eq "culHmRegDefShLg" );
# return %culHmRegDefine if($hn eq "culHmRegDefine" );
# return %culHmRegGeneral if($hn eq "culHmRegGeneral" );
# return %culHmRegType if($hn eq "culHmRegType" );
# return %culHmRegModel if($hn eq "culHmRegModel" );
# return %culHmRegChan if($hn eq "culHmRegChan" );
#
# return %culHmGlobalGets if($hn eq "culHmGlobalGets" );
# return %culHmSubTypeGets if($hn eq "culHmSubTypeGets" );
# return %culHmModelGets if($hn eq "culHmModelGets" );
#
# return %culHmGlobalSetsDevice if($hn eq "culHmGlobalSetsDevice");
# return %culHmSubTypeDevSets if($hn eq "culHmSubTypeDevSets" );
# return %culHmGlobalSetsChn if($hn eq "culHmGlobalSetsChn" );
# return %culHmGlobalSets if($hn eq "culHmGlobalSets" );
# return %culHmGlobalSetsVrtDev if($hn eq "culHmGlobalSetsVrtDev");
# return %culHmSubTypeSets if($hn eq "culHmSubTypeSets" );
# return %culHmModelSets if($hn eq "culHmModelSets" );
# return %culHmChanSets if($hn eq "culHmChanSets" );
# return %culHmFunctSets if($hn eq "culHmFunctSets" );
#
# return %culHmBits if($hn eq "culHmBits" );
# return @culHmCmdFlags if($hn eq "culHmCmdFlags" );
# return $K_actDetID if($hn eq "K_actDetID" );
#}
1;