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

73_AutoShuttersControl: fix little bugs, change control logic

git-svn-id: https://svn.fhem.de/fhem/trunk@20076 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
LeonGaultier 2019-08-28 08:16:27 +00:00
parent ebcc109d43
commit 42198816f0
2 changed files with 75 additions and 24 deletions

View File

@ -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.
- bugfix: 73_AutoShuttersControl: fix little bugs, change control logic
- feature: 93_DbRep: devices contained in the selection definition are marked
as "Probably associated with" if possible
- bugfix: 76_SMAInverter: fix Perl warnings

View File

@ -60,6 +60,7 @@ use strict;
use warnings;
use POSIX;
use utf8;
use Encode;
use FHEM::Meta;
use GPUtils qw(GP_Import GP_Export);
use Data::Dumper; #only for Debugging
@ -262,6 +263,7 @@ my %posSetCmds = (
HM485 => 'level',
SELVECommeo => 'position',
SELVE => 'position',
EnOcean => 'position',
);
my $shutters = new ASC_Shutters();
@ -485,6 +487,10 @@ sub Notify($$) {
}
}
elsif ( grep /^($posReading):\s\d+$/, @{$events} ) {
ASC_Debug( 'Notify: '
. ' ASC_Pos_Reading Event vom Rollo wurde erkannt '
. ' - RECEIVED EVENT: '
. Dumper $events);
EventProcessingShutters( $hash, $devname, join( ' ', @{$events} ) );
}
else {
@ -1015,7 +1021,14 @@ sub EventProcessingWindowRec($@) {
{
$shutters->setLastDrive('ventilate - window open');
$shutters->setNoOffset(1);
$shutters->setDriveCmd( $shutters->getVentilatePos );
$shutters->setDriveCmd(
(
(
$shutters->getShuttersPlace eq 'terrace'
and $shutters->getSubTyp eq 'twostate'
) ? $shutters->getOpenPos : $shutters->getVentilatePos
)
);
}
elsif ( $match =~ /[Oo]pen/
and $shutters->getSubTyp eq 'threestate' )
@ -1039,7 +1052,13 @@ sub EventProcessingWindowRec($@) {
if ( defined($posValue) and $posValue ) {
$shutters->setLastDrive($setLastDrive);
$shutters->setNoOffset(1);
$shutters->setDriveCmd($posValue);
$shutters->setDriveCmd(
(
$shutters->getShuttersPlace eq 'terrace'
? $shutters->getOpenPos
: $posValue
)
);
}
}
}
@ -1063,13 +1082,14 @@ sub EventProcessingRoommate($@) {
my $getModeUp = $shutters->getModeUp;
my $getModeDown = $shutters->getModeDown;
my $getRoommatesStatus = $shutters->getRoommatesStatus;
my $getRoommatesLastStatus = $shutters->getRoommatesLastStatus;
my $posValue;
if (
( $1 eq 'home' or $1 eq 'awoken' )
and ( $shutters->getRoommatesStatus eq 'home'
or $shutters->getRoommatesStatus eq 'awoken' )
and ( $getRoommatesStatus eq 'home'
or $getRoommatesStatus eq 'awoken' )
and $ascDev->getAutoShuttersControlMorning eq 'on'
and ( $getModeUp eq 'home'
or $getModeUp eq 'always'
@ -1115,7 +1135,7 @@ sub EventProcessingRoommate($@) {
$getRoommatesLastStatus eq 'absent'
or $getRoommatesLastStatus eq 'gone'
)
and $shutters->getRoommatesStatus eq 'home'
and $getRoommatesStatus eq 'home'
)
{
if (
@ -1207,8 +1227,7 @@ sub EventProcessingRoommate($@) {
ShuttersCommandSet( $hash, $shuttersDev, $posValue );
}
elsif (
$getModeDown eq 'absent'
and $1 eq 'absent'
$1 eq 'absent'
and ( not $shutters->getIsDay
or $shutters->getShadingMode eq 'absent' )
)
@ -1223,7 +1242,10 @@ sub EventProcessingRoommate($@) {
$shutters->setLastDrive('shading in');
ShuttersCommandSet( $hash, $shuttersDev, $posValue );
}
elsif ( not $shutters->getIsDay ) {
elsif ( not $shutters->getIsDay
and $getModeDown eq 'absent'
and $getRoommatesStatus eq 'absent' )
{
$posValue = $shutters->getClosedPos;
$shutters->setLastDrive('roommate absent');
ShuttersCommandSet( $hash, $shuttersDev, $posValue );
@ -1380,14 +1402,15 @@ sub EventProcessingResidents($@) {
and not $shutters->getSelfDefenseAbsent
and $shutters->getSelfDefenseAbsentTimerrun );
if ( $shutters->getStatus == $shutters->getClosedPos ) {
if ( $shutters->getStatus == $shutters->getClosedPos
and $shutters->getIsDay )
{
$shutters->setHardLockOut('on')
if (
CheckIfShuttersWindowRecOpen($shuttersDev) == 2
and $shutters->getShuttersPlace eq 'terrace'
and ( $getModeUp eq 'absent'
or $getModeUp eq 'off' )
and CheckIfShuttersWindowRecOpen($shuttersDev) != 0
);
$shutters->setLastDrive('selfDefense inactive');
@ -1906,7 +1929,7 @@ sub EventProcessingTwilightDevice($@) {
ASC_Debug( 'EventProcessingTwilightDevice: '
. $name
. ' - Passendes Event wurde erkannt. Verarbeitung über alle Rolllos beginnt'
. ' - Passendes Event wurde erkannt. Verarbeitung über alle Rollos beginnt'
);
foreach my $shuttersDev ( @{ $hash->{helper}{shuttersList} } ) {
@ -2279,13 +2302,18 @@ sub EventProcessingShutters($@) {
my ( $hash, $shuttersDev, $events ) = @_;
my $name = $hash->{NAME};
ASC_Debug( 'EventProcessingShutters: '
. ' Fn wurde durch Notify aufgerufen da ASC_Pos_Reading Event erkannt wurde '
. ' - RECEIVED EVENT: '
. Dumper $events);
if ( $events =~ m#.*:\s(\d+)# ) {
$shutters->setShuttersDev($shuttersDev);
$ascDev->setPosReading;
ASC_Debug( 'EventProcessingShutters: '
. $shutters->getShuttersDev
. ' - Event vom Rolllo erkannt. Es wird nun eine etwaige manuelle Fahrt ausgewertet.'
. ' - Event vom Rollo erkannt. Es wird nun eine etwaige manuelle Fahrt ausgewertet.'
. ' Int von gettimeofday: '
. int( gettimeofday() )
. ' Last Position Timestamp: '
@ -2323,6 +2351,11 @@ sub EventProcessingShutters($@) {
);
}
}
ASC_Debug( 'EventProcessingShutters: '
. ' Fn wurde durlaufen und es sollten Debugausgaben gekommen sein. '
. ' !!!Wenn nicht!!! wurde der Event nicht korrekt als Nummerisch erkannt. '
);
}
# Sub für das Zusammensetzen der Rolläden Steuerbefehle
@ -2598,19 +2631,23 @@ sub SunSetShuttersAfterTimerFn($) {
and $homemode eq 'gone' )
or $shutters->getModeDown eq 'always'
)
and (
$ascDev->getSelfDefense eq 'off'
or $shutters->getSelfDefenseExclude eq 'on'
or (
$ascDev->getSelfDefense eq 'on'
and ( $ascDev->getResidentsStatus ne 'absent'
or $ascDev->getResidentsStatus ne 'gone' )
)
)
)
{
if ( $shutters->getPrivacyDownStatus == 1 ) {
$shutters->setPrivacyDownStatus(2);
$shutters->setLastDrive('privacy position');
ShuttersCommandSet(
$hash,
$shuttersDev,
PositionValueWindowRec(
$shuttersDev, $shutters->getPrivacyDownPos
)
);
ShuttersCommandSet( $hash, $shuttersDev,
$shutters->getPrivacyDownPos );
}
else {
$shutters->setPrivacyDownStatus(0);
@ -2645,6 +2682,13 @@ sub SunRiseShuttersAfterTimerFn($) {
and $homemode eq 'gone' )
or $shutters->getModeUp eq 'always'
)
and (
$ascDev->getSelfDefense eq 'off'
or $shutters->getSelfDefenseExclude eq 'on'
or ( $ascDev->getSelfDefense eq 'on'
and $ascDev->getResidentsStatus ne 'absent'
and $ascDev->getResidentsStatus ne 'gone' )
)
)
{
@ -2660,9 +2704,12 @@ sub SunRiseShuttersAfterTimerFn($) {
$ascDev->getSelfDefense eq 'off'
or ( $ascDev->getSelfDefense eq 'on'
and CheckIfShuttersWindowRecOpen($shuttersDev) == 0 )
or ( $ascDev->getSelfDefense eq 'on'
or (
$ascDev->getSelfDefense eq 'on'
and CheckIfShuttersWindowRecOpen($shuttersDev) != 0
and $ascDev->getResidentsStatus eq 'home' )
and ( $ascDev->getResidentsStatus ne 'absent'
or $ascDev->getResidentsStatus ne 'gone' )
)
)
)
{
@ -3606,7 +3653,7 @@ sub _SetCmdFn($) {
ASC_Debug( 'FnSetCmdFn: '
. $shuttersDev
. ' - Rolllo wird gefahren, aktuelle Position: '
. ' - Rollo wird gefahren, aktuelle Position: '
. $shutters->getStatus
. ', Zielposition: '
. $posValue
@ -3644,7 +3691,10 @@ sub ASC_Debug($) {
my $debugTimestamp = strftime( "%Y.%m.%e %T", localtime(time) );
print(
"\n" . 'ASC_DEBUG!!! ' . $debugTimestamp . ' - ' . $debugMsg . "\n" );
encode_utf8(
"\n" . 'ASC_DEBUG!!! ' . $debugTimestamp . ' - ' . $debugMsg . "\n"
)
);
}
######################################
@ -6495,7 +6545,7 @@ sub getblockAscDrivesAfterManual {
],
"release_status": "under develop",
"license": "GPL_2",
"version": "v0.6.27",
"version": "v0.6.30",
"x_developmentversion": "v0.6.19.34",
"author": [
"Marko Oldenburg <leongaultier@gmail.com>"