coderewrite

This commit is contained in:
Marko Oldenburg 2022-01-02 08:26:14 +01:00
parent 47be49617d
commit d35dda835a
3 changed files with 34 additions and 32 deletions

View File

@ -1,16 +1,16 @@
UPD 2022-01-01_20:15:38 115601 FHEM/73_AutoShuttersControl.pm UPD 2022-01-01_20:15:38 115601 FHEM/73_AutoShuttersControl.pm
UPD 2022-01-02_07:52:37 75828 lib/FHEM/Automation/ShuttersControl.pm UPD 2022-01-02_08:24:03 75862 lib/FHEM/Automation/ShuttersControl.pm
UPD 2022-01-02_06:39:39 2691 lib/FHEM/Automation/ShuttersControl/Dev.pm UPD 2022-01-02_07:57:18 2691 lib/FHEM/Automation/ShuttersControl/Dev.pm
UPD 2022-01-02_06:34:39 2677 lib/FHEM/Automation/ShuttersControl/Roommate.pm UPD 2022-01-02_07:57:18 2677 lib/FHEM/Automation/ShuttersControl/Roommate.pm
UPD 2022-01-02_07:04:24 32028 lib/FHEM/Automation/ShuttersControl/Shutters.pm UPD 2022-01-02_08:24:00 32016 lib/FHEM/Automation/ShuttersControl/Shutters.pm
UPD 2022-01-02_06:37:09 25452 lib/FHEM/Automation/ShuttersControl/Shading.pm UPD 2022-01-02_07:57:18 25452 lib/FHEM/Automation/ShuttersControl/Shading.pm
UPD 2022-01-02_06:36:31 112122 lib/FHEM/Automation/ShuttersControl/EventProcessingFunctions.pm UPD 2022-01-02_07:57:18 112122 lib/FHEM/Automation/ShuttersControl/EventProcessingFunctions.pm
UPD 2022-01-02_07:31:19 40322 lib/FHEM/Automation/ShuttersControl/Helper.pm UPD 2022-01-02_07:57:18 40322 lib/FHEM/Automation/ShuttersControl/Helper.pm
UPD 2022-01-02_06:41:32 2209 lib/FHEM/Automation/ShuttersControl/Window.pm UPD 2022-01-02_07:57:18 2209 lib/FHEM/Automation/ShuttersControl/Window.pm
UPD 2022-01-01_20:15:38 11706 lib/FHEM/Automation/ShuttersControl/Dev/Attr.pm UPD 2022-01-01_20:15:38 11706 lib/FHEM/Automation/ShuttersControl/Dev/Attr.pm
UPD 2022-01-01_20:15:38 7265 lib/FHEM/Automation/ShuttersControl/Dev/Readings.pm UPD 2022-01-01_20:15:38 7265 lib/FHEM/Automation/ShuttersControl/Dev/Readings.pm
UPD 2022-01-01_20:15:38 52751 lib/FHEM/Automation/ShuttersControl/Shutters/Attr.pm UPD 2022-01-01_20:15:38 52751 lib/FHEM/Automation/ShuttersControl/Shutters/Attr.pm
UPD 2022-01-01_20:15:38 2799 lib/FHEM/Automation/ShuttersControl/Shutters/Readings.pm UPD 2022-01-01_20:15:38 2799 lib/FHEM/Automation/ShuttersControl/Shutters/Readings.pm
UPD 2022-01-01_20:15:38 3887 lib/FHEM/Automation/ShuttersControl/Window/Attr.pm UPD 2022-01-01_20:15:38 3887 lib/FHEM/Automation/ShuttersControl/Window/Attr.pm
UPD 2022-01-01_20:15:38 2200 lib/FHEM/Automation/ShuttersControl/Window/Readings.pm UPD 2022-01-01_20:15:38 2200 lib/FHEM/Automation/ShuttersControl/Window/Readings.pm
UPD 2022-01-02_06:36:44 7113 lib/FHEM/Automation/ShuttersControl/Rainprotection.pm UPD 2022-01-02_07:57:18 7113 lib/FHEM/Automation/ShuttersControl/Rainprotection.pm

View File

@ -172,7 +172,7 @@ BEGIN {
} }
## Die Attributsliste welche an die Rolläden verteilt wird. Zusammen mit Default Werten ## Die Attributsliste welche an die Rolläden verteilt wird. Zusammen mit Default Werten
our %userAttrList = ( my %userAttrList = (
'ASC_Mode_Up:absent,always,off,home' => '-', 'ASC_Mode_Up:absent,always,off,home' => '-',
'ASC_Mode_Down:absent,always,off,home' => '-', 'ASC_Mode_Down:absent,always,off,home' => '-',
'ASC_Up:time,astro,brightness,roommate' => '-', 'ASC_Up:time,astro,brightness,roommate' => '-',
@ -242,8 +242,8 @@ our %userAttrList = (
); );
## 2 Objekte werden erstellt ## 2 Objekte werden erstellt
our $shutters = FHEM::Automation::ShuttersControl::Shutters->new(); my $shutters = FHEM::Automation::ShuttersControl::Shutters->new();
our $ascDev = FHEM::Automation::ShuttersControl::Dev->new(); my $ascDev = FHEM::Automation::ShuttersControl::Dev->new();
my %posSetCmds = ( my %posSetCmds = (
ZWave => 'dim', ZWave => 'dim',
@ -305,9 +305,11 @@ sub ascAPIset {
sub Define { sub Define {
my $hash = shift // return; my $hash = shift // return;
my $aArg = shift // return; my $aArg = shift // return;
my $version;
return $@ if ( !FHEM::Meta::SetInternals($hash) ); return $@ unless ( FHEM::Meta::SetInternals($hash) );
use version 0.60; our $VERSION = FHEM::Meta::Get( $hash, 'version' ); $version = FHEM::Meta::Get( $hash, 'version' );
our $VERSION = $version;
return 'only one AutoShuttersControl instance allowed' return 'only one AutoShuttersControl instance allowed'
if ( ::devspec2array('TYPE=AutoShuttersControl') > 1 ) if ( ::devspec2array('TYPE=AutoShuttersControl') > 1 )
@ -400,13 +402,13 @@ sub Notify {
if ( if (
( (
grep m{^DEFINED.$name$}xms, grep { /^DEFINED.$name$/ },
@{$events} && $devname eq 'global' && $::init_done @{$events} && $devname eq 'global' && $::init_done
) )
|| ( || (
grep m{^INITIALIZED$}xms, grep { /^INITIALIZED$/ },
@{$events} or grep m{^REREADCFG$}xms, @{$events} or grep { /^REREADCFG$/ },
@{$events} or grep m{^MODIFIED.$name$}xms, @{$events} or grep { /^MODIFIED.$name$/ },
@{$events} @{$events}
) )
&& $devname eq 'global' && $devname eq 'global'
@ -450,7 +452,7 @@ sub Notify {
my $posReading = $shutters->getPosCmd; my $posReading = $shutters->getPosCmd;
if ( $devname eq $name ) { if ( $devname eq $name ) {
if ( grep m{^userAttrList:.rolled.out$}xms, @{$events} ) { if ( grep { /^userAttrList:.rolled.out$/ }, @{$events} ) {
if ( scalar( @{ $hash->{helper}{shuttersList} } ) > 0 ) { if ( scalar( @{ $hash->{helper}{shuttersList} } ) > 0 ) {
WriteReadingsShuttersList($hash); WriteReadingsShuttersList($hash);
UserAttributs_Readings_ForShutters( $hash, 'add' ); UserAttributs_Readings_ForShutters( $hash, 'add' );
@ -475,25 +477,26 @@ sub Notify {
::ReadingsVal( $name, 'controlShading', 'off' ) ne 'off' ); ::ReadingsVal( $name, 'controlShading', 'off' ) ne 'off' );
} }
} }
elsif ( grep m{^partyMode:.off$}xms, @{$events} ) { elsif ( grep { /^partyMode:.off$/ }, @{$events} ) {
EventProcessingPartyMode($hash); EventProcessingPartyMode($hash);
} }
elsif ( grep m{^sunriseTimeWeHoliday:.(on|off)$}xms, @{$events} ) { elsif ( grep { /^sunriseTimeWeHoliday:.(on|off)$/ }, @{$events} ) {
RenewSunRiseSetShuttersTimer($hash); RenewSunRiseSetShuttersTimer($hash);
} }
} }
elsif ( $devname eq "global" ) elsif ( $devname eq "global" )
{ # Kommt ein globales Event und beinhaltet folgende Syntax wird die Funktion zur Verarbeitung aufgerufen { # Kommt ein globales Event und beinhaltet folgende Syntax wird die Funktion zur Verarbeitung aufgerufen
if ( if (
grep 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_tempSensor|.*ASC_BrightnessSensor|.*ASC_twilightDevice|.*ASC_ExternalTrigger|.*ASC_Shading_StateChange_SunnyCloudy|.*ASC_TempSensor|.*ASC_Shading_Mode)(\s.*|$)}xms, /^(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_tempSensor|.*ASC_BrightnessSensor|.*ASC_twilightDevice|.*ASC_ExternalTrigger|.*ASC_Shading_StateChange_SunnyCloudy|.*ASC_TempSensor|.*ASC_Shading_Mode)(\s.*|$) /
},
@{$events} @{$events}
) )
{ {
EventProcessingGeneral( $hash, undef, join( ' ', @{$events} ) ); EventProcessingGeneral( $hash, undef, join( ' ', @{$events} ) );
} }
} }
elsif ( grep m{^($posReading):\s\d{1,3}(\.\d{1,3})?$}xms, @{$events} ) { elsif ( grep { /^($posReading):\s\d{1,3}(\.\d{1,3})?$/ }, @{$events} ) {
ASC_Debug( 'Notify: ' ASC_Debug( 'Notify: '
. ' ASC_Pos_Reading Event vom Rollo ' . ' ASC_Pos_Reading Event vom Rollo '
. $devname . $devname
@ -1337,7 +1340,7 @@ sub wiggle {
} }
} }
::InternalTimer( ::gettimeofday() + 60, \&_SetCmdFn, \%h ); ::InternalTimer( ::gettimeofday() + 60, \&SetCmdFn, \%h );
return; return;
} }
@ -1741,7 +1744,7 @@ sub _DetermineSlatCmd {
: $value; : $value;
} }
sub _SetCmdFn { sub SetCmdFn {
my $h = shift; my $h = shift;
my $shuttersDev = $h->{shuttersDev}; my $shuttersDev = $h->{shuttersDev};
@ -1888,7 +1891,7 @@ sub _SetCmdFn {
return; return;
} }
sub _setShuttersLastDriveDelayed { sub setShuttersLastDriveDelayed {
my $h = shift; my $h = shift;
my $shuttersDevHash = $h->{devHash}; my $shuttersDevHash = $h->{devHash};

View File

@ -235,7 +235,7 @@ sub setDriveCmd {
::gettimeofday() + ::gettimeofday() +
$FHEM::Automation::ShuttersControl::shutters $FHEM::Automation::ShuttersControl::shutters
->getSelfDefenseAbsentDelay, ->getSelfDefenseAbsentDelay,
\&FHEM::Automation::ShuttersControl::_SetCmdFn, \%h \&FHEM::Automation::ShuttersControl::SetCmdFn, \%h
); );
$FHEM::Automation::ShuttersControl::shutters->setSelfDefenseAbsent( $FHEM::Automation::ShuttersControl::shutters->setSelfDefenseAbsent(
1, 0, \%h ); 1, 0, \%h );
@ -249,7 +249,7 @@ sub setDriveCmd {
$FHEM::Automation::ShuttersControl::shutters $FHEM::Automation::ShuttersControl::shutters
->getDelayStart ->getDelayStart
), ),
\&FHEM::Automation::ShuttersControl::_SetCmdFn, \&FHEM::Automation::ShuttersControl::SetCmdFn,
\%h \%h
); );
@ -260,7 +260,7 @@ sub setDriveCmd {
elsif ($offSetStart < 1 elsif ($offSetStart < 1
|| $FHEM::Automation::ShuttersControl::shutters->getNoDelay ) || $FHEM::Automation::ShuttersControl::shutters->getNoDelay )
{ {
FHEM::Automation::ShuttersControl::_SetCmdFn( \%h ); FHEM::Automation::ShuttersControl::SetCmdFn( \%h );
FHEM::Automation::ShuttersControl::ASC_Debug( 'FnSetDriveCmd: ' FHEM::Automation::ShuttersControl::ASC_Debug( 'FnSetDriveCmd: '
. $FHEM::Automation::ShuttersControl::shutters->getShuttersDev . $FHEM::Automation::ShuttersControl::shutters->getShuttersDev
. ' - NICHT versetztes fahren' ); . ' - NICHT versetztes fahren' );
@ -348,8 +348,7 @@ sub setLastDriveReading {
); );
::InternalTimer( ::gettimeofday() + 0.1, ::InternalTimer( ::gettimeofday() + 0.1,
\&FHEM::Automation::ShuttersControl::_setShuttersLastDriveDelayed, \&FHEM::Automation::ShuttersControl::setShuttersLastDriveDelayed, \%h );
\%h );
return; return;
} }