rewrite change Attributs

This commit is contained in:
Marko Oldenburg
2019-09-17 16:24:48 +02:00
parent 3d9b4b5ba9
commit 8d1bc376d5

View File

@@ -292,11 +292,8 @@ sub ascAPIget($@) {
sub Initialize($) { sub Initialize($) {
my ($hash) = @_; my ($hash) = @_;
### alte Attribute welche entfernt werden ### alte Attribute welche entfernt werden
my $oldAttr = my $oldAttr = 'ASC_shuttersDriveOffset ';
'ASC_shuttersDriveOffset ';
## Da ich mit package arbeite müssen in die Initialize für die jeweiligen hash Fn Funktionen der Funktionsname ## Da ich mit package arbeite müssen in die Initialize für die jeweiligen hash Fn Funktionen der Funktionsname
# und davor mit :: getrennt der eigentliche package Name des Modules # und davor mit :: getrennt der eigentliche package Name des Modules
@@ -732,21 +729,18 @@ sub ShuttersDeviceScan($) {
$shutters->setAttrUpdateChanges( 'ASC_Self_Defense_Exclude', $shutters->setAttrUpdateChanges( 'ASC_Self_Defense_Exclude',
AttrVal( $_, 'ASC_Self_Defense_Exclude', 'none' ) ); AttrVal( $_, 'ASC_Self_Defense_Exclude', 'none' ) );
delFromDevAttrList( $_, 'ASC_Self_Defense_Exclude' ); delFromDevAttrList( $_, 'ASC_Self_Defense_Exclude' );
$shutters->setAttrUpdateChanges( 'ASC_Drive_Offset',
AttrVal( $_, 'ASC_Drive_Offset', 'none' ) );
delFromDevAttrList( $_, 'ASC_Drive_Offset' );
$shutters->setAttrUpdateChanges( 'ASC_Drive_OffsetStart',
AttrVal( $_, 'ASC_Drive_OffsetStart', 'none' ) );
delFromDevAttrList( $_, 'ASC_Drive_OffsetStart' );
} }
CommandAttr(undef,$name . ' ASC_shuttersDriveDelay ' . AttrVal($name,'ASC_shuttersDriveOffset',-1))
CommandAttr( undef,
$name
. ' ASC_shuttersDriveDelay '
. AttrVal( $name, 'ASC_shuttersDriveOffset', -1 ) )
if ( AttrVal( $name, 'ASC_shuttersDriveOffset', 'none' ) ne 'none' ); if ( AttrVal( $name, 'ASC_shuttersDriveOffset', 'none' ) ne 'none' );
CommandDeleteAttr( undef, $name . ' ASC_shuttersDriveOffset' ) CommandDeleteAttr( undef, $name . ' ASC_shuttersDriveOffset' )
if ( AttrVal( $name, 'ASC_shuttersDriveOffset', 'none' ) ne 'none' ); if ( AttrVal( $name, 'ASC_shuttersDriveOffset', 'none' ) ne 'none' );
#### ####
#### ####
@@ -1049,7 +1043,13 @@ sub EventProcessingWindowRec($@) {
{ {
$shutters->setLastDrive('window closed at night'); $shutters->setLastDrive('window closed at night');
$shutters->setNoOffset(1); $shutters->setNoOffset(1);
$shutters->setDriveCmd( ($shutters->getSleepPos > 0 ? $shutters->getSleepPos : $shutters->getClosedPos) ); $shutters->setDriveCmd(
(
$shutters->getSleepPos > 0
? $shutters->getSleepPos
: $shutters->getClosedPos
)
);
} }
} }
elsif ( elsif (
@@ -1096,10 +1096,12 @@ sub EventProcessingWindowRec($@) {
$shutters->setLastDrive($setLastDrive); $shutters->setLastDrive($setLastDrive);
$shutters->setNoOffset(1); $shutters->setNoOffset(1);
$shutters->setDriveCmd( $shutters->setDriveCmd(
# ( # (
# $shutters->getShuttersPlace eq 'terrace' # $shutters->getShuttersPlace eq 'terrace'
# ? $shutters->getOpenPos # ? $shutters->getOpenPos
$posValue $posValue
# ) # )
); );
} }
@@ -1177,8 +1179,10 @@ sub EventProcessingRoommate($@) {
) )
{ {
if ( if (
(not $shutters->getIsDay (
or $shutters->getDown eq 'roommate') not $shutters->getIsDay
or $shutters->getDown eq 'roommate'
)
and IsAfterShuttersTimeBlocking($shuttersDev) and IsAfterShuttersTimeBlocking($shuttersDev)
and ( $getModeDown eq 'home' and ( $getModeDown eq 'home'
or $getModeDown eq 'always' ) or $getModeDown eq 'always' )
@@ -1189,7 +1193,10 @@ sub EventProcessingRoommate($@) {
if ( CheckIfShuttersWindowRecOpen($shuttersDev) == 0 if ( CheckIfShuttersWindowRecOpen($shuttersDev) == 0
or $shutters->getVentilateOpen eq 'off' ) or $shutters->getVentilateOpen eq 'off' )
{ {
$posValue = ($shutters->getSleepPos > 0 ? $shutters->getSleepPos : $shutters->getClosedPos); $posValue =
( $shutters->getSleepPos > 0
? $shutters->getSleepPos
: $shutters->getClosedPos );
} }
else { else {
$posValue = $shutters->getVentilatePos; $posValue = $shutters->getVentilatePos;
@@ -1200,8 +1207,10 @@ sub EventProcessingRoommate($@) {
ShuttersCommandSet( $hash, $shuttersDev, $posValue ); ShuttersCommandSet( $hash, $shuttersDev, $posValue );
} }
elsif ( elsif (
($shutters->getIsDay (
or $shutters->getUp eq 'roommate') $shutters->getIsDay
or $shutters->getUp eq 'roommate'
)
and IsAfterShuttersTimeBlocking($shuttersDev) and IsAfterShuttersTimeBlocking($shuttersDev)
and ( $getModeUp eq 'home' and ( $getModeUp eq 'home'
or $getModeUp eq 'always' ) or $getModeUp eq 'always' )
@@ -1250,7 +1259,10 @@ sub EventProcessingRoommate($@) {
if ( CheckIfShuttersWindowRecOpen($shuttersDev) == 0 if ( CheckIfShuttersWindowRecOpen($shuttersDev) == 0
or $shutters->getVentilateOpen eq 'off' ) or $shutters->getVentilateOpen eq 'off' )
{ {
$posValue = ($shutters->getSleepPos > 0 ? $shutters->getSleepPos : $shutters->getClosedPos); $posValue =
( $shutters->getSleepPos > 0
? $shutters->getSleepPos
: $shutters->getClosedPos );
} }
else { else {
$posValue = $shutters->getVentilatePos; $posValue = $shutters->getVentilatePos;
@@ -1267,21 +1279,29 @@ sub EventProcessingRoommate($@) {
or $shutters->getShadingMode eq 'absent' ) or $shutters->getShadingMode eq 'absent' )
) )
{ {
if ( ($shutters->getIsDay if (
or $shutters->getUp eq 'roommate') (
$shutters->getIsDay
or $shutters->getUp eq 'roommate'
)
and $shutters->getIfInShading and $shutters->getIfInShading
and and
not $shutters->getQueryShuttersPos( $shutters->getShadingPos ) not $shutters->getQueryShuttersPos( $shutters->getShadingPos )
and $shutters->getShadingMode eq 'absent' ) and $shutters->getShadingMode eq 'absent'
)
{ {
$posValue = $shutters->getShadingPos; $posValue = $shutters->getShadingPos;
$shutters->setLastDrive('shading in'); $shutters->setLastDrive('shading in');
ShuttersCommandSet( $hash, $shuttersDev, $posValue ); ShuttersCommandSet( $hash, $shuttersDev, $posValue );
} }
elsif ( (not $shutters->getIsDay elsif (
or $shutters->getDown eq 'roommate') (
not $shutters->getIsDay
or $shutters->getDown eq 'roommate'
)
and $getModeDown eq 'absent' and $getModeDown eq 'absent'
and $getRoommatesStatus eq 'absent' ) and $getRoommatesStatus eq 'absent'
)
{ {
$posValue = $shutters->getClosedPos; $posValue = $shutters->getClosedPos;
$shutters->setLastDrive('roommate absent'); $shutters->setLastDrive('roommate absent');
@@ -1313,18 +1333,18 @@ sub EventProcessingResidents($@) {
{ {
if ( if (
$ascDev->getSelfDefense eq 'on' $ascDev->getSelfDefense eq 'on'
and ( $shutters->getSelfDefenseMode eq 'absent' and (
$shutters->getSelfDefenseMode eq 'absent'
or ( CheckIfShuttersWindowRecOpen($shuttersDev) == 2 or ( CheckIfShuttersWindowRecOpen($shuttersDev) == 2
and $shutters->getSelfDefenseMode eq 'gone' and $shutters->getSelfDefenseMode eq 'gone'
and $shutters->getShuttersPlace eq 'terrace' and $shutters->getShuttersPlace eq 'terrace'
and $shutters->getSelfDefenseMode ne 'off' and $shutters->getSelfDefenseMode ne 'off' )
)
) )
) )
{ {
$shutters->setLastDrive('selfDefense active'); $shutters->setLastDrive('selfDefense active');
$shutters->setSelfDefenseAbsent( 0, 1 $shutters->setSelfDefenseAbsent( 0, 1 )
); # der erste Wert ist ob der timer schon läuft, der zweite ist ob self defense aktiv ist durch die Bedingungen ; # der erste Wert ist ob der timer schon läuft, der zweite ist ob self defense aktiv ist durch die Bedingungen
$shutters->setDriveCmd( $shutters->getClosedPos ); $shutters->setDriveCmd( $shutters->getClosedPos );
} }
elsif ( elsif (
@@ -1827,7 +1847,10 @@ sub EventProcessingBrightness($@) {
elsif ( CheckIfShuttersWindowRecOpen($shuttersDev) == 0 elsif ( CheckIfShuttersWindowRecOpen($shuttersDev) == 0
or $shutters->getVentilateOpen eq 'off' ) or $shutters->getVentilateOpen eq 'off' )
{ {
$posValue = ($shutters->getSleepPos > 0 ? $shutters->getSleepPos : $shutters->getClosedPos); $posValue =
( $shutters->getSleepPos > 0
? $shutters->getSleepPos
: $shutters->getClosedPos );
} }
else { $posValue = $shutters->getVentilatePos; } else { $posValue = $shutters->getVentilatePos; }
@@ -2586,6 +2609,8 @@ sub RenewSunRiseSetShuttersTimer($) {
$shutters->setInTimerFuncHash(undef); $shutters->setInTimerFuncHash(undef);
CreateSunRiseSetShuttersTimer( $hash, $_ ); CreateSunRiseSetShuttersTimer( $hash, $_ );
#### Temporär angelegt damit die neue Attributs Parameter Syntax verteilt werden kann #### Temporär angelegt damit die neue Attributs Parameter Syntax verteilt werden kann
#### Gleichlautende Attribute wo lediglich die Parameter geändert werden sollen müssen bereits in der Funktion ShuttersDeviceScan gelöscht werden #### Gleichlautende Attribute wo lediglich die Parameter geändert werden sollen müssen bereits in der Funktion ShuttersDeviceScan gelöscht werden
#### vorher empfiehlt es sich die dort vergebenen Parameter aus zu lesen um sie dann hier wieder neu zu setzen. Dazu wird das shutters Objekt um einen Eintrag #### vorher empfiehlt es sich die dort vergebenen Parameter aus zu lesen um sie dann hier wieder neu zu setzen. Dazu wird das shutters Objekt um einen Eintrag
@@ -2599,15 +2624,14 @@ sub RenewSunRiseSetShuttersTimer($) {
if ( $shutters->getAttrUpdateChanges('ASC_Up') ne 'none' ); if ( $shutters->getAttrUpdateChanges('ASC_Up') ne 'none' );
$attr{$_}{'ASC_Down'} = $shutters->getAttrUpdateChanges('ASC_Down') $attr{$_}{'ASC_Down'} = $shutters->getAttrUpdateChanges('ASC_Down')
if ( $shutters->getAttrUpdateChanges('ASC_Down') ne 'none' ); if ( $shutters->getAttrUpdateChanges('ASC_Down') ne 'none' );
$attr{$_}{'ASC_Self_Defense_Mode'} = $shutters->getAttrUpdateChanges('ASC_Self_Defense_Mode') $attr{$_}{'ASC_Self_Defense_Mode'} =
if ( $shutters->getAttrUpdateChanges('ASC_Self_Defense_Mode') ne 'none' ); $shutters->getAttrUpdateChanges('ASC_Self_Defense_Mode')
if ( $shutters->getAttrUpdateChanges('ASC_Self_Defense_Mode') ne
'none' );
$attr{$_}{'ASC_Self_Defense_Mode'} = 'off' $attr{$_}{'ASC_Self_Defense_Mode'} = 'off'
if ( $shutters->getAttrUpdateChanges('ASC_Self_Defense_Exclude') eq 'on' ); if (
$attr{$_}{'ASC_Drive_Delay'} = $shutters->getAttrUpdateChanges('ASC_Drive_Offset') $shutters->getAttrUpdateChanges('ASC_Self_Defense_Exclude') eq
if ( $shutters->getAttrUpdateChanges('ASC_Drive_Offset') ne 'none' ); 'on' );
$attr{$_}{'ASC_Drive_DelayStart'} = $shutters->getAttrUpdateChanges('ASC_Drive_OffsetStart')
if ( $shutters->getAttrUpdateChanges('ASC_Drive_OffsetStart') ne 'none' );
CommandDeleteReading( undef, $_ . ' .ASC_AttrUpdateChanges_.*' ) CommandDeleteReading( undef, $_ . ' .ASC_AttrUpdateChanges_.*' )
@@ -2618,14 +2642,17 @@ sub RenewSunRiseSetShuttersTimer($) {
readingsSingleUpdate( $defs{$_}, readingsSingleUpdate( $defs{$_},
'.ASC_AttrUpdateChanges_' . $hash->{VERSION}, '.ASC_AttrUpdateChanges_' . $hash->{VERSION},
1, 0 ); 1, 0 );
# $attr{$_}{'ASC_Shading_MinMax_Elevation'} =
# AttrVal( $_, 'ASC_Shading_Min_Elevation', 'none' )
# if ( AttrVal( $_, 'ASC_Shading_Min_Elevation', 'none' ) ne 'none' );
#
# delFromDevAttrList( $_, 'ASC_Shading_Min_Elevation' )
# ; # temporär muss später gelöscht werden ab Version 0.6.17
} }
$attr{$_}{ASC_Drive_Delay} = AttrVal( $_, 'ASC_Drive_Offset', 'none' )
if ( AttrVal( $_, 'ASC_Drive_Offset', 'none' ) ne 'none' );
delFromDevAttrList( $_, 'ASC_Drive_Offset' );
$attr{$_}{ASC_Drive_DelayStart} = AttrVal( $_, 'ASC_Drive_OffsetStart', 'none' )
if ( AttrVal( $_, 'ASC_Drive_OffsetStart', 'none' ) ne 'none' );
delFromDevAttrList( $_, 'ASC_Drive_OffsetStart' );
} }
} }
@@ -2711,11 +2738,9 @@ sub SunSetShuttersAfterTimerFn($) {
and ( and (
$ascDev->getSelfDefense eq 'off' $ascDev->getSelfDefense eq 'off'
or $shutters->getSelfDefenseMode eq 'off' or $shutters->getSelfDefenseMode eq 'off'
or ( or ( $ascDev->getSelfDefense eq 'on'
$ascDev->getSelfDefense eq 'on'
and $ascDev->getResidentsStatus ne 'absent' and $ascDev->getResidentsStatus ne 'absent'
and $ascDev->getResidentsStatus ne 'gone' and $ascDev->getResidentsStatus ne 'gone' )
)
) )
) )
{ {
@@ -2732,8 +2757,17 @@ sub SunSetShuttersAfterTimerFn($) {
else { else {
$shutters->setPrivacyDownStatus(0); $shutters->setPrivacyDownStatus(0);
$shutters->setLastDrive('night close'); $shutters->setLastDrive('night close');
ShuttersCommandSet( $hash, $shuttersDev, ShuttersCommandSet(
PositionValueWindowRec( $shuttersDev, ($shutters->getSleepPos > 0 ? $shutters->getSleepPos : $shutters->getClosedPos) ) $hash,
$shuttersDev,
PositionValueWindowRec(
$shuttersDev,
(
$shutters->getSleepPos > 0
? $shutters->getSleepPos
: $shutters->getClosedPos
)
)
); );
} }
} }
@@ -2768,8 +2802,7 @@ sub SunRiseShuttersAfterTimerFn($) {
or $shutters->getSelfDefenseMode eq 'off' or $shutters->getSelfDefenseMode eq 'off'
or ( $ascDev->getSelfDefense eq 'on' or ( $ascDev->getSelfDefense eq 'on'
and $ascDev->getResidentsStatus ne 'absent' and $ascDev->getResidentsStatus ne 'absent'
and $ascDev->getResidentsStatus ne 'gone' and $ascDev->getResidentsStatus ne 'gone' )
)
) )
) )
{ {
@@ -4389,11 +4422,9 @@ sub getBrightnessAverage {
return &FHEM::AutoShuttersControl::_averageBrightness( return &FHEM::AutoShuttersControl::_averageBrightness(
@{ $self->{ $self->{shuttersDev} }->{BrightnessAverageArray}->{VAL} } ) @{ $self->{ $self->{shuttersDev} }->{BrightnessAverageArray}->{VAL} } )
if ( if (
ref( ref( $self->{ $self->{shuttersDev} }->{BrightnessAverageArray}->{VAL} )
$self->{ $self->{shuttersDev} }->{BrightnessAverageArray}->{VAL} eq 'ARRAY'
) eq 'ARRAY' and scalar(
and
scalar(
@{ @{
$self->{ $self->{shuttersDev} }->{BrightnessAverageArray}->{VAL} $self->{ $self->{shuttersDev} }->{BrightnessAverageArray}->{VAL}
} }