bugfix: make BS known to CUL to avoid lost messages if both FHZ1300 and CUL are connected, adjust matching rule

git-svn-id: https://svn.fhem.de/fhem/trunk/fhem@641 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
borisneubert 2010-05-30 09:31:48 +00:00
parent d99a49d0d1
commit 612c66c222
5 changed files with 32 additions and 18 deletions

View File

@ -11,6 +11,8 @@
- feature: Dimmer function of X10 module changed to match FS20
- feature: allow only meaningful readings (fill level > -5%) in USF1000
- feature: device attr links in commandref.html
- bugfix: make BS known to CUL to avoid lost messages if both FHZ1300 and CUL
are connected, adjust matching rule
- 2010-03-13 (4.9)
- bugfix: changed the fhem prompt from FHZ> to fhem>

View File

@ -55,19 +55,20 @@ CUL_Initialize($)
$hash->{ReadFn} = "CUL_Read";
$hash->{WriteFn} = "CUL_Write";
$hash->{Clients} =
":FS20:FHT:KS300:CUL_EM:CUL_WS:USF1000:HMS:CUL_FHTTK:CUL_RFR:FHT8V".
":FS20:FHT:KS300:CUL_EM:CUL_WS:USF1000:BS:HMS:CUL_FHTTK:CUL_RFR:FHT8V".
":CUL_HOERMANN:";
my %mc = (
"1:USF1000" => "^81..(04|0c)..0101a001a5ceaa00....",
"2:FS20" => "^81..(04|0c)..0101a001",
"3:FHT" => "^81..(04|09|0d)..(0909a001|83098301|c409c401)..",
"4:KS300" => "^810d04..4027a001",
"5:CUL_WS" => "^K.....",
"6:CUL_EM" => "^E0.................\$",
"7:HMS" => "^810e04....(1|5|9).a001",
"8:CUL_FHTTK" => "^T........",
"9:CUL_RFR" => "^[0-9A-F]{4}U.",
"A:CUL_HOERMANN"=> "^R..........",
"2:BS" => "^81..(04|0c)..0101a001a5cf",
"3:FS20" => "^81..(04|0c)..0101a001",
"4:FHT" => "^81..(04|09|0d)..(0909a001|83098301|c409c401)..",
"5:KS300" => "^810d04..4027a001",
"6:CUL_WS" => "^K.....",
"7:CUL_EM" => "^E0.................\$",
"8:HMS" => "^810e04....(1|5|9).a001",
"9:CUL_FHTTK" => "^T........",
"A:CUL_RFR" => "^[0-9A-F]{4}U.",
"B:CUL_HOERMANN"=> "^R..........",
);
$hash->{MatchList} = \%mc;
$hash->{ReadyFn} = "CUL_Ready";

View File

@ -60,7 +60,7 @@ FHZ_Initialize($)
$hash->{Clients} = ":FHZ:FS20:FHT:HMS:KS300:USF1000:BS:";
my %mc = (
"1:USF1000" => "^81..(04|0c)..0101a001a5ceaa00....",
"2:BS" => "^81..(04|0c)..0101a001a5cf......",
"2:BS" => "^81..(04|0c)..0101a001a5cf",
"3:FS20" => "^81..(04|0c)..0101a001",
"4:FHT" => "^81..(04|09|0d)..(0909a001|83098301|c409c401)..",
"5:HMS" => "^810e04....(1|5|9).a001",

View File

@ -10,15 +10,13 @@ package main;
use strict;
use warnings;
my $PI= 3.141592653589793238;
#############################
sub
BS_Initialize($)
{
my ($hash) = @_;
$hash->{Match} = "^81..(04|0c)..0101a001a5cf......";
$hash->{Match} = "^81..(04|0c)..0101a001a5cf";
$hash->{DefFn} = "BS_Define";
$hash->{UndefFn} = "BS_Undef";
$hash->{ParseFn} = "BS_Parse";
@ -27,7 +25,6 @@ BS_Initialize($)
}
#############################
sub
BS_Define($$)
@ -35,8 +32,8 @@ BS_Define($$)
my ($hash, $def) = @_;
my @a = split("[ \t][ \t]*", $def);
my $u= "wrong syntax: define <name> BS <sensor> [RExt]";
return $u if((int(@a)< 3) || (int(@a)>4));
my $u= "wrong syntax: define <name> BS <sensor> [[RExt] luxOffset]";
return $u if((int(@a)< 3) || (int(@a)>5));
my $name = $a[0];
my $sensor = $a[2];
@ -46,9 +43,12 @@ BS_Define($$)
$sensor= "0$sensor";
my $RExt = 50000; # default is 50kOhm
$RExt= $a[3] if(int(@a)==4);
$RExt= $a[3] if(int(@a)>=4);
my $luxOffset= 0; # default is no offset
$luxOffset= $a[4] if(int(@a)>=5);
$hash->{SENSOR}= "$sensor";
$hash->{RExt}= $RExt;
$hash->{luxOffset}= $luxOffset;
my $dev= "a5cf $sensor";
$hash->{DEF}= $dev;
@ -97,12 +97,14 @@ BS_Parse($$)
my $value= hex(substr($msg, 25, 3)) & 0x3ff;
my $RExt= $def->{RExt};
my $luxOffset= $def->{luxOffset};
my $brightness= $value/10.24; # Vout in percent of reference voltage 1.1V
# brightness in lux= 100lux*(VOut/RExt/1.8muA)^2;
my $VOut= $value*1.1/1024.0;
my $temp= $VOut/$RExt/1.8E-6;
my $lux= 100.0*$temp*$temp;
$lux+= $luxOffset; # add lux offset
my $state= sprintf("brightness: %.2f lux: %.0f flags: %d",
$brightness, $lux, $flags);

View File

@ -205,6 +205,15 @@ DbLog_ParseEvent($$)
if($reading eq "humidity") { $unit= "%"; }
}
# BS
elsif($type eq "BS") {
if($event =~ m(brightness:.*)) {
@parts= split(/ /,$event);
$reading= "lux";
$value= $parts[4]*1.;
$unit= "lux";
}
}
@result= ($reading,$value,$unit);
return @result;