mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-04-05 17:48:44 +00:00
update template handling
git-svn-id: https://svn.fhem.de/fhem/trunk@5255 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
92d73e610f
commit
a704db0d26
@ -1482,7 +1482,7 @@ sub CUL_HM_Parse($$) {#########################################################
|
||||
$shash = $modules{CUL_HM}{defptr}{$src."02"}
|
||||
if($modules{CUL_HM}{defptr}{$src."02"});
|
||||
my ($eCnt,$P,$I,$U,$F) = map{hex($_)} unpack 'A6A6A4A4A2',$p;
|
||||
$eCnt = ($eCnt&0x7fffff)/10; #0.0 ..838860.7 Wh
|
||||
$eCnt = ($eCnt&0x7fffff)/10; #0.0 ..838860.7 Wh
|
||||
$P = $P /100; #0.0 ..167772.15 W
|
||||
$I = $I /1; #0.0 ..65535.0 mA
|
||||
$U = $U /10; #0.0 ..6553.5 mV
|
||||
@ -3778,7 +3778,7 @@ sub CUL_HM_Set($@) {#+++++++++++++++++ set command+++++++++++++++++++++++++++++
|
||||
return "No:$ioCh invalid. Number must be <=50" if (!$ioCh || $ioCh !~ m/^(\d*)$/ || $ioCh > 50);
|
||||
return "option $set unknown - use set or unset" if ($set != m/^(set|unset)$/);
|
||||
$set = ($set eq "set")?"01":"02";
|
||||
CUL_HM_PushCmdStack($hash,"++${flag}01$id${dst}$chn$set$ioId$ioCh$chn");
|
||||
CUL_HM_PushCmdStack($hash,"++${flag}01$id${dst}$chn$set$ioId${ioCh}00");
|
||||
}
|
||||
elsif($cmd eq "peerChan") { ############################################# reg
|
||||
#peerChan <btnN> <device> ... [single|dual] [set|unset] [actor|remote|both]
|
||||
@ -4733,10 +4733,10 @@ sub CUL_HM_FWupdateSpeed($$){#set IO speed
|
||||
my $hash = $defs{$name};
|
||||
if ($hash->{IODev}->{TYPE} ne "CUL"){
|
||||
my $msg = sprintf("G%02X",$speed);
|
||||
IOWrite($hash, "",$msg);
|
||||
IOWrite($hash, "cmd",$msg);
|
||||
}
|
||||
else{
|
||||
IOWrite($hash, "",($speed == 100)?"AR\n":"Ar\n");
|
||||
IOWrite($hash, "cmd","speed".$speed);
|
||||
}
|
||||
}
|
||||
sub CUL_HM_FWupdateSim($){#end FW Simulation
|
||||
|
@ -1495,7 +1495,7 @@ sub HMinfo_templateDef(@){#####################################################
|
||||
my ($name,$param,$desc,@regs) = @_;
|
||||
return "insufficient parameter" if(!defined $param);
|
||||
if ($param eq "del"){
|
||||
delete $HMConfig::tpl{$name};
|
||||
delete $HMConfig::culHmTpl{$name};
|
||||
return;
|
||||
}
|
||||
# get description if marked wir ""
|
||||
@ -1510,30 +1510,30 @@ sub HMinfo_templateDef(@){#####################################################
|
||||
splice @regs,0,$cnt;
|
||||
}
|
||||
|
||||
return "$name already defined, delete it first" if($HMConfig::tpl{$name});
|
||||
return "$name already defined, delete it first" if($HMConfig::culHmTpl{$name});
|
||||
return "insufficient parameter" if(@regs < 1);
|
||||
$HMConfig::tpl{$name}{p} = "";
|
||||
$HMConfig::tpl{$name}{p} = join(" ",split(":",$param)) if($param ne "0");
|
||||
$HMConfig::tpl{$name}{t} = $desc;
|
||||
$HMConfig::culHmTpl{$name}{p} = "";
|
||||
$HMConfig::culHmTpl{$name}{p} = join(" ",split(":",$param)) if($param ne "0");
|
||||
$HMConfig::culHmTpl{$name}{t} = $desc;
|
||||
my $paramNo = split(":",$param);
|
||||
foreach (@regs){
|
||||
my ($r,$v)=split":",$_;
|
||||
if (!defined $v){
|
||||
delete $HMConfig::tpl{$name};
|
||||
delete $HMConfig::culHmTpl{$name};
|
||||
return " empty reg value for $r";
|
||||
}
|
||||
elsif($v =~ m/^p(.)/){
|
||||
return ($1+1)." params are necessary, only $paramNo aregiven"
|
||||
if (($1+1)>$paramNo);
|
||||
}
|
||||
$HMConfig::tpl{$name}{reg}{$r} = $v;
|
||||
$HMConfig::culHmTpl{$name}{reg}{$r} = $v;
|
||||
}
|
||||
}
|
||||
sub HMinfo_templateSet(@){#####################################################
|
||||
my ($aName,$tmpl,$pSet,@p) = @_;
|
||||
$pSet = ":" if (!$pSet || $pSet eq "none");
|
||||
my ($pName,$pTyp) = split(":",$pSet);
|
||||
return "template undefined $tmpl" if(!$HMConfig::tpl{$tmpl});
|
||||
return "template undefined $tmpl" if(!$HMConfig::culHmTpl{$tmpl});
|
||||
return "aktor $aName unknown" if(!$defs{$aName});
|
||||
return "exec set $aName getConfig first" if(!(grep /RegL_/,keys%{$defs{$aName}{READINGS}}));
|
||||
return "give <peer>:[short|long] with peer, not $pSet" if($pName && $pTyp !~ m/(short|long)/);
|
||||
@ -1541,11 +1541,11 @@ sub HMinfo_templateSet(@){#####################################################
|
||||
my $aHash = $defs{$aName};
|
||||
|
||||
my @regCh;
|
||||
foreach (keys%{$HMConfig::tpl{$tmpl}{reg}}){
|
||||
foreach (keys%{$HMConfig::culHmTpl{$tmpl}{reg}}){
|
||||
my $regN = $pSet.$_;
|
||||
my $regV = $HMConfig::tpl{$tmpl}{reg}{$_};
|
||||
my $regV = $HMConfig::culHmTpl{$tmpl}{reg}{$_};
|
||||
if ($regV =~m /^p(.)$/) {#replace with User parameter
|
||||
return "insufficient values - at least ".$HMConfig::tpl{p}." are $1 necessary" if (@p < ($1+1));
|
||||
return "insufficient values - at least ".$HMConfig::culHmTpl{p}." are $1 necessary" if (@p < ($1+1));
|
||||
$regV = $p[$1];
|
||||
}
|
||||
my ($ret,undef) = CUL_HM_Set($aHash,$aName,"regSet",$regN,"?",$pName);
|
||||
@ -1569,7 +1569,7 @@ sub HMinfo_templateChk(@){#####################################################
|
||||
my ($aName,$tmpl,$pSet,@p) = @_;
|
||||
$pSet = "" if (!$pSet || $pSet eq "none");
|
||||
my ($pName,$pTyp) = split(":",$pSet);
|
||||
return "template undefined $tmpl\n" if(!$HMConfig::tpl{$tmpl});
|
||||
return "template undefined $tmpl\n" if(!$HMConfig::culHmTpl{$tmpl});
|
||||
return "aktor $aName unknown\n" if(!$defs{$aName});
|
||||
return "give <peer>:[short|long|all] wrong:$pTyp\n" if($pTyp && $pTyp !~ m/(short|long|all)/);
|
||||
|
||||
@ -1598,16 +1598,16 @@ sub HMinfo_templateChk(@){#####################################################
|
||||
}
|
||||
else{
|
||||
my $pRnm = $pName?($pName."-".($pTyp eq "long"?"lg":"sh")):"";
|
||||
foreach my $rn (keys%{$HMConfig::tpl{$tmpl}{reg}}){
|
||||
foreach my $rn (keys%{$HMConfig::culHmTpl{$tmpl}{reg}}){
|
||||
my $regV = ReadingsVal($aName,"R-$pRnm$rn" ,undef);
|
||||
$regV = ReadingsVal($aName,".R-$pRnm$rn",undef) if (!defined $regV);
|
||||
$regV = ReadingsVal($aName,"R-".$rn ,undef) if (!defined $regV);
|
||||
$regV = ReadingsVal($aName,".R-".$rn ,undef) if (!defined $regV);
|
||||
if (defined $regV){
|
||||
$regV =~s/ .*//;#strip unit
|
||||
my $tplV = $HMConfig::tpl{$tmpl}{reg}{$rn};
|
||||
my $tplV = $HMConfig::culHmTpl{$tmpl}{reg}{$rn};
|
||||
if ($tplV =~m /^p(.)$/) {#replace with User parameter
|
||||
return "insufficient data - at least ".$HMConfig::tpl{p}." are $1 necessary"
|
||||
return "insufficient data - at least ".$HMConfig::culHmTpl{p}." are $1 necessary"
|
||||
if (@p < ($1+1));
|
||||
$tplV = $p[$1];
|
||||
}
|
||||
@ -1625,21 +1625,21 @@ sub HMinfo_templateChk(@){#####################################################
|
||||
sub HMinfo_templateList($){####################################################
|
||||
my $templ = shift;
|
||||
my $reply = "";
|
||||
if(!($templ && (grep /$templ/,keys%HMConfig::tpl))){# list all templates
|
||||
foreach (sort keys%HMConfig::tpl){
|
||||
if(!($templ && (grep /$templ/,keys%HMConfig::culHmTpl))){# list all templates
|
||||
foreach (sort keys%HMConfig::culHmTpl){
|
||||
$reply .= sprintf("%-16s params:%-24s Info:%s\n"
|
||||
,$_
|
||||
,$HMConfig::tpl{$_}{p}
|
||||
,$HMConfig::tpl{$_}{t}
|
||||
,$HMConfig::culHmTpl{$_}{p}
|
||||
,$HMConfig::culHmTpl{$_}{t}
|
||||
);
|
||||
}
|
||||
}
|
||||
else{#details about one template
|
||||
$reply = sprintf("%-16s params:%-24s Info:%s\n",$templ,$HMConfig::tpl{$templ}{p},$HMConfig::tpl{$templ}{t});
|
||||
foreach (sort keys %{$HMConfig::tpl{$templ}{reg}}){
|
||||
my $val = $HMConfig::tpl{$templ}{reg}{$_};
|
||||
$reply = sprintf("%-16s params:%-24s Info:%s\n",$templ,$HMConfig::culHmTpl{$templ}{p},$HMConfig::culHmTpl{$templ}{t});
|
||||
foreach (sort keys %{$HMConfig::culHmTpl{$templ}{reg}}){
|
||||
my $val = $HMConfig::culHmTpl{$templ}{reg}{$_};
|
||||
if ($val =~m /^p(.)$/){
|
||||
my @a = split(" ",$HMConfig::tpl{$templ}{p});
|
||||
my @a = split(" ",$HMConfig::culHmTpl{$templ}{p});
|
||||
$val = $a[$1];
|
||||
}
|
||||
$reply .= sprintf(" %-16s :%s\n",$_,$val);
|
||||
|
@ -31,6 +31,7 @@ use vars qw(%culHmChanSets);
|
||||
use vars qw(%culHmFunctSets);
|
||||
use vars qw(%culHmBits);
|
||||
use vars qw(@culHmCmdFlags);
|
||||
use vars qw(%culHmTpl);
|
||||
use vars qw($K_actDetID);
|
||||
|
||||
# ----------------modul globals-----------------------
|
||||
@ -1054,7 +1055,7 @@ $culHmRegChan{"ROTO_ZEL-STG-RM-FWT03"}= $culHmRegChan{"HM-CC-TC03"};
|
||||
|
||||
##############################---templates---##################################
|
||||
#en-block programming of funktions
|
||||
my %tpl = (
|
||||
%culHmTpl = (
|
||||
autoOff => {p=>"time" ,t=>"staircase - auto off after <time>, extend time with each trigger"
|
||||
,reg=>{ OnTime =>"p0"
|
||||
,OffTime =>111600
|
||||
|
Loading…
x
Reference in New Issue
Block a user