mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-02-01 01:09:47 +00:00
KS550 sign fix, HM autocreate additions, HMLAN preparations
git-svn-id: https://svn.fhem.de/fhem/trunk@841 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
fc46db4acb
commit
51cdc406d7
@ -337,12 +337,13 @@ CUL_HM_Parse($$)
|
|||||||
|
|
||||||
} elsif($model eq "KS550") {
|
} elsif($model eq "KS550") {
|
||||||
|
|
||||||
|
|
||||||
if($cmd eq "8670" && $p =~ m/^(....)(..)(....)(....)(..)(..)(..)/) {
|
if($cmd eq "8670" && $p =~ m/^(....)(..)(....)(....)(..)(..)(..)/) {
|
||||||
my ( $t, $h, $r, $w, $wd, $s, $b ) =
|
my ( $t, $h, $r, $w, $wd, $s, $b ) =
|
||||||
(hex($1), hex($2), hex($3), hex($4), hex($5), hex($6), hex($7));
|
(hex($1), hex($2), hex($3), hex($4), hex($5), hex($6), hex($7));
|
||||||
my $tsgn = ($t & 0x4000); # not tested
|
my $tsgn = ($t & 0x4000); # not tested
|
||||||
$t = ($t & 0x3fff)/10;
|
$t = ($t & 0x3fff)/10;
|
||||||
$t = -$t if($tsgn);
|
$t = sprintf("%0.1f", $t-1638.4) if($tsgn);
|
||||||
my $ir = $r & 0x8000;
|
my $ir = $r & 0x8000;
|
||||||
$r = ($r & 0x7fff) * 0.295;
|
$r = ($r & 0x7fff) * 0.295;
|
||||||
my $wdr = ($w>>14)*22.5;
|
my $wdr = ($w>>14)*22.5;
|
||||||
@ -361,6 +362,9 @@ CUL_HM_Parse($$)
|
|||||||
push @event, "sunshine:$s";
|
push @event, "sunshine:$s";
|
||||||
push @event, "brightness:$b";
|
push @event, "brightness:$b";
|
||||||
|
|
||||||
|
} else {
|
||||||
|
push @event, "KS550 unknown: $p";
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} elsif($st eq "KFM" && $model eq "KFM-Sensor") {
|
} elsif($st eq "KFM" && $model eq "KFM-Sensor") {
|
||||||
@ -610,7 +614,6 @@ CUL_HM_Pair(@)
|
|||||||
$attr{$name}{serialNr} = pack('H*', substr($p, 6, 20));
|
$attr{$name}{serialNr} = pack('H*', substr($p, 6, 20));
|
||||||
$attr{$name}{firmware} = sprintf("%d.%d", hex(substr($p,0,1)),hex(substr($p,1,1)));
|
$attr{$name}{firmware} = sprintf("%d.%d", hex(substr($p,0,1)),hex(substr($p,1,1)));
|
||||||
$attr{$name}{devInfo} = substr($p,28);
|
$attr{$name}{devInfo} = substr($p,28);
|
||||||
|
|
||||||
my $stn = $attr{$name}{subType}; # subTypeName
|
my $stn = $attr{$name}{subType}; # subTypeName
|
||||||
my $stt = $stn eq "unknown" ? "subType unknown" : "is a $stn";
|
my $stt = $stn eq "unknown" ? "subType unknown" : "is a $stn";
|
||||||
|
|
||||||
@ -695,9 +698,11 @@ CUL_HM_SendCmd($$$$)
|
|||||||
$cmd = sprintf("As%02X%02x%s", length($cmd2)/2+1, $mn, $cmd2);
|
$cmd = sprintf("As%02X%02x%s", length($cmd2)/2+1, $mn, $cmd2);
|
||||||
IOWrite($hash, "", $cmd);
|
IOWrite($hash, "", $cmd);
|
||||||
if($waitforack) {
|
if($waitforack) {
|
||||||
$hash->{ackWaiting} = $cmd;
|
if($hash->{IODev} && $hash->{IODev}{TYPE} ne "HMLAN") {
|
||||||
$hash->{ackCmdSent} = 1;
|
$hash->{ackWaiting} = $cmd;
|
||||||
InternalTimer(gettimeofday()+0.4, "CUL_HM_Resend", $hash, 0);
|
$hash->{ackCmdSent} = 1;
|
||||||
|
InternalTimer(gettimeofday()+0.4, "CUL_HM_Resend", $hash, 0)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
$cmd =~ m/As(..)(..)(....)(......)(......)(.*)/;
|
$cmd =~ m/As(..)(..)(....)(......)(......)(.*)/;
|
||||||
CUL_HM_DumpProtocol("CUL_HM SND", $io, ($1,$2,$3,$4,$5,$6));
|
CUL_HM_DumpProtocol("CUL_HM SND", $io, ($1,$2,$3,$4,$5,$6));
|
||||||
@ -738,8 +743,8 @@ sub
|
|||||||
CUL_HM_Id($)
|
CUL_HM_Id($)
|
||||||
{
|
{
|
||||||
my ($io) = @_;
|
my ($io) = @_;
|
||||||
return "123456" if(!$io || !defined($io->{FHTID}));
|
my $fhtid = defined($io->{FHTID}) ? $io->{FHTID} : "0000";
|
||||||
return AttrVal($io->{NAME}, "hmId", "F1".$io->{FHTID});
|
return AttrVal($io->{NAME}, "hmId", "F1$fhtid");
|
||||||
}
|
}
|
||||||
|
|
||||||
my %culHmBits = (
|
my %culHmBits = (
|
||||||
|
@ -167,7 +167,7 @@ FileLog_Get($@)
|
|||||||
" <infile> is without direcory, - means the current file\n" .
|
" <infile> is without direcory, - means the current file\n" .
|
||||||
" <outfile> is a prefix, - means stdout\n"
|
" <outfile> is a prefix, - means stdout\n"
|
||||||
if(int(@a) < 5);
|
if(int(@a) < 5);
|
||||||
|
Log 1, join("/", @a);
|
||||||
shift @a;
|
shift @a;
|
||||||
my $inf = shift @a;
|
my $inf = shift @a;
|
||||||
my $outf = shift @a;
|
my $outf = shift @a;
|
||||||
|
@ -24,7 +24,9 @@ my %flogpar = (
|
|||||||
"HMS:HMS100T._.*"
|
"HMS:HMS100T._.*"
|
||||||
=> { GPLOT => "hms:Temp/Hum,", FILTER => "%NAME:T:.*" },
|
=> { GPLOT => "hms:Temp/Hum,", FILTER => "%NAME:T:.*" },
|
||||||
"KS300:.*"
|
"KS300:.*"
|
||||||
=> { GPLOT => "ks300:Temp/Rain,ks300_2:Wind/Hum,", FILTER => "%NAME:T:.*" },
|
=> { GPLOT => "ks300:Temp/Rain,ks300_2:Wind/Hum,",
|
||||||
|
FILTER => "%NAME:T:.*" },
|
||||||
|
|
||||||
# Oregon sensors:
|
# Oregon sensors:
|
||||||
# * temperature
|
# * temperature
|
||||||
"OREGON:(THR128|THWR288A|THN132N).*"
|
"OREGON:(THR128|THWR288A|THN132N).*"
|
||||||
@ -42,6 +44,14 @@ my %flogpar = (
|
|||||||
# * Oregon sensors: Rain gauge
|
# * Oregon sensors: Rain gauge
|
||||||
"OREGON:(PCR800|RGR918).*"
|
"OREGON:(PCR800|RGR918).*"
|
||||||
=> { GPLOT => "oregon_rain:RainRate", FILTER => "%NAME" },
|
=> { GPLOT => "oregon_rain:RainRate", FILTER => "%NAME" },
|
||||||
|
|
||||||
|
# HomeMatic
|
||||||
|
"CUL_HM:THSensor"
|
||||||
|
=> { GPLOT => "hms:Temp/Hum,",
|
||||||
|
FILTER => "%NAME:T:.*" },
|
||||||
|
"CUL_HM:KS550"
|
||||||
|
=> { GPLOT => "ks300:Temp/Rain,ks300_2:Wind/Hum,",
|
||||||
|
FILTER => "%NAME:T:.*" },
|
||||||
);
|
);
|
||||||
|
|
||||||
#####################################
|
#####################################
|
||||||
@ -52,7 +62,11 @@ autocreate_Initialize($)
|
|||||||
$hash->{DefFn} = "autocreate_Define";
|
$hash->{DefFn} = "autocreate_Define";
|
||||||
$hash->{NotifyFn} = "autocreate_Notify";
|
$hash->{NotifyFn} = "autocreate_Notify";
|
||||||
$hash->{AttrList}= "loglevel:0,1,2,3,4,5,6 " .
|
$hash->{AttrList}= "loglevel:0,1,2,3,4,5,6 " .
|
||||||
"autosave filelog device_room weblink weblink_room";
|
"autosave filelog device_room weblink weblink_room " .
|
||||||
|
"disable";
|
||||||
|
my %ahash = ( Fn=>"CommandCreateLog",
|
||||||
|
Hlp=>"<device>,create log/weblink for <device>" );
|
||||||
|
$cmds{createlog} = \%ahash;
|
||||||
}
|
}
|
||||||
|
|
||||||
#####################################
|
#####################################
|
||||||
@ -83,6 +97,7 @@ autocreate_Notify($$)
|
|||||||
my ($ntfy, $dev) = @_;
|
my ($ntfy, $dev) = @_;
|
||||||
|
|
||||||
my $me = $ntfy->{NAME};
|
my $me = $ntfy->{NAME};
|
||||||
|
my ($ll1, $ll2) = (GetLogLevel($me,1), GetLogLevel($me,2));
|
||||||
my $max = int(@{$dev->{CHANGED}});
|
my $max = int(@{$dev->{CHANGED}});
|
||||||
my $ret = "";
|
my $ret = "";
|
||||||
my $nrcreated;
|
my $nrcreated;
|
||||||
@ -95,17 +110,23 @@ autocreate_Notify($$)
|
|||||||
################
|
################
|
||||||
if($s =~ m/^UNDEFINED ([^ ]*) ([^ ]*) (.*)$/) {
|
if($s =~ m/^UNDEFINED ([^ ]*) ([^ ]*) (.*)$/) {
|
||||||
my ($name, $type, $arg) = ($1, $2, $3);
|
my ($name, $type, $arg) = ($1, $2, $3);
|
||||||
|
next if(AttrVal($me, "disable", undef));
|
||||||
|
|
||||||
my $lctype = lc($type);
|
my $lctype = lc($type);
|
||||||
|
my ($cmd, $ret);
|
||||||
|
my $hash = $defs{$name}; # Called from createlog
|
||||||
|
|
||||||
####################
|
####################
|
||||||
my $cmd = "$name $type $arg";
|
if(!$hash) {
|
||||||
Log GetLogLevel($me,2), "autocreate: define $cmd";
|
$cmd = "$name $type $arg";
|
||||||
my $ret = CommandDefine(undef, $cmd);
|
Log $ll2, "autocreate: define $cmd";
|
||||||
if($ret) {
|
$ret = CommandDefine(undef, $cmd);
|
||||||
Log GetLogLevel($me,1), "ERROR: $ret";
|
if($ret) {
|
||||||
last;
|
Log $ll1, "ERROR: $ret";
|
||||||
|
last;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
my $hash = $defs{$name};
|
$hash = $defs{$name};
|
||||||
$nrcreated++;
|
$nrcreated++;
|
||||||
my $room = replace_wildcards($hash, $attr{$me}{device_room});
|
my $room = replace_wildcards($hash, $attr{$me}{device_room});
|
||||||
$attr{$name}{room} = $room if($room);
|
$attr{$name}{room} = $room if($room);
|
||||||
@ -114,17 +135,20 @@ autocreate_Notify($$)
|
|||||||
my $fl = replace_wildcards($hash, $attr{$me}{filelog});
|
my $fl = replace_wildcards($hash, $attr{$me}{filelog});
|
||||||
next if(!$fl);
|
next if(!$fl);
|
||||||
my $flname = "FileLog_$name";
|
my $flname = "FileLog_$name";
|
||||||
|
delete($defs{$flname}); # If we are re-creating it with createlog.
|
||||||
my ($gplot, $filter) = ("", $name);
|
my ($gplot, $filter) = ("", $name);
|
||||||
foreach my $k (keys %flogpar) {
|
foreach my $k (keys %flogpar) {
|
||||||
next if("$type:$name" !~ m/^$k$/);
|
my $model = AttrVal($name, "model", "");
|
||||||
|
next if("$type:$name" !~ m/^$k$/ &&
|
||||||
|
"$type:$model" !~ m/^$k$/);
|
||||||
$gplot = $flogpar{$k}{GPLOT};
|
$gplot = $flogpar{$k}{GPLOT};
|
||||||
$filter = replace_wildcards($hash, $flogpar{$k}{FILTER});
|
$filter = replace_wildcards($hash, $flogpar{$k}{FILTER});
|
||||||
}
|
}
|
||||||
$cmd = "$flname FileLog $fl $filter";
|
$cmd = "$flname FileLog $fl $filter";
|
||||||
Log GetLogLevel($me,2), "autocreate: define $cmd";
|
Log $ll2, "autocreate: define $cmd";
|
||||||
$ret = CommandDefine(undef, $cmd);
|
$ret = CommandDefine(undef, $cmd);
|
||||||
if($ret) {
|
if($ret) {
|
||||||
Log GetLogLevel($me,1), "ERROR: $ret";
|
Log $ll1, "ERROR: $ret";
|
||||||
last;
|
last;
|
||||||
}
|
}
|
||||||
$attr{$flname}{room} = $room if($room);
|
$attr{$flname}{room} = $room if($room);
|
||||||
@ -134,20 +158,26 @@ autocreate_Notify($$)
|
|||||||
####################
|
####################
|
||||||
next if(!$attr{$me}{weblink} || !$gplot);
|
next if(!$attr{$me}{weblink} || !$gplot);
|
||||||
$room = replace_wildcards($hash, $attr{$me}{weblink_room});
|
$room = replace_wildcards($hash, $attr{$me}{weblink_room});
|
||||||
my $wlname = "weblink_$name";
|
my $wnr = 1;
|
||||||
my $gplotfile;
|
foreach my $wdef (split(/,/, $gplot)) {
|
||||||
my $stuff;
|
next if(!$wdef);
|
||||||
($gplotfile, $stuff) = split(/:/, $gplot);
|
my ($gplotfile, $stuff) = split(/:/, $wdef);
|
||||||
$cmd = "$wlname weblink fileplot $flname:$gplotfile:CURRENT";
|
next if(!$gplotfile);
|
||||||
Log GetLogLevel($me,2), "autocreate: define $cmd";
|
my $wlname = "weblink_$name";
|
||||||
$ret = CommandDefine(undef, $cmd);
|
$wlname .= "_$wnr" if($wnr > 1);
|
||||||
if($ret) {
|
$wnr++;
|
||||||
Log GetLogLevel($me,1), "ERROR: $ret";
|
delete($defs{$wlname}); # If we are re-creating it with createlog.
|
||||||
last;
|
$cmd = "$wlname weblink fileplot $flname:$gplotfile:CURRENT";
|
||||||
}
|
Log $ll2, "autocreate: define $cmd";
|
||||||
$attr{$wlname}{room} = $room if($room);
|
$ret = CommandDefine(undef, $cmd);
|
||||||
$attr{$wlname}{label} = '"' . $name .
|
if($ret) {
|
||||||
|
Log $ll1, "ERROR: $ret";
|
||||||
|
last;
|
||||||
|
}
|
||||||
|
$attr{$wlname}{room} = $room if($room);
|
||||||
|
$attr{$wlname}{label} = '"' . $name .
|
||||||
' Min $data{min1}, Max $data{max1}, Last $data{currval1}"';
|
' Min $data{min1}, Max $data{max1}, Last $data{currval1}"';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -166,8 +196,7 @@ autocreate_Notify($$)
|
|||||||
$hash->{DEF} =~ s/$old/$new/g;
|
$hash->{DEF} =~ s/$old/$new/g;
|
||||||
|
|
||||||
rename($oldlogfile, $hash->{currentlogfile});
|
rename($oldlogfile, $hash->{currentlogfile});
|
||||||
Log GetLogLevel($me,2),
|
Log $ll2, "autocreate: renamed FileLog_$old to FileLog_$new";
|
||||||
"autocreate: renamed FileLog_$old to FileLog_$new";
|
|
||||||
$nrcreated++;
|
$nrcreated++;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -177,8 +206,7 @@ autocreate_Notify($$)
|
|||||||
$hash->{LINK} =~ s/$old/$new/g;
|
$hash->{LINK} =~ s/$old/$new/g;
|
||||||
$hash->{DEF} =~ s/$old/$new/g;
|
$hash->{DEF} =~ s/$old/$new/g;
|
||||||
$attr{"weblink_$new"}{label} =~ s/$old/$new/g;
|
$attr{"weblink_$new"}{label} =~ s/$old/$new/g;
|
||||||
Log GetLogLevel($me,2),
|
Log $ll2, "autocreate: renamed weblink_$old to weblink_$new";
|
||||||
"autocreate: renamed weblink_$old to weblink_$new";
|
|
||||||
$nrcreated++;
|
$nrcreated++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -188,13 +216,31 @@ autocreate_Notify($$)
|
|||||||
return $ret;
|
return $ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
#####################################
|
|
||||||
# Test code. Use {dp "xxx"} to fake a device specific message
|
|
||||||
# FS20: 81xx04yy0101a00180c1020013
|
|
||||||
sub
|
sub
|
||||||
dp($)
|
CommandCreateLog($$)
|
||||||
{
|
{
|
||||||
Dispatch($defs{CUL}, shift, undef);
|
my ($cl, $n) = @_;
|
||||||
|
my $ac;
|
||||||
|
|
||||||
|
foreach my $d (keys %defs) {
|
||||||
|
next if($defs{$d}{TYPE} ne "autocreate");
|
||||||
|
$ac = $d;
|
||||||
|
last;
|
||||||
|
}
|
||||||
|
return "Please define an autocreate device with attributes first " .
|
||||||
|
"(it may be disabled)" if(!$ac);
|
||||||
|
|
||||||
|
return "No device named $n found" if(!$defs{$n});
|
||||||
|
|
||||||
|
my $acd = $defs{$ac};
|
||||||
|
my $disabled = AttrVal($ac, "disable", undef);
|
||||||
|
delete $attr{$ac}{disable} if($disabled);
|
||||||
|
|
||||||
|
$acd->{CHANGED}[0] = "UNDEFINED $n $defs{$n}{TYPE} none";
|
||||||
|
autocreate_Notify($acd, $acd);
|
||||||
|
delete $acd->{CHANGED};
|
||||||
|
|
||||||
|
$attr{$ac}{disable} = 1 if($disabled);
|
||||||
}
|
}
|
||||||
|
|
||||||
1;
|
1;
|
||||||
|
Loading…
Reference in New Issue
Block a user