mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-03-09 14:47:00 +00:00
73_AutoShuttersControl: new RainProtection package
git-svn-id: https://svn.fhem.de/fhem/trunk@24460 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
3961717cdb
commit
7a39e88b07
@ -1,5 +1,6 @@
|
||||
# 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.
|
||||
- feature: 73_AutoShuttersControl: new RainProtection package
|
||||
- change: 49_IPCAM: allow zero for snapshots attribute, and some cleanup.
|
||||
- change: 93_DbLog: some minor changes, e.g. PID Info in Log Output
|
||||
- change: doif.js: tolerate dots in element id, cleanup
|
||||
|
@ -1058,8 +1058,8 @@ sub CreateSunRiseSetShuttersTimer {
|
||||
);
|
||||
|
||||
my $name = $hash->{NAME};
|
||||
my $shuttersDevHash = $defs{$shuttersDev} // Log3( $hash->{NAME}, 1,
|
||||
"AutoShuttersControl ($hash->{NAME}) - Error in function CreateSunRiseSetShuttersTimer. No shuttersDevHash given"
|
||||
my $shuttersDevHash = $defs{$shuttersDev} // return Log3( $hash->{NAME}, 1,
|
||||
"AutoShuttersControl ($hash->{NAME}) - Error in function CreateSunRiseSetShuttersTimer. No shuttersDevHash found for device name $shuttersDev"
|
||||
);
|
||||
my %funcHash;
|
||||
$shutters->setShuttersDev($shuttersDev);
|
||||
|
@ -2,7 +2,7 @@
|
||||
#
|
||||
# Developed with Kate
|
||||
#
|
||||
# (c) 2018-2020 Copyright: Marko Oldenburg (fhemsupport@cooltux.net)
|
||||
# (c) 2018-2021 Copyright: Marko Oldenburg (fhemdevelopment@cooltux.net)
|
||||
# All rights reserved
|
||||
#
|
||||
# Special thanks goes to:
|
||||
@ -49,6 +49,7 @@ use Data::Dumper; #only for Debugging
|
||||
|
||||
use FHEM::Automation::ShuttersControl::Helper qw (:ALL);
|
||||
use FHEM::Automation::ShuttersControl::Shading qw (:ALL);
|
||||
use FHEM::Automation::ShuttersControl::Rainprotection qw (:ALL);
|
||||
|
||||
require Exporter;
|
||||
our @ISA = qw(Exporter);
|
||||
@ -1276,70 +1277,12 @@ sub EventProcessingRain {
|
||||
$FHEM::Automation::ShuttersControl::ascDev->getRainTriggerMax;
|
||||
my $triggerMin =
|
||||
$FHEM::Automation::ShuttersControl::ascDev->getRainTriggerMin;
|
||||
my $closedPos = $FHEM::Automation::ShuttersControl::ascDev
|
||||
->getRainSensorShuttersClosedPos;
|
||||
|
||||
if ( $1 eq 'rain' ) { $val = $triggerMax + 1 }
|
||||
elsif ( $1 eq 'dry' ) { $val = $triggerMin }
|
||||
else { $val = $1 }
|
||||
|
||||
RainProtection( $hash, $val, $triggerMax, $triggerMin, $closedPos );
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
sub RainProtection {
|
||||
my ( $hash, $val, $triggerMax, $triggerMin, $closedPos ) = @_;
|
||||
|
||||
for my $shuttersDev ( @{ $hash->{helper}{shuttersList} } ) {
|
||||
$FHEM::Automation::ShuttersControl::shutters->setShuttersDev(
|
||||
$shuttersDev);
|
||||
|
||||
next
|
||||
if (
|
||||
$FHEM::Automation::ShuttersControl::shutters->getRainProtection eq
|
||||
'off' );
|
||||
|
||||
if ( $val > $triggerMax
|
||||
&& $FHEM::Automation::ShuttersControl::shutters->getStatus !=
|
||||
$closedPos
|
||||
&& $FHEM::Automation::ShuttersControl::shutters
|
||||
->getRainProtectionStatus eq 'unprotected' )
|
||||
{
|
||||
$FHEM::Automation::ShuttersControl::shutters->setLastDrive(
|
||||
'rain protected');
|
||||
$FHEM::Automation::ShuttersControl::shutters->setDriveCmd(
|
||||
$closedPos);
|
||||
$FHEM::Automation::ShuttersControl::shutters
|
||||
->setRainProtectionStatus('protected');
|
||||
}
|
||||
elsif ( ( $val == 0 || $val < $triggerMin )
|
||||
&& $FHEM::Automation::ShuttersControl::shutters->getStatus ==
|
||||
$closedPos
|
||||
&& IsAfterShuttersManualBlocking($shuttersDev)
|
||||
&& $FHEM::Automation::ShuttersControl::shutters
|
||||
->getRainProtectionStatus eq 'protected' )
|
||||
{
|
||||
$FHEM::Automation::ShuttersControl::shutters->setLastDrive(
|
||||
'rain un-protected');
|
||||
$FHEM::Automation::ShuttersControl::shutters->setDriveCmd(
|
||||
(
|
||||
$FHEM::Automation::ShuttersControl::shutters->getIsDay
|
||||
? $FHEM::Automation::ShuttersControl::shutters->getLastPos
|
||||
: (
|
||||
$FHEM::Automation::ShuttersControl::shutters
|
||||
->getPrivacyDownStatus == 2
|
||||
? $FHEM::Automation::ShuttersControl::shutters
|
||||
->getPrivacyDownPos
|
||||
: $FHEM::Automation::ShuttersControl::shutters
|
||||
->getClosedPos
|
||||
)
|
||||
)
|
||||
);
|
||||
$FHEM::Automation::ShuttersControl::shutters
|
||||
->setRainProtectionStatus('unprotected');
|
||||
}
|
||||
RainProcessing( $hash, $val, $triggerMax, $triggerMin );
|
||||
}
|
||||
|
||||
return;
|
||||
|
148
fhem/lib/FHEM/Automation/ShuttersControl/Rainprotection.pm
Normal file
148
fhem/lib/FHEM/Automation/ShuttersControl/Rainprotection.pm
Normal file
@ -0,0 +1,148 @@
|
||||
###############################################################################
|
||||
#
|
||||
# Developed with Kate
|
||||
#
|
||||
# (c) 2018-2021 Copyright: Marko Oldenburg (fhemdevelopment@cooltux.net)
|
||||
# All rights reserved
|
||||
#
|
||||
# Special thanks goes to:
|
||||
# - Bernd (Cluni) this module is based on the logic of his script "Rollladensteuerung für HM/ROLLO inkl. Abschattung und Komfortfunktionen in Perl" (https://forum.fhem.de/index.php/topic,73964.0.html)
|
||||
# - Beta-User for many tests, many suggestions and good discussions
|
||||
# - pc1246 write english commandref
|
||||
# - FunkOdyssey commandref style
|
||||
# - sledge fix many typo in commandref
|
||||
# - many User that use with modul and report bugs
|
||||
# - Christoph (christoph.kaiser.in) Patch that expand RegEx for Window Events
|
||||
# - Julian (Loredo) expand Residents Events for new Residents functions
|
||||
# - Christoph (Christoph Morrison) for fix Commandref, many suggestions and good discussions
|
||||
#
|
||||
#
|
||||
# This script is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 2 of the License,or
|
||||
# any later version.
|
||||
#
|
||||
# The GNU General Public License can be found at
|
||||
# http://www.gnu.org/copyleft/gpl.html.
|
||||
# A copy is found in the textfile GPL.txt and important notices to the license
|
||||
# from the author is found in LICENSE.txt distributed with these scripts.
|
||||
#
|
||||
# This script is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
#
|
||||
# $Id$
|
||||
#
|
||||
###############################################################################
|
||||
|
||||
## unserer packagename
|
||||
package FHEM::Automation::ShuttersControl::Rainprotection;
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
use utf8;
|
||||
|
||||
use FHEM::Automation::ShuttersControl::Helper qw (:ALL);
|
||||
|
||||
require Exporter;
|
||||
our @ISA = qw(Exporter);
|
||||
our @EXPORT_OK = qw(
|
||||
RainProcessing
|
||||
);
|
||||
our %EXPORT_TAGS = (
|
||||
ALL => [
|
||||
qw(
|
||||
RainProcessing
|
||||
)
|
||||
],
|
||||
);
|
||||
|
||||
|
||||
sub RainProcessing {
|
||||
my ( $hash, $val, $triggerMax, $triggerMin ) = @_;
|
||||
|
||||
my $rainClosedPos = $FHEM::Automation::ShuttersControl::ascDev
|
||||
->getRainSensorShuttersClosedPos;
|
||||
|
||||
for my $shuttersDev ( @{ $hash->{helper}{shuttersList} } ) {
|
||||
$FHEM::Automation::ShuttersControl::shutters->setShuttersDev(
|
||||
$shuttersDev);
|
||||
|
||||
next
|
||||
if (
|
||||
$FHEM::Automation::ShuttersControl::shutters->getRainProtection eq
|
||||
'off' );
|
||||
|
||||
if ( $val > $triggerMax
|
||||
&& $FHEM::Automation::ShuttersControl::shutters->getStatus !=
|
||||
$rainClosedPos
|
||||
&& $FHEM::Automation::ShuttersControl::shutters
|
||||
->getRainProtectionStatus eq 'unprotected' )
|
||||
{
|
||||
_RainProtected();
|
||||
}
|
||||
elsif ( ( $val == 0 || $val < $triggerMin )
|
||||
&& $FHEM::Automation::ShuttersControl::shutters->getStatus ==
|
||||
$rainClosedPos
|
||||
&& IsAfterShuttersManualBlocking($shuttersDev)
|
||||
&& $FHEM::Automation::ShuttersControl::shutters
|
||||
->getRainProtectionStatus eq 'protected' )
|
||||
{
|
||||
my %funcHash = (
|
||||
shuttersdevice => $shuttersDev,
|
||||
);
|
||||
|
||||
::InternalTimer( ::gettimeofday() + $FHEM::Automation::ShuttersControl::ascDev->getRainWaitingTime
|
||||
, \&_RainUnprotected
|
||||
, \%funcHash );
|
||||
}
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
### es muss noch beobachtet werden ob die Auswahl des Rollos welches bearbeitet werden soll bestehen bleibt oder mit in die neuen Funktionen übergeben werden muss
|
||||
sub _RainProtected {
|
||||
$FHEM::Automation::ShuttersControl::shutters->setLastDrive(
|
||||
'rain protected');
|
||||
$FHEM::Automation::ShuttersControl::shutters->setDriveCmd(
|
||||
$FHEM::Automation::ShuttersControl::ascDev
|
||||
->getRainSensorShuttersClosedPos);
|
||||
$FHEM::Automation::ShuttersControl::shutters
|
||||
->setRainProtectionStatus('protected');
|
||||
}
|
||||
|
||||
sub _RainUnprotected {
|
||||
my $h = shift;
|
||||
|
||||
my $shuttersDev = $h->{shuttersdevice};
|
||||
$FHEM::Automation::ShuttersControl::shutters->setShuttersDev(
|
||||
$shuttersDev);
|
||||
|
||||
$FHEM::Automation::ShuttersControl::shutters->setLastDrive(
|
||||
'rain un-protected');
|
||||
$FHEM::Automation::ShuttersControl::shutters->setDriveCmd(
|
||||
(
|
||||
$FHEM::Automation::ShuttersControl::shutters->getIsDay
|
||||
? $FHEM::Automation::ShuttersControl::shutters->getLastPos
|
||||
: (
|
||||
$FHEM::Automation::ShuttersControl::shutters
|
||||
->getPrivacyDownStatus == 2
|
||||
? $FHEM::Automation::ShuttersControl::shutters
|
||||
->getPrivacyDownPos
|
||||
: $FHEM::Automation::ShuttersControl::shutters
|
||||
->getClosedPos
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
$FHEM::Automation::ShuttersControl::shutters
|
||||
->setRainProtectionStatus('unprotected');
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
1;
|
Loading…
x
Reference in New Issue
Block a user