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

BS and USF1000 modules updated to readingsFN mechanism

git-svn-id: https://svn.fhem.de/fhem/trunk@2540 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
borisneubert 2013-01-20 16:16:50 +00:00
parent eaa47d7635
commit 00a67f9161
2 changed files with 22 additions and 27 deletions

View File

@ -22,7 +22,7 @@ BS_Initialize($)
$hash->{UndefFn} = "BS_Undef";
$hash->{ParseFn} = "BS_Parse";
$hash->{AttrList} = "do_not_notify:1,0 showtime:0,1 ".
"ignore:1,0 model:BS loglevel:0,1,2,3,4,5,6";
"ignore:1,0 model:BS loglevel:0,1,2,3,4,5,6 " . $readingFnAttributes;
}
@ -110,18 +110,13 @@ BS_Parse($$)
my $state= sprintf("brightness: %.2f lux: %.0f flags: %d",
$brightness, $lux, $flags);
$def->{CHANGED}[0] = $state;
$def->{STATE} = $state;
$def->{READINGS}{state}{TIME} = $t;
$def->{READINGS}{state}{VAL} = $state;
Log GetLogLevel($name, 4), "BS $name: $state";
$def->{READINGS}{brightness}{TIME} = $t;
$def->{READINGS}{brightness}{VAL} = $brightness;
$def->{READINGS}{lux}{TIME} = $t;
$def->{READINGS}{lux}{VAL} = $lux;
$def->{READINGS}{flags}{TIME} = $t;
$def->{READINGS}{flags}{VAL} = $flags;
readingsBeginUpdate($def);
readingsBulkUpdate($def, "state", $state);
#Log GetLogLevel($name, 4), "BS $name: $state";
readingsBulkUpdate($def, "brightness", $brightness);
readingsBulkUpdate($def, "lux", $lux);
readingsBulkUpdate($def, "flags", $flags);
readingsEndUpdate($def, 0);
return $name;
@ -194,6 +189,7 @@ BS_Parse($$)
<li><a href="#loglevel">loglevel</a></li>
<li><a href="#model">model</a> (bs)</li>
<li><a href="#ignore">ignore</a></li>
<li><a href="#readingFnAttributes">readingFnAttributes</a></li>
</ul>
<br>

View File

@ -26,7 +26,7 @@ USF1000_Initialize($)
$hash->{UndefFn} = "USF1000_Undef";
$hash->{ParseFn} = "USF1000_Parse";
$hash->{AttrList} = "IODev do_not_notify:1,0 ignore:0,1 showtime:0,1 " .
"model:usf1000s loglevel:0,1,2,3,4,5,6";
"model:usf1000s loglevel:0,1,2,3,4,5,6 " . $readingFnAttributes;
}
@ -116,6 +116,7 @@ USF1000_Parse($$)
my $distance= hex($xx)/100.0; # in meters
my $valid= (($distance>0.00) && ($distance<2.55));
readingsBeginUpdate($def);
if($valid) {
my $wlevel = $def->{HEIGHT}-($distance-$def->{OFFSET}); # water level
@ -144,18 +145,14 @@ USF1000_Parse($$)
my $state= sprintf("v: %d V: %d", $flevel, $volume);
$def->{CHANGED}[0] = $state;
$def->{STATE} = $state;
$def->{READINGS}{state}{TIME} = $t;
$def->{READINGS}{state}{VAL} = $state;
Log GetLogLevel($name, 4), "USF1000 $name: $state";
readingsBulkUpdate($def, "state", $state);
readingsBulkUpdate($def, "distance", $distance);
readingsBulkUpdate($def, "level", $flevel);
readingsBulkUpdate($def, "volume", $volume);
#Log GetLogLevel($name, 4), "USF1000 $name: $state";
#Debug "USF1000 $name: $state";
$def->{READINGS}{distance}{TIME} = $t;
$def->{READINGS}{distance}{VAL} = $distance;
$def->{READINGS}{level}{TIME} = $t;
$def->{READINGS}{level}{VAL} = $flevel;
$def->{READINGS}{volume}{TIME} = $t;
$def->{READINGS}{volume}{VAL} = $volume;
}
}
@ -166,8 +163,9 @@ USF1000_Parse($$)
}
$warnings= $warnings ? $warnings : "none";
$def->{READINGS}{"warnings"}{TIME} = $t;
$def->{READINGS}{"warnings"}{VAL} = $warnings;
readingsBulkUpdate($def, "warnings", $warnings);
readingsEndUpdate($def, 0);
return $name;
@ -246,6 +244,7 @@ USF1000_Parse($$)
<li><a href="#loglevel">loglevel</a></li>
<li><a href="#model">model</a> (usf1000s)</li>
<li><a href="#ignore">ignore</a></li>
<li><a href="#readingFnAttributes">readingFnAttributes</a></li>
</ul>
<br>