code style

This commit is contained in:
Marko Oldenburg 2019-04-25 21:34:46 +02:00
parent cae15e958b
commit 407cc28291

View File

@ -162,7 +162,7 @@ my %userAttrList = (
'ASC_AutoAstroModeEveningHorizon:-9,-8,-7,-6,-5,-4,-3,-2,-1,0,1,2,3,4,5,6,7,8,9' 'ASC_AutoAstroModeEveningHorizon:-9,-8,-7,-6,-5,-4,-3,-2,-1,0,1,2,3,4,5,6,7,8,9'
=> '-', => '-',
'ASC_Open_Pos:0,10,20,30,40,50,60,70,80,90,100' => [ '', 0, 100 ], 'ASC_Open_Pos:0,10,20,30,40,50,60,70,80,90,100' => [ '', 0, 100 ],
'ASC_Closed_Pos:0,10,20,30,40,50,60,70,80,90,100' => [ '', 100, 0 ], 'ASC_Closed_Pos:0,10,20,30,40,50,60,70,80,90,100' => [ '', 100, 0 ],
'ASC_Pos_Reading' => [ '', 'position', 'pct' ], 'ASC_Pos_Reading' => [ '', 'position', 'pct' ],
'ASC_Time_Up_Early' => '-', 'ASC_Time_Up_Early' => '-',
'ASC_Time_Up_Late' => '-', 'ASC_Time_Up_Late' => '-',
@ -716,16 +716,14 @@ sub UserAttributs_Readings_ForShutters($$) {
if ( ref($attribValue) ne 'ARRAY' ) { if ( ref($attribValue) ne 'ARRAY' ) {
$attr{$_}{ ( split( ':', $attrib ) )[0] } = $attribValue $attr{$_}{ ( split( ':', $attrib ) )[0] } = $attribValue
if ( if (
not not defined( $attr{$_}{ ( split( ':', $attrib ) )[0] } )
defined( $attr{$_}{ ( split( ':', $attrib ) )[0] } )
and $attribValue ne '-' ); and $attribValue ne '-' );
} }
else { else {
$attr{$_}{ ( split( ':', $attrib ) )[0] } = $attr{$_}{ ( split( ':', $attrib ) )[0] } =
$attribValue->[ AttrVal( $_, 'ASC', 2 ) ] $attribValue->[ AttrVal( $_, 'ASC', 2 ) ]
if ( if (
not not defined( $attr{$_}{ ( split( ':', $attrib ) )[0] } )
defined( $attr{$_}{ ( split( ':', $attrib ) )[0] } )
and $attrib eq 'ASC_Pos_Reading' ); and $attrib eq 'ASC_Pos_Reading' );
} }
} }
@ -1219,20 +1217,19 @@ sub EventProcessingWind($@) {
$shutters->setShuttersDev($shuttersDev); $shutters->setShuttersDev($shuttersDev);
ASC_Debug( 'EventProcessingWind: ' ASC_Debug( 'EventProcessingWind: '
. $shutters->getShuttersDev . $shutters->getShuttersDev
. ' - WindProtection1: ' . ' - WindProtection1: '
. $shutters->getWindProtection . $shutters->getWindProtection
. ' WindMax1: ' . ' WindMax1: '
. $shutters->getWindMax . $shutters->getWindMax
. ' WindMin1: ' . ' WindMin1: '
. $shutters->getWindMin . $shutters->getWindMin
. ' Bekommender Wert1: ' . ' Bekommender Wert1: '
. $1 . $1 );
);
$shutters->setWindProtection('unprotection') $shutters->setWindProtection('unprotection')
if ( not defined( $shutters->getWindProtection ) if ( not defined( $shutters->getWindProtection )
or not $shutters->getWindProtection ); or not $shutters->getWindProtection );
next next
if ( CheckIfShuttersWindowRecOpen($shuttersDev) != 0 if ( CheckIfShuttersWindowRecOpen($shuttersDev) != 0
@ -1252,18 +1249,17 @@ sub EventProcessingWind($@) {
$shutters->setDriveCmd( $shutters->getLastPos ); $shutters->setDriveCmd( $shutters->getLastPos );
$shutters->setWindProtection('unprotection'); $shutters->setWindProtection('unprotection');
} }
ASC_Debug( 'EventProcessingWind: ' ASC_Debug( 'EventProcessingWind: '
. $shutters->getShuttersDev . $shutters->getShuttersDev
. ' - WindProtection2: ' . ' - WindProtection2: '
. $shutters->getWindProtection . $shutters->getWindProtection
. ' WindMax2: ' . ' WindMax2: '
. $shutters->getWindMax . $shutters->getWindMax
. ' WindMin2: ' . ' WindMin2: '
. $shutters->getWindMin . $shutters->getWindMin
. ' Bekommender Wert2: ' . ' Bekommender Wert2: '
. $1 . $1 );
);
} }
} }
} }
@ -1843,8 +1839,8 @@ sub ShadingProcessing($@) {
} }
Log3( $name, 4, Log3( $name, 4,
"AutoShuttersControl ($name) - Shading Processing - In der Routine zum fahren der Rollläden, Shading Wert: " "AutoShuttersControl ($name) - Shading Processing - In der Routine zum fahren der Rollläden, Shading Wert: "
. $shutters->getShadingStatus ); . $shutters->getShadingStatus );
ASC_Debug( ASC_Debug(
'ShadingProcessing: ' 'ShadingProcessing: '
@ -1912,7 +1908,8 @@ sub EventProcessingShutters($@) {
if ( $events =~ m#.*:\s(\d+)# ) { if ( $events =~ m#.*:\s(\d+)# ) {
$shutters->setShuttersDev($shuttersDev); $shutters->setShuttersDev($shuttersDev);
$ascDev->setPosReading; $ascDev->setPosReading;
if ( ( int( gettimeofday() ) - $shutters->getLastPosTimestamp ) > $shutters->getDriveUpMaxDuration if ( ( int( gettimeofday() ) - $shutters->getLastPosTimestamp ) >
$shutters->getDriveUpMaxDuration
and $shutters->getLastPos != $shutters->getStatus ) and $shutters->getLastPos != $shutters->getStatus )
{ {
$shutters->setLastDrive('manual'); $shutters->setLastDrive('manual');
@ -2454,7 +2451,8 @@ sub AutoSearchTwilightDev($) {
sub GetAttrValues($@) { sub GetAttrValues($@) {
my ( $dev, $attribut, $default ) = @_; my ( $dev, $attribut, $default ) = @_;
my @values = split( ' ', AttrVal( $dev, $attribut, (defined($default) ? $default : 'none') ) ); my @values = split( ' ',
AttrVal( $dev, $attribut, ( defined($default) ? $default : 'none' ) ) );
my ( $value1, $value2 ) = split( ':', $values[0] ); my ( $value1, $value2 ) = split( ':', $values[0] );
my ( $value3, $value4 ) = split( ':', $values[1] ) my ( $value3, $value4 ) = split( ':', $values[1] )
if ( defined( $values[1] ) ); if ( defined( $values[1] ) );
@ -3633,7 +3631,9 @@ sub getASC {
sub getAntiFreezePos { sub getAntiFreezePos {
my $self = shift; my $self = shift;
return AttrVal( $self->{shuttersDev}, 'ASC_Antifreeze_Pos', $userAttrList{ASC_Antifreeze_Pos}[AttrVal( $self->{shuttersDev}, 'ASC', 2 )] ); return AttrVal( $self->{shuttersDev}, 'ASC_Antifreeze_Pos',
$userAttrList{ASC_Antifreeze_Pos}
[ AttrVal( $self->{shuttersDev}, 'ASC', 2 ) ] );
} }
sub getShuttersPlace { sub getShuttersPlace {
@ -3669,13 +3669,15 @@ sub getWiggleValue {
### Begin Beschattung ### Begin Beschattung
sub getShadingPos { sub getShadingPos {
my $self = shift; my $self = shift;
return AttrVal( $self->{shuttersDev}, 'ASC_Shading_Pos', $userAttrList{'ASC_Shading_Pos:10,20,30,40,50,60,70,80,90,100'}[AttrVal( $self->{shuttersDev}, 'ASC', 2 )] ); return AttrVal( $self->{shuttersDev}, 'ASC_Shading_Pos',
$userAttrList{'ASC_Shading_Pos:10,20,30,40,50,60,70,80,90,100'}
[ AttrVal( $self->{shuttersDev}, 'ASC', 2 ) ] );
} }
sub getShadingMode { sub getShadingMode {
my $self = shift; my $self = shift;
return AttrVal( $self->{shuttersDev}, 'ASC_Shading_Mode', 'off' ); return AttrVal( $self->{shuttersDev}, 'ASC_Shading_Mode', 'off' );
} }
@ -3836,19 +3838,25 @@ sub getPosCmd {
sub getOpenPos { sub getOpenPos {
my $self = shift; my $self = shift;
return AttrVal( $self->{shuttersDev}, 'ASC_Open_Pos', $userAttrList{'ASC_Open_Pos:0,10,20,30,40,50,60,70,80,90,100'}[AttrVal( $self->{shuttersDev}, 'ASC', 2 )] ); return AttrVal( $self->{shuttersDev}, 'ASC_Open_Pos',
$userAttrList{'ASC_Open_Pos:0,10,20,30,40,50,60,70,80,90,100'}
[ AttrVal( $self->{shuttersDev}, 'ASC', 2 ) ] );
} }
sub getVentilatePos { sub getVentilatePos {
my $self = shift; my $self = shift;
return AttrVal( $self->{shuttersDev}, 'ASC_Ventilate_Pos', $userAttrList{'ASC_Ventilate_Pos:10,20,30,40,50,60,70,80,90,100'}[AttrVal( $self->{shuttersDev}, 'ASC', 2 )] ); return AttrVal( $self->{shuttersDev}, 'ASC_Ventilate_Pos',
$userAttrList{'ASC_Ventilate_Pos:10,20,30,40,50,60,70,80,90,100'}
[ AttrVal( $self->{shuttersDev}, 'ASC', 2 ) ] );
} }
sub getClosedPos { sub getClosedPos {
my $self = shift; my $self = shift;
return AttrVal( $self->{shuttersDev}, 'ASC_Closed_Pos', $userAttrList{'ASC_Closed_Pos:0,10,20,30,40,50,60,70,80,90,100'}[AttrVal( $self->{shuttersDev}, 'ASC', 2 )] ); return AttrVal( $self->{shuttersDev}, 'ASC_Closed_Pos',
$userAttrList{'ASC_Closed_Pos:0,10,20,30,40,50,60,70,80,90,100'}
[ AttrVal( $self->{shuttersDev}, 'ASC', 2 ) ] );
} }
sub getVentilateOpen { sub getVentilateOpen {
@ -3860,7 +3868,9 @@ sub getVentilateOpen {
sub getComfortOpenPos { sub getComfortOpenPos {
my $self = shift; my $self = shift;
return AttrVal( $self->{shuttersDev}, 'ASC_ComfortOpen_Pos', $userAttrList{'ASC_ComfortOpen_Pos:0,10,20,30,40,50,60,70,80,90,100'}[AttrVal( $self->{shuttersDev}, 'ASC', 2 )] ); return AttrVal( $self->{shuttersDev}, 'ASC_ComfortOpen_Pos',
$userAttrList{'ASC_ComfortOpen_Pos:0,10,20,30,40,50,60,70,80,90,100'}
[ AttrVal( $self->{shuttersDev}, 'ASC', 2 ) ] );
} }
sub getPartyMode { sub getPartyMode {
@ -3870,13 +3880,13 @@ sub getPartyMode {
} }
sub getRoommates { sub getRoommates {
my $self = shift; my $self = shift;
return AttrVal( $self->{shuttersDev}, 'ASC_Roommate_Device', 'none' ); return AttrVal( $self->{shuttersDev}, 'ASC_Roommate_Device', 'none' );
} }
sub getRoommatesReading { sub getRoommatesReading {
my $self = shift; my $self = shift;
return AttrVal( $self->{shuttersDev}, 'ASC_Roommate_Reading', 'state' ); return AttrVal( $self->{shuttersDev}, 'ASC_Roommate_Reading', 'state' );
} }
@ -3922,7 +3932,8 @@ sub getWindMax {
# max:hyst pos # max:hyst pos
$self->{ $self->{shuttersDev} }->{ASC_WindParameters}->{triggermax} = $max; $self->{ $self->{shuttersDev} }->{ASC_WindParameters}->{triggermax} = $max;
$self->{ $self->{shuttersDev} }->{ASC_WindParameters}->{triggerhyst} = $hyst; $self->{ $self->{shuttersDev} }->{ASC_WindParameters}->{triggerhyst} =
$hyst;
$self->{ $self->{shuttersDev} }->{ASC_WindParameters}->{closedPos} = $self->{ $self->{shuttersDev} }->{ASC_WindParameters}->{closedPos} =
( $pos ne 'none' ? $pos : $shutters->getOpenPos ); ( $pos ne 'none' ? $pos : $shutters->getOpenPos );
@ -3978,17 +3989,15 @@ sub getAntiFreeze {
} }
sub getAutoAstroModeMorning { sub getAutoAstroModeMorning {
my $self = shift; my $self = shift;
return AttrVal( $self->{shuttersDev}, 'ASC_AutoAstroModeMorning', return AttrVal( $self->{shuttersDev}, 'ASC_AutoAstroModeMorning', 'none' );
'none' );
} }
sub getAutoAstroModeEvening { sub getAutoAstroModeEvening {
my $self = shift; my $self = shift;
return AttrVal( $self->{shuttersDev}, 'ASC_AutoAstroModeEvening', return AttrVal( $self->{shuttersDev}, 'ASC_AutoAstroModeEvening', 'none' );
'none' );
} }
sub getAutoAstroModeMorningHorizon { sub getAutoAstroModeMorningHorizon {
@ -4044,8 +4053,7 @@ sub getTimeDownLate {
sub getTimeUpWeHoliday { sub getTimeUpWeHoliday {
my $self = shift; my $self = shift;
return AttrVal( $self->{shuttersDev}, 'ASC_Time_Up_WE_Holiday', return AttrVal( $self->{shuttersDev}, 'ASC_Time_Up_WE_Holiday', '08:00' );
'08:00' );
} }
sub getBrightnessMinVal { sub getBrightnessMinVal {
@ -4089,7 +4097,7 @@ sub getBrightnessMaxVal {
sub getDriveUpMaxDuration { sub getDriveUpMaxDuration {
my $self = shift; my $self = shift;
return AttrVal( $self->{shuttersDev}, 'ASC_DriveUpMaxDuration',60 ); return AttrVal( $self->{shuttersDev}, 'ASC_DriveUpMaxDuration', 60 );
} }
## Subklasse Readings von ASC_Shutters ## ## Subklasse Readings von ASC_Shutters ##
@ -4130,7 +4138,7 @@ sub getStatus {
} }
sub getDelayCmd { sub getDelayCmd {
my $self = shift; my $self = shift;
return $self->{ $self->{shuttersDev} }{delayCmd}; return $self->{ $self->{shuttersDev} }{delayCmd};
} }
@ -4156,13 +4164,13 @@ BEGIN {
} }
sub getSubTyp { sub getSubTyp {
my $self = shift; my $self = shift;
return AttrVal( $self->{shuttersDev}, 'ASC_WindowRec_subType', 'twostate' ); return AttrVal( $self->{shuttersDev}, 'ASC_WindowRec_subType', 'twostate' );
} }
sub _getWinDev { sub _getWinDev {
my $self = shift; my $self = shift;
return AttrVal( $self->{shuttersDev}, 'ASC_WindowRec', 'none' ); return AttrVal( $self->{shuttersDev}, 'ASC_WindowRec', 'none' );
} }
@ -4184,7 +4192,7 @@ BEGIN {
} }
sub getWinStatus { sub getWinStatus {
my $self = shift; my $self = shift;
return ReadingsVal( $shutters->_getWinDev, 'state', 'closed' ); return ReadingsVal( $shutters->_getWinDev, 'state', 'closed' );
} }
@ -4318,22 +4326,22 @@ sub setLastPosReading {
} }
sub getPartyMode { sub getPartyMode {
my $self = shift; my $self = shift;
my $name = $self->{name}; my $name = $self->{name};
return ReadingsVal( $name, 'partyMode', 'none' ); return ReadingsVal( $name, 'partyMode', 'none' );
} }
sub getHardLockOut { sub getHardLockOut {
my $self = shift; my $self = shift;
my $name = $self->{name}; my $name = $self->{name};
return ReadingsVal( $name, 'hardLockOut', 'none' ); return ReadingsVal( $name, 'hardLockOut', 'none' );
} }
sub getSunriseTimeWeHoliday { sub getSunriseTimeWeHoliday {
my $self = shift; my $self = shift;
my $name = $self->{name}; my $name = $self->{name};
return ReadingsVal( $name, 'sunriseTimeWeHoliday', 'none' ); return ReadingsVal( $name, 'sunriseTimeWeHoliday', 'none' );
} }
@ -4463,8 +4471,8 @@ sub _getTwilightDevice {
} }
sub getAutoAstroModeEvening { sub getAutoAstroModeEvening {
my $self = shift; my $self = shift;
my $name = $self->{name}; my $name = $self->{name};
return AttrVal( $name, 'ASC_autoAstroModeEvening', 'none' ); return AttrVal( $name, 'ASC_autoAstroModeEvening', 'none' );
} }
@ -4477,8 +4485,8 @@ sub getAutoAstroModeEveningHorizon {
} }
sub getAutoAstroModeMorning { sub getAutoAstroModeMorning {
my $self = shift; my $self = shift;
my $name = $self->{name}; my $name = $self->{name};
return AttrVal( $name, 'ASC_autoAstroModeMorning', 'none' ); return AttrVal( $name, 'ASC_autoAstroModeMorning', 'none' );
} }
@ -4491,15 +4499,15 @@ sub getAutoAstroModeMorningHorizon {
} }
sub getAutoShuttersControlMorning { sub getAutoShuttersControlMorning {
my $self = shift; my $self = shift;
my $name = $self->{name}; my $name = $self->{name};
return AttrVal( $name, 'ASC_autoShuttersControlMorning', 'none' ); return AttrVal( $name, 'ASC_autoShuttersControlMorning', 'none' );
} }
sub getAutoShuttersControlEvening { sub getAutoShuttersControlEvening {
my $self = shift; my $self = shift;
my $name = $self->{name}; my $name = $self->{name};
return AttrVal( $name, 'ASC_autoShuttersControlEvening', 'none' ); return AttrVal( $name, 'ASC_autoShuttersControlEvening', 'none' );
} }
@ -4512,8 +4520,8 @@ sub getAutoShuttersControlComfort {
} }
sub getFreezeTemp { sub getFreezeTemp {
my $self = shift; my $self = shift;
my $name = $self->{name}; my $name = $self->{name};
return AttrVal( $name, 'ASC_freezeTemp', 3 ); return AttrVal( $name, 'ASC_freezeTemp', 3 );
} }