2
0
mirror of https://github.com/fhem/fhem-mirror.git synced 2025-03-03 04:36:36 +00:00

14_CUL_WS update from Peter. CUL:KS300 is handled by the 14_KS300 module now

git-svn-id: https://svn.fhem.de/fhem/trunk@327 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
rudolfkoenig 2009-01-12 09:44:30 +00:00
parent 04c05dfe1a
commit 8da9eb3e8e
2 changed files with 124 additions and 72 deletions

View File

@ -562,11 +562,11 @@ CUL_Read($)
} elsif($fn eq "K") {
if($len == 99) { # Reformat for 13_KS300.pm
if($len == 15) { # Reformat for 13_KS300.pm
my @a = split("", $dmsg);
$dmsg = sprintf("81%02x04xx4027a001", $len/2+6);
for(my $i = 0; $i < 14; $i+=2) { # Swap nibbles.
$dmsg .= $a[$i+2] . $a[$i+1];
for(my $i = 1; $i < 14; $i+=2) { # Swap nibbles.
$dmsg .= $a[$i+1] . $a[$i];
}
}
# Other K... Messages ar sent to CUL_WS

View File

@ -9,10 +9,11 @@ my %defptr;
# Supports following devices:
# KS300TH (this is redirected to the more sophisticated 14_KS300 by 00_CUL)
# S300TH
#
#
# WS2000/WS7000
#
my $Station8 = "WS300";
my $Station4 = "WS7000";
#####################################
sub
@ -69,10 +70,15 @@ sub
CUL_WS_Parse($$)
{
my ($hash,$msg) = @_;
my %tlist = ("2"=>"rain",
my $name = $hash->{NAME};
my %tlist = ("0"=>"temp",
"1"=>"temp/hum",
"2"=>"rain",
"3"=>"wind",
"4"=>"temp/hum/press",
"5"=>"brightness");
"5"=>"brightness",
"6"=>"pyro",
"7"=>"temp/hum");
my @a = split("", $msg);
@ -81,73 +87,77 @@ CUL_WS_Parse($$)
my $cde = ($firstbyte&7) + 1;
my $type = $tlist{$a[2]} ? $tlist{$a[2]} : "unknown";
if(!$defptr{$cde}) {
Log 1, "CUL_WS UNDEFINED $type sensor detected, code $cde";
return "UNDEFINED CUL_WS: $cde";
}
my $def = $defptr{$cde};
return "" if($def->{IODev} && $def->{IODev}{NAME} ne $hash->{NAME});
if(!$defptr{$cde})
{
Log 1, "CUL_WS UNDEFINED $type sensor detected, code $cde";
# return "UNDEFINED CUL_WS: $cde";
}
my $tm=TimeNow();
$hash = $defptr{$cde};
my $name = $hash->{NAME};
my $typbyte = hex($a[2]) & 7;
my $sfirstbyte = $firstbyte & 7;
my $val = "";
my $devtype = "unknown";
if($sfirstbyte == 7) {
if($typbyte == 0) {
if($sfirstbyte == 7)
{
if($typbyte == 0)
{
my $sgn = ($firstbyte&8) ? -1 : 1;
my $tmp = $sgn * ($a[6].$a[3].".".$a[4]) + $hash->{corr1};
$val = "T: $tmp";
$devtype = "CUL_WS WS7000 Temp";
}
$devtype = "??? Temp";
}
if($typbyte == 1) {
if($typbyte == 1)
{
my $sgn = ($firstbyte&8) ? -1 : 1;
my $tmp = $sgn * ($a[6].$a[3].".".$a[4]) + $hash->{corr1};
my $hum = ($a[7].$a[8].".".$a[5]) + $hash->{corr2};
$val = "T: $tmp H: $hum";
$devtype = "CUL_WS WS7000 Temp/Hum";
}
$devtype = "$Station8 PS50";
}
if($typbyte == 2) {
if($typbyte == 2)
{
#my $more = ($firstbyte&8) ? 0 : 1000;
my $c = $hash->{corr1} ? $hash->{corr1} : 1;
my $hexcount = hex($a[5].$a[3].$a[4]) + $c;
$val = "R: $hexcount";
$devtype = "CUL_WS WS7000 Rain";
}
$devtype = "$Station4 Rain";
}
if($typbyte == 3) {
if($typbyte == 3)
{
my $hun = ($firstbyte&8) ? 100 : 0;
my $speed = ($a[6].$a[3].".".$a[4])+$hun;
my $dir = (($a[7]&3).$a[8].$a[5])+0;
my $swing = ($a[7]&6) >> 2;
$val = "W: $speed D: $dir A: $swing";
$devtype = "CUL_WS WS7000 Wind";
}
$devtype = "$Station4 Wind";
}
if($typbyte == 4) {
if($typbyte == 4)
{
my $sgn = ($firstbyte&8) ? -1 : 1;
my $tmp = $sgn * ($a[6].$a[3].".".$a[4]) + $hash->{corr1};
my $hum = ($a[7].$a[8].".".$a[5]) + $hash->{corr2};
my $prs = ($a[9].$a[10])+ 900 + $hash->{corr3};
if ($prs < 930) {
if ($prs < 930)
{
$prs = $prs + 100;
}
$val = "T: $tmp H: $hum P: $prs";
$devtype = "$Station4 Indoor";
}
if(@a == 13) {
$val = "T: $tmp H: $hum P: $prs";
} else {
$val = "T: $tmp H: $hum P: $prs lenerr";
}
$devtype = "CUL_WS WS7000 Indoor";
}
if($typbyte == 5) {
if($typbyte == 5)
{
my $fakt = 1;
my $rawfakt = ($a[5])+0;
if($rawfakt == 1) { $fakt = 10; }
@ -156,51 +166,93 @@ CUL_WS_Parse($$)
my $br = (hex($a[5].$a[4].$a[3])*$fakt) + $hash->{corr1};
$val = "B: $br";
$devtype = "CUL_WS WS7000 Brightness";
}
$devtype = "$Station4 Brightness";
}
if($typbyte == 6) { #wurde nie gebaut
$devtype = "CUL_WS WS7000 Pyro";
}
if($typbyte == 7) {
$devtype = "CUL_WS unknown";
}
if($typbyte == 6)
{ #wurde nie gebaut
$devtype = "$Station4 Pyro";
}
} else {
if($typbyte == 7)
{
# if(@a == 9)
# { # S300TH
# my $sgn = ($firstbyte&8) ? -1 : 1;
# my $tmp = $sgn * ($a[6].$a[3].".".$a[4]) + $hash->{corr1};
# my $hum = ($a[7].$a[8].".".$a[5]) + $hash->{corr2};
# $val = "T: $tmp H: $hum";
# $devtype = "S300TH";
# }
# elsif(@a == 15)
# { # KS300/2#
#
# my $c = $hash->{corr4} ? $hash->{corr4} : 255;
# my $rain = sprintf("%0.1f", hex("$a[14]$a[11]$a[12]") * $c / 1000);
# my $wnd = sprintf("%0.1f", "$a[9]$a[10].$a[7]" + $hash->{corr3});
# my $hum = sprintf( "%02d", "$a[8]$a[5]" + $hash->{corr2});
# my $tmp = sprintf("%0.1f", ("$a[6]$a[3].$a[4]"+$hash->{corr1}) *
# (($a[1] & 0xC) ? -1 : 1));
# my $ir = ((hex($a[1]) & 2)) ? "yes" : "no";
if(@a == 9) { # S300TH
# $val = "T: $tmp H: $hum W: $wnd R: $rain IR: $ir";
# $devtype = "KS300/2";
# }
# else
# {
my $sgn = ($firstbyte&8) ? -1 : 1;
my $tmp = $sgn * ($a[6].$a[3].".".$a[4]) + $hash->{corr1};
my $hum = ($a[7].$a[8].".".$a[5]) + $hash->{corr2};
$val = "T: $tmp H: $hum";
$devtype = "??? Temp/Hum";
# }
}
}
else
{
#$firstbyte not 7
if(@a == 9)
{ # S300TH
my $sgn = ($firstbyte&8) ? -1 : 1;
my $tmp = $sgn * ($a[6].$a[3].".".$a[4]) + $hash->{corr1};
my $hum = ($a[7].$a[8].".".$a[5]) + $hash->{corr2};
$val = "T: $tmp H: $hum";
$devtype = "$Station8 S300TH";
}
elsif(@a == 15)
{ # KS300/2
my $c = $hash->{corr4} ? $hash->{corr4} : 255;
my $rain = sprintf("%0.1f", hex("$a[14]$a[11]$a[12]") * $c / 1000);
my $wnd = sprintf("%0.1f", "$a[9]$a[10].$a[7]" + $hash->{corr3});
my $hum = sprintf( "%02d", "$a[8]$a[5]" + $hash->{corr2});
my $tmp = sprintf("%0.1f", ("$a[6]$a[3].$a[4]"+$hash->{corr1}) *
(($a[1] & 0xC) ? -1 : 1));
my $ir = ((hex($a[1]) & 2)) ? "yes" : "no";
$val = "T: $tmp H: $hum W: $wnd R: $rain IR: $ir";
$devtype = "$Station8 KS300/2";
}
else #WS7000 Temp/Hum sensors
{
my $sgn = ($firstbyte&8) ? -1 : 1;
my $tmp = $sgn * ($a[6].$a[3].".".$a[4]) + $hash->{corr1};
my $hum = ($a[7].$a[8].".".$a[5]) + $hash->{corr2};
$val = "T: $tmp H: $hum";
$devtype = "S300TH";
$devtype = "WS7000 TH".$sfirstbyte;
}
}
} elsif(@a == 15) { # KS300/2
Log GetLogLevel($name,3), "CUL_WS $devtype $name: $val";
my $c = $hash->{corr4} ? $hash->{corr4} : 255;
my $rain = sprintf("%0.1f", hex("$a[14]$a[11]$a[12]") * $c / 1000);
my $wnd = sprintf("%0.1f", "$a[9]$a[10].$a[7]" + $hash->{corr3});
my $hum = sprintf( "%02d", "$a[8]$a[5]" + $hash->{corr2});
my $tmp = sprintf("%0.1f", ("$a[6]$a[3].$a[4]"+$hash->{corr1}) *
(($a[1] & 0xC) ? -1 : 1));
my $ir = ((hex($a[1]) & 2)) ? "yes" : "no";
$hash->{STATE} = $val; # List overview
$hash->{READINGS}{state}{TIME} = TimeNow(); # For list
$hash->{READINGS}{state}{VAL} = $val;
$hash->{CHANGED}[0] = $val; # For notify
$hash->{READINGS}{$devtype}{VAL}=$val;
$hash->{READINGS}{$devtype}{TIME}=$tm;
$val = "T: $tmp H: $hum W: $wnd R: $rain IR: $ir";
$devtype = "KS300/2";
}
}
Log GetLogLevel($name,4), "CUL_WS $devtype sensor $name: $val";
$hash->{STATE} = $val; # List overview
$hash->{READINGS}{state}{TIME} = TimeNow(); # For list
$hash->{READINGS}{state}{VAL} = $val;
$hash->{CHANGED}[0] = $val; # For notify
return $name;
return $name;
}
1;