2
0
mirror of https://github.com/fhem/fhem-mirror.git synced 2025-01-31 12:49:34 +00:00

finalized 09_BS.pm and documentation

git-svn-id: https://svn.fhem.de/fhem/trunk@446 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
borisneubert 2009-10-11 20:34:30 +00:00
parent 56c0de9afb
commit 6e8d02a693
4 changed files with 104 additions and 23 deletions

View File

@ -24,7 +24,7 @@ BS_Initialize($)
$hash->{DefFn} = "BS_Define"; $hash->{DefFn} = "BS_Define";
$hash->{UndefFn} = "BS_Undef"; $hash->{UndefFn} = "BS_Undef";
$hash->{ParseFn} = "BS_Parse"; $hash->{ParseFn} = "BS_Parse";
$hash->{AttrList} = "IODev do_not_notify:1,0 showtime:0,1 dummy:1,0 model:BSs loglevel:0,1,2,3,4,5,6"; $hash->{AttrList} = "IODev do_not_notify:1,0 showtime:0,1 dummy:1,0 model:BS loglevel:0,1,2,3,4,5,6";
} }
@ -36,20 +36,20 @@ BS_Define($$)
my ($hash, $def) = @_; my ($hash, $def) = @_;
my @a = split("[ \t][ \t]*", $def); my @a = split("[ \t][ \t]*", $def);
my $u= "wrong syntax: define <name> BS <sensor> [factor]"; my $u= "wrong syntax: define <name> BS <sensor> [RExt]";
return $u if((int(@a)< 3) || (int(@a)>4)); return $u if((int(@a)< 3) || (int(@a)>4));
my $name = $a[0]; my $name = $a[0];
my $sensor = $a[2]; my $sensor = $a[2];
if($sensor !~ /[1..9]/) { if($sensor !~ /[123456789]/) {
return "erroneous sensor specification $sensor, use one of 1..9"; return "erroneous sensor specification $sensor, use one of 1..9";
} }
$sensor= "0$sensor"; $sensor= "0$sensor";
my $factor = 1.0; my $RExt = 50000; # default is 50kOhm
$factor= $a[3] if(int(@a)==4); $RExt= $a[3] if(int(@a)==4);
$hash->{SENSOR}= "$sensor"; $hash->{SENSOR}= "$sensor";
$hash->{FACTOR}= $factor; $hash->{RExt}= $RExt;
my $dev= "a5cf $sensor"; my $dev= "a5cf $sensor";
$hash->{DEF}= $dev; $hash->{DEF}= $dev;
@ -96,10 +96,16 @@ BS_Parse($$)
my $flags= hex(substr($msg, 24, 1)) & 0xdc; my $flags= hex(substr($msg, 24, 1)) & 0xdc;
my $value= hex(substr($msg, 25, 3)) & 0x3ff; my $value= hex(substr($msg, 25, 3)) & 0x3ff;
my $factor= $def->{FACTOR}; my $RExt= $def->{RExt};
my $brightness= $value/10.24*$factor; my $brightness= $value/10.24; # Vout in percent of reference voltage 1.1V
my $state= sprintf("brightness: %.2f flags: %d", $brightness, $flags); # 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;
my $state= sprintf("brightness: %.2f lux: %.0f flags: %d",
$brightness, $lux, $flags);
$def->{CHANGED}[0] = $state; $def->{CHANGED}[0] = $state;
$def->{STATE} = $state; $def->{STATE} = $state;
@ -109,6 +115,8 @@ BS_Parse($$)
$def->{READINGS}{brightness}{TIME} = $t; $def->{READINGS}{brightness}{TIME} = $t;
$def->{READINGS}{brightness}{VAL} = $brightness; $def->{READINGS}{brightness}{VAL} = $brightness;
$def->{READINGS}{lux}{TIME} = $t;
$def->{READINGS}{lux}{VAL} = $lux;
$def->{READINGS}{flags}{TIME} = $t; $def->{READINGS}{flags}{TIME} = $t;
$def->{READINGS}{flags}{VAL} = $flags; $def->{READINGS}{flags}{VAL} = $flags;

View File

@ -144,7 +144,7 @@ FHT_Initialize($)
$hash->{UndefFn} = "FHT_Undef"; $hash->{UndefFn} = "FHT_Undef";
$hash->{ParseFn} = "FHT_Parse"; $hash->{ParseFn} = "FHT_Parse";
$hash->{AttrList} = "IODev do_not_notify:0,1 model;fht80b dummy:0,1 " . $hash->{AttrList} = "IODev do_not_notify:0,1 model;fht80b dummy:0,1 " .
"showtime:0,1 loglevel:0,1,2,3,4,5,6 retrycount minfhtbuffer". "showtime:0,1 loglevel:0,1,2,3,4,5,6 retrycount minfhtbuffer ".
"lazy tmpcorr"; "lazy tmpcorr";
} }
@ -237,7 +237,9 @@ FHT_Set($@)
} }
if($lazy && defined($readings->{$cmd}) && $readings->{$cmd}{VAL} eq $val) { if($lazy &&
$cmd ne "report1" && $cmd ne "report2" && $cmd ne "refreshvalues" &&
defined($readings->{$cmd}) && $readings->{$cmd}{VAL} eq $val) {
$ret .= "Lazy mode ignores $cmd"; $ret .= "Lazy mode ignores $cmd";
Log GetLogLevel($name,2), "Lazy mode ignores $cmd $val"; Log GetLogLevel($name,2), "Lazy mode ignores $cmd $val";

View File

@ -425,4 +425,11 @@
- 00_CM11.pm: feature: get time, fwrev, set reopen for CM11 (Boris 2009-09-12) - 00_CM11.pm: feature: get time, fwrev, set reopen for CM11 (Boris 2009-09-12)
- Sun Sep 20 2009 (Boris) - Sun Sep 20 2009 (Boris)
- Module 09_BS.pm for brightness sensor added (Boris 2009-09-20) - Module 09_BS.pm for brightness sensor added (Boris 2009-09-20)
- Sat Oct 03 2009 (Boris)
- bugfix: missing blank in attribute list for FHT; exclude report from lazy
- typos and anchors in documentation corrected
- Sun Oct11 2009 (Boris)
- finalized 09_BS.pm and documentation

View File

@ -49,6 +49,7 @@
<ul> <ul>
<a href="#global">global</a><br> <a href="#global">global</a><br>
<a href="#BS">BS</a> &nbsp;
<a href="#CM11">CM11</a> &nbsp; <a href="#CM11">CM11</a> &nbsp;
<a href="#CUL">CUL</a> &nbsp; <a href="#CUL">CUL</a> &nbsp;
<a href="#CUL_EM">CUL_EM</a> &nbsp; <a href="#CUL_EM">CUL_EM</a> &nbsp;
@ -1009,7 +1010,7 @@ A line ending with \ will be concatenated with the next one, so long lines
Disable FileLog/notify/inform notification for a device. This affects Disable FileLog/notify/inform notification for a device. This affects
the received signal, the set and trigger commands.</li><br> the received signal, the set and trigger commands.</li><br>
<li><a href="#dummy">dummy</a></li><br> <li><a href="#attrdummy">dummy</a></li><br>
<a name="filtertimeout"></a> <a name="filtertimeout"></a>
<li>filtertimeout<br> <li>filtertimeout<br>
@ -1425,7 +1426,7 @@ A line ending with \ will be concatenated with the next one, so long lines
<b>Attributes</b> <b>Attributes</b>
<ul> <ul>
<li><a href="#do_not_notify">do_not_notify</a></li><br> <li><a href="#do_not_notify">do_not_notify</a></li><br>
<li><a href="#dummy">dummy</a></li><br> <li><a href="#attrdummy">dummy</a></li><br>
<li><a href="#loglevel">loglevel</a></li><br> <li><a href="#loglevel">loglevel</a></li><br>
<li><a href="#model">model</a> (fht80b)</li><br> <li><a href="#model">model</a> (fht80b)</li><br>
<li><a href="#showtime">showtime</a></li><br> <li><a href="#showtime">showtime</a></li><br>
@ -1625,7 +1626,7 @@ A line ending with \ will be concatenated with the next one, so long lines
<b>Attributes</b> <b>Attributes</b>
<ul> <ul>
<li><a href="#do_not_notify">do_not_notify</a></li><br> <li><a href="#do_not_notify">do_not_notify</a></li><br>
<li><a href="#dummy">dummy</a></li><br> <li><a href="#attrdummy">dummy</a></li><br>
<li><a href="#filtertimeout">filtertimeout</a></li><br> <li><a href="#filtertimeout">filtertimeout</a></li><br>
<li><a href="#repeater">repeater</a></li><br> <li><a href="#repeater">repeater</a></li><br>
<li><a href="#showtime">showtime</a></li><br> <li><a href="#showtime">showtime</a></li><br>
@ -1787,7 +1788,7 @@ A line ending with \ will be concatenated with the next one, so long lines
<b>Attributes</b> <b>Attributes</b>
<ul> <ul>
<li><a href="#model">model</a> (em1010pc)</li> <li><a href="#model">model</a> (em1010pc)</li>
<li><a href="#dummy">dummy</a></li> <li><a href="#attrdummy">dummy</a></li>
<li><a href="#loglevel">loglevel</a></li> <li><a href="#loglevel">loglevel</a></li>
</ul> </ul>
<br> <br>
@ -1849,7 +1850,7 @@ A line ending with \ will be concatenated with the next one, so long lines
<b>Attributes</b> <b>Attributes</b>
<ul> <ul>
<li><a href="#model">model</a> (EM1000WZ)</li> <li><a href="#model">model</a> (EM1000WZ)</li>
<li><a href="#dummy">dummy</a></li> <li><a href="#attrdummy">dummy</a></li>
<li><a href="#loglevel">loglevel</a></li> <li><a href="#loglevel">loglevel</a></li>
<li><a href="#IODev">IODev</a></li><br> <li><a href="#IODev">IODev</a></li><br>
</ul> </ul>
@ -1903,7 +1904,7 @@ A line ending with \ will be concatenated with the next one, so long lines
<b>Attributes</b> <b>Attributes</b>
<ul> <ul>
<li><a href="#model">model</a> (EM1000GZ)</li> <li><a href="#model">model</a> (EM1000GZ)</li>
<li><a href="#dummy">dummy</a></li> <li><a href="#attrdummy">dummy</a></li>
<li><a href="#loglevel">loglevel</a></li> <li><a href="#loglevel">loglevel</a></li>
<li><a href="#IODev">IODev</a></li><br> <li><a href="#IODev">IODev</a></li><br>
</ul> </ul>
@ -1950,7 +1951,7 @@ A line ending with \ will be concatenated with the next one, so long lines
<b>Attributes</b> <b>Attributes</b>
<ul> <ul>
<li><a href="#model">model</a> (EM1000EM)</li> <li><a href="#model">model</a> (EM1000EM)</li>
<li><a href="#dummy">dummy</a></li> <li><a href="#attrdummy">dummy</a></li>
<li><a href="#loglevel">loglevel</a></li> <li><a href="#loglevel">loglevel</a></li>
<li><a href="#IODev">IODev</a></li><br> <li><a href="#IODev">IODev</a></li><br>
</ul> </ul>
@ -2078,7 +2079,7 @@ A line ending with \ will be concatenated with the next one, so long lines
<b>Attributes</b> <b>Attributes</b>
<ul> <ul>
<li><a href="#do_not_notify">do_not_notify</a></li> <li><a href="#do_not_notify">do_not_notify</a></li>
<li><a href="#dummy">dummy</a></li> <li><a href="#attrdummy">dummy</a></li>
<li><a href="#loglevel">loglevel</a></li> <li><a href="#loglevel">loglevel</a></li>
<li><a href="#model">model</a> (CM11)</li> <li><a href="#model">model</a> (CM11)</li>
</ul> </ul>
@ -2182,7 +2183,7 @@ A line ending with \ will be concatenated with the next one, so long lines
<ul> <ul>
<li><a href="#follow-on-for-timer">follow-on-for-timer</a></li><br> <li><a href="#follow-on-for-timer">follow-on-for-timer</a></li><br>
<li><a href="#do_not_notify">do_not_notify</a></li><br> <li><a href="#do_not_notify">do_not_notify</a></li><br>
<li><a href="#dummy">dummy</a></li><br> <li><a href="#attrdummy">dummy</a></li><br>
<li><a href="#showtime">showtime</a></li><br> <li><a href="#showtime">showtime</a></li><br>
<li><a href="#model">model</a> (lm12,lm15,am12,tm13)</li><br> <li><a href="#model">model</a> (lm12,lm15,am12,tm13)</li><br>
<li><a href="#loglevel">loglevel</a></li> <li><a href="#loglevel">loglevel</a></li>
@ -2409,6 +2410,69 @@ A line ending with \ will be concatenated with the next one, so long lines
</ul> </ul>
<a name="BS"></a>
<h3>BS</h3>
<ul>
The module BS allows to collect data from a brightness sensor through a
<a href="#FHZ">FHZ</a> device. For details on the brightness sensor see
<a href="http://www.busware.de/tiki-index.php?page=CPM-BS">busware wiki</a>.
You can have at most nine different brightness sensors in range of your
FHZ.<br>
<br>
The state contains the brightness in % (reading <code>brightness</code>) and
the brightness in lux (reading <code>lux</code>). The <code>flags</code>
reading is always zero. The meaning of these readings is explained in more
detail on the above mentioned wiki page.<br>
<br>
<a name="BSDefine"></a>
<b>Define</b>
<ul>
<code>define &lt;name&gt; BS &lt;sensor#&gt; [&lt;RExt&gt;]</code>
<br><br>
<code>&lt;sensor#&gt;</code> is the number of sensor in the brightness
sensor address system that runs from 1 to 9.<br>
<br>
<code>&lt;RExt&gt;</code> is the value of the resistor on your brightness
sensor in &Omega; (Ohm). The brightness reading in % is proportional to the resistance, the
lux reading is proportional to the resistance squared. The value is
optional. The default resistance is RExt= 50.000&Omega;.<br>
<br>
Example:<br>
<ul>
<code>define bs1 BS 1 40000</code><br>
</ul>
</ul>
<br>
<b>Set </b>
<ul>
N/A
</ul>
<br>
<b>Get</b>
<ul>
N/A
</ul>
<br>
<b>Attributes</b>
<ul>
<li><a href="#do_not_notify">do_not_notify</a></li>
<li><a href="#showtime">showtime</a></li>
<li><a href="#loglevel">loglevel</a></li>
<li><a href="#model">model</a> (bs)</li>
</ul>
<br>
</ul>
<a name="SCIVT"></a> <a name="SCIVT"></a>
<h3>SCIVT</h3> <h3>SCIVT</h3>
@ -2610,7 +2674,7 @@ A line ending with \ will be concatenated with the next one, so long lines
<b>Attributes</b> <b>Attributes</b>
<ul> <ul>
<li><a href="#dummy">dummy</a></li><br> <li><a href="#attrdummy">dummy</a></li><br>
<li><a href="#loglevel">loglevel</a></li> <li><a href="#loglevel">loglevel</a></li>
<li><a href="#model">model</a> (M232Counter)</li> <li><a href="#model">model</a> (M232Counter)</li>
</ul> </ul>
@ -2657,7 +2721,7 @@ A line ending with \ will be concatenated with the next one, so long lines
<b>Attributes</b> <b>Attributes</b>
<ul> <ul>
<li><a href="#dummy">dummy</a></li><br> <li><a href="#attrdummy">dummy</a></li><br>
<li><a href="#loglevel">loglevel</a></li> <li><a href="#loglevel">loglevel</a></li>
<li><a href="#model">model</a> (M232Voltage)</li> <li><a href="#model">model</a> (M232Voltage)</li>
</ul> </ul>