first devel version with shading support

This commit is contained in:
Marko Oldenburg 2018-12-07 13:04:41 +01:00
parent 0bf225404e
commit c7181f449f

View File

@ -150,10 +150,10 @@ my %userAttrList = (
'ASC_Up:time,astro,brightness' => 'astro', 'ASC_Up:time,astro,brightness' => 'astro',
'ASC_Down:time,astro,brightness' => 'astro', 'ASC_Down:time,astro,brightness' => 'astro',
'ASC_AutoAstroModeMorning:REAL,CIVIL,NAUTIC,ASTRONOMIC,HORIZON' => 'none', 'ASC_AutoAstroModeMorning:REAL,CIVIL,NAUTIC,ASTRONOMIC,HORIZON' => 'none',
'ASC_AutoAstroModeMorningHorizon:-9,-8,-7,-6,-5,-4,-3,-2,-1,0,1,2,3,4,5,6,7,8,9' 'ASC_AutoAstroModeMorningHorizon:-9,-8,-7,-6,-5,-4,-3,-2,-1,0,1,2,3,4,5,6,7,8,9'
=> 'none', => 'none',
'ASC_AutoAstroModeEvening:REAL,CIVIL,NAUTIC,ASTRONOMIC,HORIZON' => 'none', 'ASC_AutoAstroModeEvening:REAL,CIVIL,NAUTIC,ASTRONOMIC,HORIZON' => 'none',
'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'
=> 'none', => 'none',
'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 ],
@ -167,23 +167,24 @@ my %userAttrList = (
'ASC_Ventilate_Window_Open:on,off' => 'on', 'ASC_Ventilate_Window_Open:on,off' => 'on',
'ASC_LockOut:soft,hard,off' => 'off', 'ASC_LockOut:soft,hard,off' => 'off',
'ASC_LockOut_Cmd:inhibit,blocked,protection' => 'none', 'ASC_LockOut_Cmd:inhibit,blocked,protection' => 'none',
'ASC_BlockingTime_afterManual' => 1200, 'ASC_BlockingTime_afterManual' => 1200,
'ASC_BlockingTime_beforNightClose' => 3600, 'ASC_BlockingTime_beforNightClose' => 3600,
'ASC_BlockingTime_beforDayOpen' => 3600, 'ASC_BlockingTime_beforDayOpen' => 3600,
'ASC_Brightness_Sensor' => 'none', 'ASC_Brightness_Sensor' => 'none',
'ASC_Brightness_Reading' => 'brightness', 'ASC_Brightness_Reading' => 'brightness',
'ASC_Shading_Direction' => 180, 'ASC_Shading_Direction' => 180,
'ASC_Shading_Pos:10,20,30,40,50,60,70,80,90,100' => [ '', 80, 20 ], 'ASC_Shading_Pos:10,20,30,40,50,60,70,80,90,100' => [ '', 80, 20 ],
'ASC_Shading_Mode:on,off,home,absent' => 'off', 'ASC_Shading_Mode:on,off,home,absent' => 'off',
'ASC_Shading_Angle_Left' => 75, 'ASC_Shading_Angle_Left' => 75,
'ASC_Shading_Angle_Right' => 75, 'ASC_Shading_Angle_Right' => 75,
'ASC_Shading_StateChange_Sunny' => 35000, 'ASC_Shading_StateChange_Sunny' => 35000,
'ASC_Shading_StateChange_Cloudy' => 20000, 'ASC_Shading_StateChange_Cloudy' => 20000,
'ASC_Shading_Min_Elevation' => 25.0, 'ASC_Shading_Min_Elevation' => 25.0,
'ASC_Shading_Min_OutsideTemperature' => 18, 'ASC_Shading_Min_OutsideTemperature' => 18,
'ASC_Shading_WaitingPeriod' => 1200, 'ASC_Shading_WaitingPeriod' => 1200,
# 'ASC_Shading_Fast_Open:on,off' => 'none',
# 'ASC_Shading_Fast_Close:on,off' => 'none', # 'ASC_Shading_Fast_Open:on,off' => 'none',
# 'ASC_Shading_Fast_Close:on,off' => 'none',
'ASC_Drive_Offset' => -1, 'ASC_Drive_Offset' => -1,
'ASC_WindowRec_subType:twostate,threestate' => 'twostate', 'ASC_WindowRec_subType:twostate,threestate' => 'twostate',
'ASC_ShuttersPlace:window,terrace' => 'window', 'ASC_ShuttersPlace:window,terrace' => 'window',
@ -191,7 +192,7 @@ my %userAttrList = (
'ASC_ComfortOpen_Pos:0,10,20,30,40,50,60,70,80,90,100' => [ '', 20, 80 ], 'ASC_ComfortOpen_Pos:0,10,20,30,40,50,60,70,80,90,100' => [ '', 20, 80 ],
'ASC_GuestRoom:on,off' => 'none', 'ASC_GuestRoom:on,off' => 'none',
'ASC_Antifreeze:off,soft,hard,am,pm' => 'off', 'ASC_Antifreeze:off,soft,hard,am,pm' => 'off',
'ASC_Antifreeze_Pos:5,10,15,20,25,30,35,40,45,50,55,60,65,70,75,80,85,90,95,100' 'ASC_Antifreeze_Pos:5,10,15,20,25,30,35,40,45,50,55,60,65,70,75,80,85,90,95,100'
=> [ '', 85, 15 ], => [ '', 85, 15 ],
'ASC_Partymode:on,off' => 'off', 'ASC_Partymode:on,off' => 'off',
'ASC_Roommate_Device' => 'none', 'ASC_Roommate_Device' => 'none',
@ -270,7 +271,8 @@ sub Define($$) {
) if ( AttrVal( $name, 'devStateIcon', 'none' ) eq 'none' ); ) if ( AttrVal( $name, 'devStateIcon', 'none' ) eq 'none' );
CommandDeleteReading( undef, $name . ' lockOut' ) CommandDeleteReading( undef, $name . ' lockOut' )
if ( ReadingsVal($name,'lockOut','none') ne 'none' ); # temporär ab Version 0.2.2 if ( ReadingsVal( $name, 'lockOut', 'none' ) ne 'none' )
; # temporär ab Version 0.2.2
addToAttrList('ASC:0,1,2'); addToAttrList('ASC:0,1,2');
@ -821,7 +823,7 @@ sub EventProcessingWindowRec($@) {
ShuttersCommandSet( $hash, $shuttersDev, $shutters->getDelayCmd ); ShuttersCommandSet( $hash, $shuttersDev, $shutters->getDelayCmd );
} }
elsif ( $1 eq 'closed' elsif ( $1 eq 'closed'
and IsAfterShuttersTimeBlocking($hash,$shuttersDev) and IsAfterShuttersTimeBlocking( $hash, $shuttersDev )
) # wenn nicht dann wird entsprechend dem Fensterkontakt Event der Rolladen geschlossen ) # wenn nicht dann wird entsprechend dem Fensterkontakt Event der Rolladen geschlossen
{ {
if ( $shutters->getStatus == $shutters->getVentilatePos if ( $shutters->getStatus == $shutters->getVentilatePos
@ -914,7 +916,7 @@ sub EventProcessingRoommate($@) {
or $shutters->getRoommatesLastStatus eq 'awoken' or $shutters->getRoommatesLastStatus eq 'awoken'
) )
and IsDay( $hash, $shuttersDev ) and IsDay( $hash, $shuttersDev )
and IsAfterShuttersTimeBlocking($hash,$shuttersDev) and IsAfterShuttersTimeBlocking( $hash, $shuttersDev )
) )
{ {
Log3( $name, 4, Log3( $name, 4,
@ -938,8 +940,8 @@ sub EventProcessingRoommate($@) {
and $shutters->getRoommatesStatus eq 'home' and $shutters->getRoommatesStatus eq 'home'
) )
{ {
if ( not IsDay( $hash, $shuttersDev ) if ( not IsDay( $hash, $shuttersDev )
and IsAfterShuttersTimeBlocking($hash,$shuttersDev) ) and IsAfterShuttersTimeBlocking( $hash, $shuttersDev ) )
{ {
my $position; my $position;
$shutters->setLastDrive('roommate home'); $shutters->setLastDrive('roommate home');
@ -959,7 +961,7 @@ sub EventProcessingRoommate($@) {
} }
elsif ( IsDay( $hash, $shuttersDev ) elsif ( IsDay( $hash, $shuttersDev )
and $shutters->getStatus == $shutters->getClosedPos and $shutters->getStatus == $shutters->getClosedPos
and IsAfterShuttersTimeBlocking($hash,$shuttersDev) ) and IsAfterShuttersTimeBlocking( $hash, $shuttersDev ) )
{ {
$shutters->setLastDrive('roommate home'); $shutters->setLastDrive('roommate home');
ShuttersCommandSet( $hash, $shuttersDev, ShuttersCommandSet( $hash, $shuttersDev,
@ -1022,7 +1024,7 @@ sub EventProcessingResidents($@) {
or $shutters->getModeDown eq 'always' or $shutters->getModeDown eq 'always'
) )
and not IsDay( $hash, $shuttersDev ) and not IsDay( $hash, $shuttersDev )
and IsAfterShuttersTimeBlocking($hash,$shuttersDev) and IsAfterShuttersTimeBlocking( $hash, $shuttersDev )
) )
) )
{ {
@ -1069,7 +1071,7 @@ sub EventProcessingResidents($@) {
or $shutters->getModeDown eq 'always' ) or $shutters->getModeDown eq 'always' )
and ( $ascDev->getResidentsLastStatus ne 'asleep' and ( $ascDev->getResidentsLastStatus ne 'asleep'
or $ascDev->getResidentsLastStatus ne 'awoken' ) or $ascDev->getResidentsLastStatus ne 'awoken' )
and IsAfterShuttersTimeBlocking($hash,$shuttersDev) and IsAfterShuttersTimeBlocking( $hash, $shuttersDev )
) )
{ {
$shutters->setLastDrive('residents home'); $shutters->setLastDrive('residents home');
@ -1097,7 +1099,7 @@ sub EventProcessingResidents($@) {
and $shutters->getRoommatesStatus eq 'none' and $shutters->getRoommatesStatus eq 'none'
and ( $shutters->getModeUp eq 'home' and ( $shutters->getModeUp eq 'home'
or $shutters->getModeUp eq 'always' ) or $shutters->getModeUp eq 'always' )
and IsAfterShuttersTimeBlocking($hash,$shuttersDev) and IsAfterShuttersTimeBlocking( $hash, $shuttersDev )
) )
{ {
if ( $ascDev->getResidentsLastStatus eq 'asleep' if ( $ascDev->getResidentsLastStatus eq 'asleep'
@ -1277,22 +1279,26 @@ sub EventProcessingShadingBrightness($@) {
$shutters->getDirection, $shutters->getShadingAngleLeft, $shutters->getDirection, $shutters->getShadingAngleLeft,
$shutters->getShadingAngleRight $shutters->getShadingAngleRight
) )
if ( ( $shutters->getShadingMode eq 'on' if (
or $shutters->getShadingMode eq $homemode) (
and IsDay( $hash, $shuttersDev ) ); $shutters->getShadingMode eq 'on'
or $shutters->getShadingMode eq $homemode
)
and IsDay( $hash, $shuttersDev )
);
} }
} }
sub EventProcessingTwilightDevice($@) { sub EventProcessingTwilightDevice($@) {
my ( $hash, $device, $events ) = @_; my ( $hash, $device, $events ) = @_;
# Twilight # Twilight
# azimuth = azimuth = Sonnenwinkel # azimuth = azimuth = Sonnenwinkel
# elevation = elevation = Sonnenhöhe # elevation = elevation = Sonnenhöhe
# #
# Astro # Astro
# SunAz = azimuth = Sonnenwinkel # SunAz = azimuth = Sonnenwinkel
# SunAlt = evaluation = Sonnenhöhe # SunAlt = evaluation = Sonnenhöhe
if ( $events =~ m#(azimuth|evaluation|SunAz|SunAlt):\s(\d+.\d+)# ) { if ( $events =~ m#(azimuth|evaluation|SunAz|SunAlt):\s(\d+.\d+)# ) {
my $name = $device; my $name = $device;
@ -1339,44 +1345,51 @@ sub ShadingProcessing($@) {
### anglePlus ist $shutters->getShadingAngleRight ### anglePlus ist $shutters->getShadingAngleRight
### winPos ist die Fensterposition $shutters->getDirection ### winPos ist die Fensterposition $shutters->getDirection
my ( my (
$hash, $shuttersDev, $hash, $shuttersDev, $azimuth, $elevation, $brightness,
$azimuth, $elevation, $outTemp, $winPos, $angleMinus, $anglePlus
$brightness, $outTemp,
$winPos, $angleMinus,
$anglePlus
) = @_; ) = @_;
my $name = $hash->{NAME}; my $name = $hash->{NAME};
$shutters->setShuttersDev($shuttersDev); $shutters->setShuttersDev($shuttersDev);
$shutters->setShading('out') $shutters->setShading('out')
if ( not IsDay($hash,$shuttersDev) if ( not IsDay( $hash, $shuttersDev )
and $shutters->getShading ne 'out' ); and $shutters->getShading ne 'out' );
Log3( $name, 1, Log3( $name, 1,
"AutoShuttersControl ($name) - Shading Processing, Rollladen: " . $shuttersDev . " Azimuth: " . $azimuth . " Elevation: " . $elevation . " Brightness: " . $brightness . " OutTemp: " . $outTemp "AutoShuttersControl ($name) - Shading Processing, Rollladen: "
); . $shuttersDev
. " Azimuth: "
. $azimuth
. " Elevation: "
. $elevation
. " Brightness: "
. $brightness
. " OutTemp: "
. $outTemp );
return return
if ( $azimuth == -1 if ( $azimuth == -1
or $elevation == -1 or $elevation == -1
or $brightness == -1 or $brightness == -1
or $outTemp == -100 or $outTemp == -100
or $outTemp < $shutters->getShadingMinOutsideTemperature or $outTemp < $shutters->getShadingMinOutsideTemperature
or not IsDay($hash,$shuttersDev) or not IsDay( $hash, $shuttersDev )
or (int(gettimeofday()) - $shutters->getShadingTimestamp) < ($shutters->getShadingWaitingPeriod / 2) or ( int( gettimeofday() ) - $shutters->getShadingTimestamp ) <
or not IsAfterShuttersTimeBlocking($hash,$shuttersDev) ( $shutters->getShadingWaitingPeriod / 2 )
); or not IsAfterShuttersTimeBlocking( $hash, $shuttersDev ) );
Log3( $name, 1, Log3( $name, 1,
"AutoShuttersControl ($name) - Shading Processing, Rollladen: " . $shuttersDev . " Nach dem return"); "AutoShuttersControl ($name) - Shading Processing, Rollladen: "
. $shuttersDev
. " Nach dem return" );
# minimalen und maximalen Winkel des Fensters bestimmen. wenn die aktuelle Sonnenposition z.B. bei 205° läge und der Wert für angleMin/Max 85° wäre, dann würden zwischen 120° und 290° beschattet. # minimalen und maximalen Winkel des Fensters bestimmen. wenn die aktuelle Sonnenposition z.B. bei 205° läge und der Wert für angleMin/Max 85° wäre, dann würden zwischen 120° und 290° beschattet.
my $winPosMin = $winPos - $angleMinus; my $winPosMin = $winPos - $angleMinus;
my $winPosMax = $winPos + $anglePlus; my $winPosMax = $winPos + $anglePlus;
if ( $azimuth < $winPosMin if ( $azimuth < $winPosMin
or $azimuth > $winPosMax or $azimuth > $winPosMax
or $elevation < $shutters->getShadingMinElevation or $elevation < $shutters->getShadingMinElevation
or $brightness <= $shutters->getShadingStateChangeCloudy ) or $brightness <= $shutters->getShadingStateChangeCloudy )
{ {
$shutters->setShading('out reserved') $shutters->setShading('out reserved')
if ( $shutters->getShading eq 'in' if ( $shutters->getShading eq 'in'
@ -1384,35 +1397,48 @@ sub ShadingProcessing($@) {
$shutters->setShading('out') $shutters->setShading('out')
if ( $shutters->getShading eq 'out reserved' if ( $shutters->getShading eq 'out reserved'
and (int(gettimeofday()) - $shutters->getShadingTimestamp) >= $shutters->getShadingWaitingPeriod ); and ( int( gettimeofday() ) - $shutters->getShadingTimestamp ) >=
$shutters->getShadingWaitingPeriod );
Log3( $name, 1, Log3( $name, 1,
"AutoShuttersControl ($name) - Shading Processing, Rollladen: " . $shuttersDev . " In der Out Abfrage, Shadingwert: " . $shutters->getShading . ", Zeitstempel: " . $shutters->getShadingTimestamp); "AutoShuttersControl ($name) - Shading Processing, Rollladen: "
. $shuttersDev
. " In der Out Abfrage, Shadingwert: "
. $shutters->getShading
. ", Zeitstempel: "
. $shutters->getShadingTimestamp );
} }
elsif ( $azimuth >= $winPosMin elsif ( $azimuth >= $winPosMin
and $azimuth <= $winPosMax and $azimuth <= $winPosMax
and $elevation >= $shutters->getShadingMinElevation and $elevation >= $shutters->getShadingMinElevation
and $brightness >= $shutters->getShadingStateChangeSunny ) and $brightness >= $shutters->getShadingStateChangeSunny )
{ {
$shutters->setShading('in reserved') $shutters->setShading('in reserved')
if ( $shutters->getShading eq 'out' if ( $shutters->getShading eq 'out'
or $shutters->getShading eq 'out reserved'); or $shutters->getShading eq 'out reserved' );
$shutters->setShading('in') $shutters->setShading('in')
if ( $shutters->getShading eq 'in reserved' if ( $shutters->getShading eq 'in reserved'
and (int(gettimeofday()) - $shutters->getShadingTimestamp) >= ($shutters->getShadingWaitingPeriod / 2) ); and ( int( gettimeofday() ) - $shutters->getShadingTimestamp ) >=
( $shutters->getShadingWaitingPeriod / 2 ) );
Log3( $name, 1, Log3( $name, 1,
"AutoShuttersControl ($name) - Shading Processing, Rollladen: " . $shuttersDev . " In der In Abfrage, Shadingwert: " . $shutters->getShading . ", Zeitstempel: " . $shutters->getShadingTimestamp); "AutoShuttersControl ($name) - Shading Processing, Rollladen: "
. $shuttersDev
. " In der In Abfrage, Shadingwert: "
. $shutters->getShading
. ", Zeitstempel: "
. $shutters->getShadingTimestamp );
} }
if ( $shutters->getShading eq 'out' or $shutters->getShading eq 'in' ) { if ( $shutters->getShading eq 'out' or $shutters->getShading eq 'in' ) {
$shutters->setShading($shutters->getShading) $shutters->setShading( $shutters->getShading )
if ( (int(gettimeofday()) - $shutters->getShadingTimestamp) >= ($shutters->getShadingWaitingPeriod / 2) ); if ( ( int( gettimeofday() ) - $shutters->getShadingTimestamp ) >=
( $shutters->getShadingWaitingPeriod / 2 ) );
if ( $shutters->getShading eq 'in' if ( $shutters->getShading eq 'in'
and $shutters->getShadingPos != $shutters->getStatus ) and $shutters->getShadingPos != $shutters->getStatus )
{ {
my $queryShuttersShadingPos = ( my $queryShuttersShadingPos = (
$shutters->getShuttersPosCmdValueNegate $shutters->getShuttersPosCmdValueNegate
? $shutters->getStatus > $shutters->getShadingPos ? $shutters->getStatus > $shutters->getShadingPos
: $shutters->getStatus < $shutters->getShadingPos : $shutters->getStatus < $shutters->getShadingPos
); );
@ -1421,17 +1447,19 @@ sub ShadingProcessing($@) {
ShuttersCommandSet( $hash, $shuttersDev, $shutters->getShadingPos ) ShuttersCommandSet( $hash, $shuttersDev, $shutters->getShadingPos )
if ( not $queryShuttersShadingPos ); if ( not $queryShuttersShadingPos );
} }
elsif( $shutters->getShading eq 'out' elsif ( $shutters->getShading eq 'out'
and $shutters->getShadingPos == $shutters->getStatus ) and $shutters->getShadingPos == $shutters->getStatus )
{ {
$shutters->setLastDrive('shading out'); $shutters->setLastDrive('shading out');
ShuttersCommandSet( $hash, $shuttersDev, $shutters->getLastPos ); ShuttersCommandSet( $hash, $shuttersDev, $shutters->getLastPos );
Log3( $name, 1, Log3( $name, 1,
"AutoShuttersControl ($name) - Shading Processing - shading out läuft" ); "AutoShuttersControl ($name) - Shading Processing - shading out läuft"
);
} }
Log3( $name, 1, Log3( $name, 1,
"AutoShuttersControl ($name) - Shading Processing - In der Routine zum fahren der Rollläden, Shading Wert: " . $shutters->getShading ); "AutoShuttersControl ($name) - Shading Processing - In der Routine zum fahren der Rollläden, Shading Wert: "
. $shutters->getShading );
} }
} }
@ -1502,20 +1530,23 @@ sub ShuttersCommandSet($$$) {
: $shutters->getStatus < $posValue : $shutters->getStatus < $posValue
); );
if ( ($posValue != $shutters->getShadingPos if (
and ( $shutters->getPartyMode eq 'on' and $ascDev->getPartyMode eq 'on' ) (
or ( CheckIfShuttersWindowRecOpen($shuttersDev) == 2 $posValue != $shutters->getShadingPos
and $shutters->getSubTyp eq 'threestate' and ( $shutters->getPartyMode eq 'on'
and $ascDev->getAutoShuttersControlComfort eq 'off' and $ascDev->getPartyMode eq 'on' )
and $shutters->getVentilateOpen eq 'on' ) or ( CheckIfShuttersWindowRecOpen($shuttersDev) == 2
or ( and $shutters->getSubTyp eq 'threestate'
CheckIfShuttersWindowRecOpen($shuttersDev) == 2 and $ascDev->getAutoShuttersControlComfort eq 'off'
and ( $shutters->getLockOut eq 'soft' and $shutters->getVentilateOpen eq 'on' )
or $shutters->getLockOut eq 'hard' ) or (
and $ascDev->getHardLockOut eq 'on' CheckIfShuttersWindowRecOpen($shuttersDev) == 2
and not $queryShuttersPosValue and ( $shutters->getLockOut eq 'soft'
) or $shutters->getLockOut eq 'hard' )
) and $ascDev->getHardLockOut eq 'on'
and not $queryShuttersPosValue
)
)
) )
{ {
$shutters->setDelayCmd($posValue); $shutters->setDelayCmd($posValue);
@ -1771,11 +1802,9 @@ sub CreateNewNotifyDev($) {
AddNotifyDev( $hash, AttrVal( $_, 'ASC_WindowRec', 'none' ), AddNotifyDev( $hash, AttrVal( $_, 'ASC_WindowRec', 'none' ),
$_, 'ASC_WindowRec' ) $_, 'ASC_WindowRec' )
if ( AttrVal( $_, 'ASC_WindowRec', 'none' ) ne 'none' ); if ( AttrVal( $_, 'ASC_WindowRec', 'none' ) ne 'none' );
AddNotifyDev( $hash, AddNotifyDev( $hash, AttrVal( $_, 'ASC_Brightness_Sensor', 'none' ),
AttrVal( $_, 'ASC_Brightness_Sensor', 'none' ),
$_, 'ASC_Brightness_Sensor' ) $_, 'ASC_Brightness_Sensor' )
if ( if ( AttrVal( $_, 'ASC_Brightness_Sensor', 'none' ) ne 'none' );
AttrVal( $_, 'ASC_Brightness_Sensor', 'none' ) ne 'none' );
$shuttersList = $shuttersList . ',' . $_; $shuttersList = $shuttersList . ',' . $_;
} }
AddNotifyDev( $hash, AttrVal( $name, 'ASC_residentsDevice', 'none' ), AddNotifyDev( $hash, AttrVal( $name, 'ASC_residentsDevice', 'none' ),
@ -2190,17 +2219,22 @@ sub ShuttersSunrise($$$) {
} }
sub IsAfterShuttersTimeBlocking($$) { sub IsAfterShuttersTimeBlocking($$) {
my ($hash, $shuttersDev) = @_; my ( $hash, $shuttersDev ) = @_;
$shutters->setShuttersDev($shuttersDev); $shutters->setShuttersDev($shuttersDev);
if ( if (
( int(gettimeofday()) - $shutters->getLastManPosTimestamp) < $shutters->getBlockingTimeAfterManual ( int( gettimeofday() ) - $shutters->getLastManPosTimestamp ) <
or ( not IsDay($hash,$shuttersDev) $shutters->getBlockingTimeAfterManual
and $shutters->getSunriseUnixTime - (int(gettimeofday())) < $shutters->getBlockingTimeBeforDayOpen) or ( not IsDay( $hash, $shuttersDev )
or ( IsDay($hash,$shuttersDev) and $shutters->getSunriseUnixTime - ( int( gettimeofday() ) ) <
and $shutters->getSunsetUnixTime - (int(gettimeofday())) < $shutters->getBlockingTimeBeforNightClose) $shutters->getBlockingTimeBeforDayOpen )
or ( IsDay( $hash, $shuttersDev )
and $shutters->getSunsetUnixTime - ( int( gettimeofday() ) ) <
$shutters->getBlockingTimeBeforNightClose )
) )
{ return 0 } {
return 0;
}
else { return 1 } else { return 1 }
} }
@ -2565,11 +2599,12 @@ sub setLastManPos {
$self->{ $self->{shuttersDev} }{lastManPos}{VAL} = $position $self->{ $self->{shuttersDev} }{lastManPos}{VAL} = $position
if ( defined($position) ); if ( defined($position) );
$self->{ $self->{shuttersDev} }{lastManPos}{TIME} = int( gettimeofday() ) $self->{ $self->{shuttersDev} }{lastManPos}{TIME} = int( gettimeofday() )
if ( defined( $self->{ $self->{shuttersDev} }{lastManPos} )
and defined($self->{ $self->{shuttersDev} }{lastManPos}{TIME}) );
$self->{ $self->{shuttersDev} }{lastManPos}{TIME} = int( gettimeofday() ) - 86400
if ( defined( $self->{ $self->{shuttersDev} }{lastManPos} ) if ( defined( $self->{ $self->{shuttersDev} }{lastManPos} )
and not defined($self->{ $self->{shuttersDev} }{lastManPos}{TIME}) ); and defined( $self->{ $self->{shuttersDev} }{lastManPos}{TIME} ) );
$self->{ $self->{shuttersDev} }{lastManPos}{TIME} =
int( gettimeofday() ) - 86400
if ( defined( $self->{ $self->{shuttersDev} }{lastManPos} )
and not defined( $self->{ $self->{shuttersDev} }{lastManPos}{TIME} ) );
return 0; return 0;
} }
@ -2767,8 +2802,7 @@ sub setShading {
return 0; return 0;
} }
sub getShading sub getShading { # Werte für value = in, out, in reserved, out reserved
{ # Werte für value = in, out, in reserved, out reserved
my $self = shift; my $self = shift;
return $self->{ $self->{shuttersDev} }{Shading}{VAL} return $self->{ $self->{shuttersDev} }{Shading}{VAL}
@ -2855,8 +2889,7 @@ sub _getBrightnessSensor {
my $default = $self->{defaultarg}; my $default = $self->{defaultarg};
$default = 'none' if ( not defined($default) ); $default = 'none' if ( not defined($default) );
return AttrVal( $self->{shuttersDev}, 'ASC_Brightness_Sensor', return AttrVal( $self->{shuttersDev}, 'ASC_Brightness_Sensor', $default );
$default );
} }
sub getBrightnessReading { sub getBrightnessReading {
@ -2864,8 +2897,7 @@ sub getBrightnessReading {
my $default = $self->{defaultarg}; my $default = $self->{defaultarg};
$default = 'brightness' if ( not defined($default) ); $default = 'brightness' if ( not defined($default) );
return AttrVal( $self->{shuttersDev}, 'ASC_Brightness_Reading', return AttrVal( $self->{shuttersDev}, 'ASC_Brightness_Reading', $default );
$default );
} }
sub getDirection { sub getDirection {
@ -2889,7 +2921,8 @@ sub getShadingAngleRight {
sub getShadingMinOutsideTemperature { sub getShadingMinOutsideTemperature {
my $self = shift; my $self = shift;
return AttrVal( $self->{shuttersDev}, 'ASC_Shading_Min_OutsideTemperature', 2 ); return AttrVal( $self->{shuttersDev}, 'ASC_Shading_Min_OutsideTemperature',
2 );
} }
sub getShadingMinElevation { sub getShadingMinElevation {
@ -2901,13 +2934,15 @@ sub getShadingMinElevation {
sub getShadingStateChangeSunny { sub getShadingStateChangeSunny {
my $self = shift; my $self = shift;
return AttrVal( $self->{shuttersDev}, 'ASC_Shading_StateChange_Sunny', 5000 ); return AttrVal( $self->{shuttersDev}, 'ASC_Shading_StateChange_Sunny',
5000 );
} }
sub getShadingStateChangeCloudy { sub getShadingStateChangeCloudy {
my $self = shift; my $self = shift;
return AttrVal( $self->{shuttersDev}, 'ASC_Shading_StateChange_Cloudy', 2000 ); return AttrVal( $self->{shuttersDev}, 'ASC_Shading_StateChange_Cloudy',
2000 );
} }
sub getShadingWaitingPeriod { sub getShadingWaitingPeriod {
@ -2926,19 +2961,22 @@ sub getOffset {
sub getBlockingTimeAfterManual { sub getBlockingTimeAfterManual {
my $self = shift; my $self = shift;
return AttrVal( $self->{shuttersDev}, 'ASC_BlockingTime_afterManual', 1200 ); return AttrVal( $self->{shuttersDev}, 'ASC_BlockingTime_afterManual',
1200 );
} }
sub getBlockingTimeBeforNightClose { sub getBlockingTimeBeforNightClose {
my $self = shift; my $self = shift;
return AttrVal( $self->{shuttersDev}, 'ASC_BlockingTime_beforNightClose', 3600 ); return AttrVal( $self->{shuttersDev}, 'ASC_BlockingTime_beforNightClose',
3600 );
} }
sub getBlockingTimeBeforDayOpen { sub getBlockingTimeBeforDayOpen {
my $self = shift; my $self = shift;
return AttrVal( $self->{shuttersDev}, 'ASC_BlockingTime_beforDayOpen', 3600 ); return AttrVal( $self->{shuttersDev}, 'ASC_BlockingTime_beforDayOpen',
3600 );
} }
sub getPosCmd { sub getPosCmd {