From 2ecded0564af926fdf9e1e45fef6f5d435b85f45 Mon Sep 17 00:00:00 2001 From: LeonGaultier Date: Mon, 13 Apr 2020 12:57:02 +0000 Subject: [PATCH] 73_AutoShuttersControl: rollback Notify Fn, fix shading out/in reserved git-svn-id: https://svn.fhem.de/fhem/trunk@21662 2b470e98-0d58-463d-a4d8-8e2adae1ed80 --- fhem/CHANGED | 16 +-- fhem/FHEM/73_AutoShuttersControl.pm | 150 ++++++++++++---------------- 2 files changed, 72 insertions(+), 94 deletions(-) diff --git a/fhem/CHANGED b/fhem/CHANGED index 190b0fcfc..f48768bc1 100644 --- a/fhem/CHANGED +++ b/fhem/CHANGED @@ -1,13 +1,15 @@ # 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: rollback Notify Fn, fix shading + out/in reserved - feature: 72_FB_CALLMONITOR: new reading/event "calls_count" which reflects the number of active calls in parallel - - bugfix: 50_TelegramBot: parsemode corrected for multiple lines - msg1041326 - - change: 37_echodevice.pm more loginformations set "NPM_login new" + - bugfix: 50_TelegramBot: parsemode corrected for multiple lines - msg1041326 + - change: 37_echodevice.pm more loginformations set "NPM_login new" - change: 93_Log2Syslog: new reading 'Parse_Err_LastData', minor changes - change: 93_Log2Syslog: some code changes and reviews - - bugfix: 70_DENON_AVR: fixed HTTP 403 (thx justme1968) - - bugfix : 73_AutoShuttersControl: fix shading drive if current position under + - bugfix: 70_DENON_AVR: fixed HTTP 403 (thx justme1968) + - bugfix: 73_AutoShuttersControl: fix shading drive if current position under shading position - feature: 37_echodevice.pm CHANGE: Keepalive aktiviert @@ -18,16 +20,16 @@ set sounds: (Sounds gemäß Routine-Übersicht) - feature: 14_SD_UT.pm new model Momento - - bugfix: 14_SD_WS_09.pm: WindDirAverage + - bugfix: 14_SD_WS_09.pm: WindDirAverage - feature: 14_SD_WS_09.pm: support for WH2315 - feature: 14_SD_UT.pm new model Novy_840039 new remote control xavax 00111939 new remote control with 4 buttons for diesel heating - - change: 14_SD_UT.pm + - change: 14_SD_UT.pm model Novy_840039, rename button text power_button to power_on_off remove sort option - - bugfix: 14_SD_UT.pm + - bugfix: 14_SD_UT.pm fix UTClock for all models TR-502MSV bugfix, ident was only 8 bit, must be 12 bit long RC_10 button set all work after renaming the device diff --git a/fhem/FHEM/73_AutoShuttersControl.pm b/fhem/FHEM/73_AutoShuttersControl.pm index 6e21f835e..4a09057c6 100644 --- a/fhem/FHEM/73_AutoShuttersControl.pm +++ b/fhem/FHEM/73_AutoShuttersControl.pm @@ -408,32 +408,18 @@ sub Notify { . " Notify: " . Dumper $events); # mit Dumper - my $found_event = { # container to memoize specific found events - 'defined' => 0, - 'initialized' => 0, - 'rereadcfg' => 0, - 'modified' => 0, - 'rolledout' => 0, - 'partyoff' => 0, - 'timeweholiday' => 0, - 'attrdelattr' => 0, - 'posreading' => 0, - }; - - # iterate the event list just ONCE - for my $event ( @{$events} ) { - $found_event->{'defined'}++ if ( $event =~ m{^DEFINED\s$name$}xms ); - $found_event->{'initialized'}++ if ( $event =~ m{^INITIALIZED$}xms ); - $found_event->{'rereadcfg'}++ if ( $event =~ m{^REREADCFG$}xms ); - $found_event->{'modified'}++ if ( $event =~ m{^MODIFIED\s$name$}xms ); - } - if ( - ( $found_event->{'defined'} && $devname eq 'global' && $init_done ) - || ( $found_event->{'initialized'} - || $found_event->{'rereadcfg'} - || $found_event->{'modified'} ) - && $devname eq 'global' + ( + grep m{^DEFINED.$name$}xms, + @{$events} and $devname eq 'global' and $init_done + ) + or ( + grep m{^INITIALIZED$}xms, + @{$events} or grep m{^REREADCFG$}xms, + @{$events} or grep m{^MODIFIED.$name$}xms, + @{$events} + ) + and $devname eq 'global' ) { readingsSingleUpdate( $hash, 'partyMode', 'off', 0 ) @@ -470,74 +456,41 @@ sub Notify { } return unless ( ref( $hash->{helper}{shuttersList} ) eq 'ARRAY' - && scalar( @{ $hash->{helper}{shuttersList} } ) > 0 ); + and scalar( @{ $hash->{helper}{shuttersList} } ) > 0 ); my $posReading = $shutters->getPosCmd; - for my $event ( @{$events} ) { - $found_event->{'rolledout'}++ - if ( $event =~ m{^userAttrList:\srolled\sout$}xms ); - $found_event->{'partyoff'}++ if ( $event =~ m{^partyMode:\soff$}xms ); - $found_event->{'sunrise'}++ - if ( $event =~ m{^sunriseTimeWeHoliday:\s(on|off)$}xms ); - $found_event->{'attrdelattr'}++ - if ( - $event =~ m{^(ATTR|DELETEATTR) - \s(.*ASC_Time_Up_WE_Holiday - |.*ASC_Up - |.*ASC_Down - |.*ASC_AutoAstroModeMorning - |.*ASC_AutoAstroModeMorningHorizon - |.*ASC_AutoAstroModeEvening - |.*ASC_AutoAstroModeEveningHorizon - |.*ASC_Time_Up_Early - |.*ASC_Time_Up_Late - |.*ASC_Time_Down_Early - |.*ASC_Time_Down_Late - |.*ASC_autoAstroModeMorning - |.*ASC_autoAstroModeMorningHorizon - |.*ASC_PrivacyDownValue_beforeNightClose - |.*ASC_PrivacyUpValue_beforeDayOpen - |.*ASC_autoAstroModeEvening - |.*ASC_autoAstroModeEveningHorizon - |.*ASC_Roommate_Device - |.*ASC_WindowRec - |.*ASC_residentsDev - |.*ASC_rainSensor - |.*ASC_windSensor - |.*ASC_BrightnessSensor - |.*ASC_twilightDevice - |.*ASC_ExternalTrigger) - (\s.*|$)}xms - ); - $found_event->{'posreading'}++ - if ( $event =~ m{^($posReading):\s\d+$}xms ); - } if ( $devname eq $name ) { - if ( $found_event->{'rolledout'} ) { + if ( grep m{^userAttrList:.rolled.out$}xms, @{$events} ) { unless ( scalar( @{ $hash->{helper}{shuttersList} } ) == 0 ) { WriteReadingsShuttersList($hash); UserAttributs_Readings_ForShutters( $hash, 'add' ); InternalTimer( gettimeofday() + 3, - \&RenewSunRiseSetShuttersTimer, $hash ); + 'FHEM::AutoShuttersControl::RenewSunRiseSetShuttersTimer', + $hash ); InternalTimer( gettimeofday() + 5, - \&AutoSearchTwilightDev, $hash ); + 'FHEM::AutoShuttersControl::AutoSearchTwilightDev', $hash ); } } - elsif ( $found_event->{'partyoff'} ) { + elsif ( grep m{^partyMode:.off$}xms, @{$events} ) { EventProcessingPartyMode($hash); } - elsif ( $found_event->{'sunrise'} ) { + elsif ( grep m{^sunriseTimeWeHoliday:.(on|off)$}xms, @{$events} ) { RenewSunRiseSetShuttersTimer($hash); } } elsif ( $devname eq "global" ) { # Kommt ein globales Event und beinhaltet folgende Syntax wird die Funktion zur Verarbeitung aufgerufen - if ( $found_event->{'attrdelattr'} ) { + if ( + grep +m{^(ATTR|DELETEATTR)\s(.*ASC_Time_Up_WE_Holiday|.*ASC_Up|.*ASC_Down|.*ASC_AutoAstroModeMorning|.*ASC_AutoAstroModeMorningHorizon|.*ASC_AutoAstroModeEvening|.*ASC_AutoAstroModeEveningHorizon|.*ASC_Time_Up_Early|.*ASC_Time_Up_Late|.*ASC_Time_Down_Early|.*ASC_Time_Down_Late|.*ASC_autoAstroModeMorning|.*ASC_autoAstroModeMorningHorizon|.*ASC_PrivacyDownValue_beforeNightClose|.*ASC_PrivacyUpValue_beforeDayOpen|.*ASC_autoAstroModeEvening|.*ASC_autoAstroModeEveningHorizon|.*ASC_Roommate_Device|.*ASC_WindowRec|.*ASC_residentsDev|.*ASC_rainSensor|.*ASC_windSensor|.*ASC_BrightnessSensor|.*ASC_twilightDevice|.*ASC_ExternalTrigger)(\s.*|$)}xms, + @{$events} + ) + { EventProcessingGeneral( $hash, undef, join( ' ', @{$events} ) ); } } - elsif ( $found_event->{'posreading'} ) { + elsif ( grep m{^($posReading):\s\d+$}xms, @{$events} ) { ASC_Debug( 'Notify: ' . ' ASC_Pos_Reading Event vom Rollo wurde erkannt ' . ' - RECEIVED EVENT: ' @@ -548,6 +501,7 @@ sub Notify { EventProcessingGeneral( $hash, $devname, join( ' ', @{$events} ) ) ; # bei allen anderen Events wird die entsprechende Funktion zur Verarbeitung aufgerufen } + return; } @@ -1336,9 +1290,8 @@ sub EventProcessingRoommate { && $shutters->getShadingMode eq 'home' ) { $shutters->setLastDrive('shading in'); - $posValue = $shutters->getShadingPos; - - ShuttersCommandSet( $hash, $shuttersDev, $posValue ); + ShuttersCommandSet( $hash, $shuttersDev, + $shutters->getShadingPos ); } elsif ( ( @@ -1363,9 +1316,9 @@ sub EventProcessingRoommate { : 'shading out' ) ); - $posValue = $shutters->getOpenPos; - ShuttersCommandSet( $hash, $shuttersDev, $posValue ); + ShuttersCommandSet( $hash, $shuttersDev, + $shutters->getOpenPos ); } } } @@ -1401,7 +1354,8 @@ sub EventProcessingRoommate { $1 eq 'absent' && ( !$shutters->getIsDay || $shutters->getDown eq 'roommate' - || $shutters->getShadingMode eq 'absent' ) + || $shutters->getShadingMode eq 'absent' + || $shutters->getUp eq 'absent' ) ) { if ( ( $shutters->getIsDay || $shutters->getUp eq 'roommate' ) @@ -1409,17 +1363,24 @@ sub EventProcessingRoommate { && !$shutters->getQueryShuttersPos( $shutters->getShadingPos ) && $shutters->getShadingMode eq 'absent' ) { - $posValue = $shutters->getShadingPos; $shutters->setLastDrive('shading in'); - ShuttersCommandSet( $hash, $shuttersDev, $posValue ); + ShuttersCommandSet( $hash, $shuttersDev, + $shutters->getShadingPos ); } elsif (( !$shutters->getIsDay || $shutters->getDown eq 'roommate' ) && $getModeDown eq 'absent' && $getRoommatesStatus eq 'absent' ) { - $posValue = $shutters->getClosedPos; $shutters->setLastDrive('roommate absent'); - ShuttersCommandSet( $hash, $shuttersDev, $posValue ); + ShuttersCommandSet( $hash, $shuttersDev, + $shutters->getClosedPos ); + } + elsif ($shutters->getIsDay + && $shutters->getUp eq 'absent' ) + { + $shutters->setLastDrive('roommate absent'); + ShuttersCommandSet( $hash, $shuttersDev, + $shutters->getOpenPos ); } } } @@ -2399,7 +2360,14 @@ sub ShadingProcessing { if ( $shutters->getShadingStatus eq 'in' || $shutters->getShadingStatus eq 'in reserved' ); - if ( $shutters->getShadingStatus eq 'out reserved' ) { + if ( + ( + $shutters->getShadingStatus eq 'out reserved' + and + ( int( gettimeofday() ) - $shutters->getShadingStatusTimestamp ) + ) > $shutters->getShadingWaitingPeriod + ) + { $shutters->setShadingStatus('out'); $shutters->setShadingLastStatus('in') if ( $shutters->getShadingLastStatus eq 'out' ); @@ -2431,7 +2399,11 @@ sub ShadingProcessing { if ( $shutters->getShadingStatus eq 'out' || $shutters->getShadingStatus eq 'out reserved' ); - if ( $shutters->getShadingStatus eq 'in reserved' ) { + if ( $shutters->getShadingStatus eq 'in reserved' + and + ( int( gettimeofday() ) - $shutters->getShadingStatusTimestamp ) > + ( $shutters->getShadingWaitingPeriod / 2 ) ) + { $shutters->setShadingStatus('in'); $shutters->setShadingLastStatus('out') if ( $shutters->getShadingLastStatus eq 'in' ); @@ -2521,7 +2493,11 @@ sub ShadingProcessingDriveCommand { ? $shutters->getOpenPos : ( $shutters->getQueryShuttersPos( $shutters->getLastPos ) - ? $shutters->getLastPos + ? ( + $shutters->getLastPos == $shutters->getSleepPos + ? $shutters->getOpenPos + : $shutters->getLastPos + ) : $shutters->getOpenPos ) ) @@ -5418,7 +5394,7 @@ sub getShadingLastStatus { # Werte für value = in, out ); } -sub getShadingManualDriveStatus { # Werte für value = in, out +sub getShadingManualDriveStatus { # Werte für value = 0, 1 my $self = shift; return ( @@ -8411,7 +8387,7 @@ sub getBlockAscDrivesAfterManual { ], "release_status": "testing", "license": "GPL_2", - "version": "v0.8.26", + "version": "v0.8.27", "author": [ "Marko Oldenburg " ],