2
0
mirror of https://github.com/fhem/fhem-mirror.git synced 2025-01-31 06:39:11 +00:00

51_MOBILEALERTS: Perl Warnings and Init RainSensor

git-svn-id: https://svn.fhem.de/fhem/trunk@23556 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
MarkusF 2021-01-19 18:06:03 +00:00
parent 8a8cdf5a2b
commit 6742dfb1a0
2 changed files with 11 additions and 7 deletions

View File

@ -1,5 +1,6 @@
# Add changes at the top of the list. Keep it in ASCII, and 80-char wide. # Add changes at the top of the list. Keep it in ASCII, and 80-char wide.
# Do not insert empty lines here, update check depends on it. # Do not insert empty lines here, update check depends on it.
- bugfix: 51_MOBILEALERTS: Perl Warnings and Init RainSensor
- bugfix: 57_Calendar: correct event selection for - bugfix: 57_Calendar: correct event selection for
limit:when=tomorrow (forum #97810) limit:when=tomorrow (forum #97810)
- feature: 36_ShellyModule: new module to interwork with 36_Shelly - feature: 36_ShellyModule: new module to interwork with 36_Shelly

View File

@ -27,6 +27,7 @@ sub MOBILEALERTS_Initialize($) {
$hash->{AutoCreate} = { $hash->{AutoCreate} = {
"MA_.*" => { "MA_.*" => {
ATTR => "event-on-change-reading:.* timestamp-on-change-reading:.*", ATTR => "event-on-change-reading:.* timestamp-on-change-reading:.*",
GPLOT => "",
FILTER => "%NAME" FILTER => "%NAME"
} }
}; };
@ -678,11 +679,13 @@ sub MOBILEALERTS_Parse_e1 ($$) {
unpack( "nnnnnnnnnnnn", $message ); unpack( "nnnnnnnnnnnn", $message );
my $lastEventCounter = ReadingsVal( $hash->{NAME}, "eventCounter", undef ); my $lastEventCounter = ReadingsVal( $hash->{NAME}, "eventCounter", undef );
my $mmRain = 0; my $mmRain = 0;
my $mmRainOffset = 0;
if ( !defined($lastEventCounter) ) { if ( !defined($lastEventCounter) ) {
# First Data # First Data
$mmRain = $eventCounter * MA_RAIN_FACTOR; $mmRainOffset = $eventCounter * MA_RAIN_FACTOR;
$mmRain = 0;
} }
elsif ( $lastEventCounter > $eventCounter ) { elsif ( $lastEventCounter > $eventCounter ) {
@ -695,7 +698,7 @@ sub MOBILEALERTS_Parse_e1 ($$) {
else { else {
$mmRain = 0; $mmRain = 0;
} }
MOBILEALERTS_CheckRainSensor( $hash, $mmRain ); MOBILEALERTS_CheckRainSensor( $hash, $mmRain, $mmRainOffset );
MOBILEALERTS_readingsBulkUpdate( $hash, 0, "txCounter", MOBILEALERTS_readingsBulkUpdate( $hash, 0, "txCounter",
MOBILEALERTS_decodeTxCounter($txCounter) ); MOBILEALERTS_decodeTxCounter($txCounter) );
MOBILEALERTS_readingsBulkUpdate( $hash, 0, "triggered", MOBILEALERTS_readingsBulkUpdate( $hash, 0, "triggered",
@ -1348,7 +1351,7 @@ sub MOBILEALERTS_CheckRainSensorTimed($) {
my ($hash) = @_; my ($hash) = @_;
$hash->{".expertMode"} = AttrVal( $hash->{NAME}, "expert", 0 ); $hash->{".expertMode"} = AttrVal( $hash->{NAME}, "expert", 0 );
readingsBeginUpdate($hash); readingsBeginUpdate($hash);
MOBILEALERTS_CheckRainSensor( $hash, 0 ); MOBILEALERTS_CheckRainSensor( $hash, 0, 0);
readingsEndUpdate( $hash, 1 ); readingsEndUpdate( $hash, 1 );
InternalTimer( InternalTimer(
time_str2num( time_str2num(
@ -1359,8 +1362,8 @@ sub MOBILEALERTS_CheckRainSensorTimed($) {
); );
} }
sub MOBILEALERTS_CheckRainSensor($$) { sub MOBILEALERTS_CheckRainSensor($$$) {
my ( $hash, $mmRain ) = @_; my ( $hash, $mmRain, $mmRainOffset ) = @_;
#Event #Event
push @{ $hash->{CHANGED} }, "rain" if ( $mmRain > 0 ); push @{ $hash->{CHANGED} }, "rain" if ( $mmRain > 0 );
@ -1423,8 +1426,8 @@ sub MOBILEALERTS_CheckRainSensor($$) {
if ( $mmRain > 0 ); if ( $mmRain > 0 );
} }
MOBILEALERTS_readingsBulkUpdate( $hash, 0, "mmRain", MOBILEALERTS_readingsBulkUpdate( $hash, 0, "mmRain",
$mmRain + ReadingsVal( $hash->{NAME}, "mmRain", "0" ) ) $mmRain + $mmRainOffset + ReadingsVal( $hash->{NAME}, "mmRain", "0" ) )
if ( $mmRain > 0 ); if ( $mmRain + $mmRainOffset > 0 );
} }
sub MOBILEALERTS_ActionDetector($) { sub MOBILEALERTS_ActionDetector($) {