diff --git a/73_AutoShuttersControl.pm b/73_AutoShuttersControl.pm index 5cf0ce7..807bf65 100644 --- a/73_AutoShuttersControl.pm +++ b/73_AutoShuttersControl.pm @@ -211,8 +211,8 @@ my %userAttrList = ( 'ASC_Time_Down_Late' => '-', 'ASC_PrivacyUpValue_beforeDayOpen' => '-', 'ASC_PrivacyDownValue_beforeNightClose' => '-', - 'ASC_PrivacyUp_Pos' => '-', - 'ASC_PrivacyDown_Pos' => '-', + 'ASC_PrivacyUp_Pos' => [ '', 50, 50 ], + 'ASC_PrivacyDown_Pos' => [ '', 50, 50 ], 'ASC_TempSensor' => '-', 'ASC_Ventilate_Window_Open:on,off' => '-', 'ASC_LockOut:soft,hard,off' => '-', @@ -2471,11 +2471,12 @@ sub ShadingProcessing { && ( $shutters->getModeUp eq 'always' || $shutters->getModeUp eq $homemode || $shutters->getModeUp eq 'off' ) - && ( ( int( gettimeofday() ) - $shutters->getShadingStatusTimestamp ) < 2 - || ( !$shutters->getQueryShuttersPos( $shutters->getShadingPos ) - && $shutters->getIfInShading - && $shutters->getStatus != $shutters->getShadingPos ) - ) + && ( + ( int( gettimeofday() ) - $shutters->getShadingStatusTimestamp ) < 2 + || ( !$shutters->getQueryShuttersPos( $shutters->getShadingPos ) + && $shutters->getIfInShading + && $shutters->getStatus != $shutters->getShadingPos ) + ) ); return; @@ -2781,47 +2782,48 @@ sub ShuttersCommandSet { if ( ( -# $posValue == $shutters->getShadingPos && - CheckIfShuttersWindowRecOpen($shuttersDev) == 2 + # $posValue == $shutters->getShadingPos && + CheckIfShuttersWindowRecOpen($shuttersDev) == 2 && $shutters->getShuttersPlace eq 'terrace' && ( $shutters->getLockOut eq 'soft' || $shutters->getLockOut eq 'hard' ) && !$shutters->getQueryShuttersPos($posValue) ) || ( -# $posValue != $shutters->getShadingPos -# && ( - ( - $shutters->getPartyMode eq 'on' - && $ascDev->getPartyMode eq 'on' - ) - || ( - CheckIfShuttersWindowRecOpen($shuttersDev) == 2 - && $shutters->getSubTyp eq 'threestate' - && ( $ascDev->getAutoShuttersControlComfort eq 'off' - || $shutters->getComfortOpenPos != $posValue ) - && $shutters->getVentilateOpen eq 'on' - && $shutters->getShuttersPlace eq 'window' - && $shutters->getLockOut ne 'off' - ) - || ( CheckIfShuttersWindowRecOpen($shuttersDev) == 2 - && $shutters->getSubTyp eq 'threestate' - && $ascDev->getAutoShuttersControlComfort eq 'on' - && $shutters->getVentilateOpen eq 'off' - && $shutters->getShuttersPlace eq 'window' - && $shutters->getLockOut ne 'off' ) - || ( - CheckIfShuttersWindowRecOpen($shuttersDev) == 2 - && ( $shutters->getLockOut eq 'soft' - || $shutters->getLockOut eq 'hard' ) - && !$shutters->getQueryShuttersPos($posValue) - ) - || ( CheckIfShuttersWindowRecOpen($shuttersDev) == 2 - && $shutters->getShuttersPlace eq 'terrace' - && !$shutters->getQueryShuttersPos($posValue) ) - || ( $shutters->getRainProtectionStatus eq 'protected' - && $shutters->getWindProtectionStatus eq 'protected' ) -# ) + # $posValue != $shutters->getShadingPos + # && ( + ( + $shutters->getPartyMode eq 'on' + && $ascDev->getPartyMode eq 'on' + ) + || ( + CheckIfShuttersWindowRecOpen($shuttersDev) == 2 + && $shutters->getSubTyp eq 'threestate' + && ( $ascDev->getAutoShuttersControlComfort eq 'off' + || $shutters->getComfortOpenPos != $posValue ) + && $shutters->getVentilateOpen eq 'on' + && $shutters->getShuttersPlace eq 'window' + && $shutters->getLockOut ne 'off' + ) + || ( CheckIfShuttersWindowRecOpen($shuttersDev) == 2 + && $shutters->getSubTyp eq 'threestate' + && $ascDev->getAutoShuttersControlComfort eq 'on' + && $shutters->getVentilateOpen eq 'off' + && $shutters->getShuttersPlace eq 'window' + && $shutters->getLockOut ne 'off' ) + || ( + CheckIfShuttersWindowRecOpen($shuttersDev) == 2 + && ( $shutters->getLockOut eq 'soft' + || $shutters->getLockOut eq 'hard' ) + && !$shutters->getQueryShuttersPos($posValue) + ) + || ( CheckIfShuttersWindowRecOpen($shuttersDev) == 2 + && $shutters->getShuttersPlace eq 'terrace' + && !$shutters->getQueryShuttersPos($posValue) ) + || ( $shutters->getRainProtectionStatus eq 'protected' + && $shutters->getWindProtectionStatus eq 'protected' ) + + # ) ) ) { @@ -4349,18 +4351,22 @@ sub _DetermineSlatCmd { my $value = shift; my $posValue = shift; - return $posValue == $shutters->getShadingPos - && $shutters->getShadingPositionAssignment ne 'none' ? $shutters->getShadingPositionAssignment - : $posValue == $shutters->getVentilatePos - && $shutters->getVentilatePositionAssignment ne 'none' ? $shutters->getVentilatePositionAssignment - : $posValue == $shutters->getOpenPos - && $shutters->getOpenPositionAssignment ne 'none' ? $shutters->getOpenPositionAssignment - : $posValue == $shutters->getClosedPos - && $shutters->getClosedPositionAssignment ne 'none' ? $shutters->getClosedPositionAssignment - : $posValue == $shutters->getSleepPos - && $shutters->getSleepPositionAssignment ne 'none' ? $shutters->getSleepPositionAssignment - : $posValue == $shutters->getComfortOpenPos - && $shutters->getComfortOpenPositionAssignment ne 'none' ? $shutters->getComfortOpenPositionAssignment + return $posValue == $shutters->getShadingPos + && $shutters->getShadingPositionAssignment ne 'none' ? $shutters->getShadingPositionAssignment + : $posValue == $shutters->getVentilatePos + && $shutters->getVentilatePositionAssignment ne 'none' ? $shutters->getVentilatePositionAssignment + : $posValue == $shutters->getOpenPos + && $shutters->getOpenPositionAssignment ne 'none' ? $shutters->getOpenPositionAssignment + : $posValue == $shutters->getClosedPos + && $shutters->getClosedPositionAssignment ne 'none' ? $shutters->getClosedPositionAssignment + : $posValue == $shutters->getSleepPos + && $shutters->getSleepPositionAssignment ne 'none' ? $shutters->getSleepPositionAssignment + : $posValue == $shutters->getComfortOpenPos + && $shutters->getComfortOpenPositionAssignment ne 'none' ? $shutters->getComfortOpenPositionAssignment + : $posValue == $shutters->getPrivacyUpPos + && $shutters->getPrivacyUpPositionAssignment ne 'none' ? $shutters->getPrivacyUpPositionAssignment + : $posValue == $shutters->getPrivacyDownPos + && $shutters->getPrivacyDownPositionAssignment ne 'none' ? $shutters->getPrivacyDownPositionAssignment : $value; } @@ -4412,15 +4418,53 @@ sub _SetCmdFn { my $slatPos = -1; if ( $shutters->getShadingPositionAssignment ne 'none' - && $shutters->getShadingPositionAssignment =~ m{\A[a-zA-Z]+\z}xms ) + || $shutters->getOpenPositionAssignment ne 'none' + || $shutters->getClosedPositionAssignment ne 'none' + || $shutters->getPrivacyUpPositionAssignment ne 'none' + || $shutters->getPrivacyDownPositionAssignment ne 'none' + || $shutters->getSleepPositionAssignment ne 'none' + || $shutters->getVentilatePositionAssignment ne 'none' + || $shutters->getComfortOpenPositionAssignment ne 'none' ) { - $driveCommand = _DetermineSlatCmd( $driveCommand, $posValue ); - } - elsif ($shutters->getShadingPositionAssignment ne 'none' - && $shutters->getShadingPositionAssignment =~ m{\A\d{1,3}\z}xms ) - { - - $slatPos = _DetermineSlatCmd( $slatPos, $posValue ); + if ( + ( + $shutters->getShadingPositionAssignment =~ m{\A[a-zA-Z]+\z}xms + && $shutters->getShadingPositionAssignment ne 'none' + ) + || ( $shutters->getOpenPositionAssignment =~ m{\A[a-zA-Z]+\z}xms + && $shutters->getOpenPositionAssignment ne 'none' ) + || ( $shutters->getClosedPositionAssignment =~ m{\A[a-zA-Z]+\z}xms + && $shutters->getClosedPositionAssignment ne 'none' ) + || ( + $shutters->getPrivacyUpPositionAssignment =~ m{\A[a-zA-Z]+\z}xms + && $shutters->getPrivacyUpPositionAssignment ne 'none' ) + || ( $shutters->getPrivacyDownPositionAssignment =~ + m{\A[a-zA-Z]+\z}xms + && $shutters->getPrivacyDownPositionAssignment ne 'none' ) + || ( $shutters->getSleepPositionAssignment =~ m{\A[a-zA-Z]+\z}xms + && $shutters->getSleepPositionAssignment ne 'none' ) + || ( + $shutters->getVentilatePositionAssignment =~ m{\A[a-zA-Z]+\z}xms + && $shutters->getVentilatePositionAssignment ne 'none' ) + || ( $shutters->getComfortOpenPositionAssignment =~ + m{\A[a-zA-Z]+\z}xms + && $shutters->getComfortOpenPositionAssignment ne 'none' ) + ) + { + $driveCommand = _DetermineSlatCmd( $driveCommand, $posValue ); + } + elsif ($shutters->getShadingPositionAssignment =~ m{\A\d{1,3}\z}xms + || $shutters->getOpenPositionAssignment =~ m{\A\d{1,3}\z}xms + || $shutters->getClosedPositionAssignment =~ m{\A\d{1,3}\z}xms + || $shutters->getPrivacyUpPositionAssignment =~ m{\A\d{1,3}\z}xms + || $shutters->getPrivacyDownPositionAssignment =~ m{\A\d{1,3}\z}xms + || $shutters->getSleepPositionAssignment =~ m{\A\d{1,3}\z}xms + || $shutters->getVentilatePositionAssignment =~ m{\A\d{1,3}\z}xms + || $shutters->getComfortOpenPositionAssignment =~ + m{\A\d{1,3}\z}xms ) + { + $slatPos = _DetermineSlatCmd( $slatPos, $posValue ); + } } CommandSet( undef, @@ -5895,25 +5939,28 @@ sub getPrivacyDownBrightnessVal { sub getPrivacyUpPos { my $self = shift; - my $val = AttrVal( $self->{shuttersDev}, 'ASC_PrivacyUp_Pos', 50 ); + return $shutters->_getPosition( 'ASC_PrivacyUp_Pos', 'ASC_PrivacyUp_Pos' ); +} - if ( defined( FHEM::AutoShuttersControl::_perlCodeCheck($val) ) ) { - $val = FHEM::AutoShuttersControl::_perlCodeCheck($val); - } +sub getPrivacyUpPositionAssignment { + my $self = shift; - return ( $val =~ m{^\d+(\.\d+)?$}xms ? $val : 50 ); + return $shutters->_getPositionAssignment( 'ASC_PrivacyUp_Pos', + 'getPrivacyUpPos' ); } sub getPrivacyDownPos { my $self = shift; - my $val = AttrVal( $self->{shuttersDev}, 'ASC_PrivacyDown_Pos', 50 ); + return $shutters->_getPosition( 'ASC_PrivacyDown_Pos', + 'ASC_PrivacyDown_Pos' ); +} - if ( defined( FHEM::AutoShuttersControl::_perlCodeCheck($val) ) ) { - $val = FHEM::AutoShuttersControl::_perlCodeCheck($val); - } +sub getPrivacyDownPositionAssignment { + my $self = shift; - return ( $val =~ m{^\d+(\.\d+)?$}xms ? $val : 50 ); + return $shutters->_getPositionAssignment( 'ASC_PrivacyDown_Pos', + 'getPrivacyDownPos' ); } sub getSelfDefenseMode { @@ -8491,11 +8538,22 @@ sub getBlockAscDrivesAfterManual {