73_AutoShuttersControl: add support blockingAfterManual at brightness, many bugfixes

git-svn-id: https://svn.fhem.de/fhem/trunk/fhem@18116 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
LeonGaultier 2019-01-02 08:42:22 +00:00
parent 83a17bb3d0
commit 50fbf6589e
2 changed files with 76 additions and 83 deletions

View File

@ -1,5 +1,7 @@
# 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.
- feature: 73_AutoShuttersControl: add support blockingAfterManual at
Brightness, Bugfixes
- feature: 49_SSCam: integrated Email shipping of snapshots, save recordings
locally with get saveRecoring command
- new: 98_vitoconnect: initial release

View File

@ -41,7 +41,7 @@ package main;
use strict;
use warnings;
my $version = '0.2.2';
my $version = '0.2.3';
sub AutoShuttersControl_Initialize($) {
my ($hash) = @_;
@ -55,9 +55,7 @@ sub AutoShuttersControl_Initialize($) {
$hash->{UndefFn} = 'AutoShuttersControl::Undef';
$hash->{AttrFn} = 'AutoShuttersControl::Attr';
$hash->{AttrList} =
'disable:0,1 '
. 'disabledForIntervals '
. 'ASC_guestPresence:on,off '
'ASC_guestPresence:on,off '
. 'ASC_temperatureSensor '
. 'ASC_temperatureReading '
. 'ASC_brightnessMinVal '
@ -76,8 +74,6 @@ sub AutoShuttersControl_Initialize($) {
. 'ASC_autoAstroModeEvening:REAL,CIVIL,NAUTIC,ASTRONOMIC,HORIZON '
. 'ASC_autoAstroModeEveningHorizon:-9,-8,-7,-6,-5,-4,-3,-2,-1,0,1,2,3,4,5,6,7,8,9 '
. 'ASC_freezeTemp:-5,-4,-3,-2,-1,0,1,2,3,4,5 '
. 'ASC_timeUpHolidayDevice '
. 'ASC_timeUpHolidayReading '
. 'ASC_shuttersDriveOffset '
. 'ASC_twilightDevice '
. 'ASC_expert:1 '
@ -167,23 +163,24 @@ my %userAttrList = (
'ASC_Ventilate_Window_Open:on,off' => 'on',
'ASC_LockOut:soft,hard,off' => 'off',
'ASC_LockOut_Cmd:inhibit,blocked,protection' => 'none',
'ASC_BlockingTime_afterManual' => 1200,
'ASC_BlockingTime_beforNightClose' => 3600,
'ASC_BlockingTime_beforDayOpen' => 3600,
'ASC_Brightness_Sensor' => 'none',
'ASC_Brightness_Reading' => 'brightness',
'ASC_Shading_Direction' => 180,
'ASC_Shading_Pos:10,20,30,40,50,60,70,80,90,100' => [ '', 80, 20 ],
'ASC_BlockingTime_afterManual' => 1200,
'ASC_BlockingTime_beforNightClose' => 3600,
'ASC_BlockingTime_beforDayOpen' => 3600,
'ASC_Brightness_Sensor' => 'none',
'ASC_Brightness_Reading' => 'brightness',
'ASC_Shading_Direction' => 180,
'ASC_Shading_Pos:10,20,30,40,50,60,70,80,90,100' => [ '', 80, 20 ],
'ASC_Shading_Mode:absent,always,off,home' => 'off',
'ASC_Shading_Angle_Left' => 75,
'ASC_Shading_Angle_Right' => 75,
'ASC_Shading_StateChange_Sunny' => 35000,
'ASC_Shading_StateChange_Cloudy' => 20000,
'ASC_Shading_Min_Elevation' => 25.0,
'ASC_Shading_Min_OutsideTemperature' => 18,
'ASC_Shading_WaitingPeriod' => 1200,
# 'ASC_Shading_Fast_Open:on,off' => 'none',
# 'ASC_Shading_Fast_Close:on,off' => 'none',
'ASC_Shading_Angle_Left' => 75,
'ASC_Shading_Angle_Right' => 75,
'ASC_Shading_StateChange_Sunny' => 35000,
'ASC_Shading_StateChange_Cloudy' => 20000,
'ASC_Shading_Min_Elevation' => 25.0,
'ASC_Shading_Min_OutsideTemperature' => 18,
'ASC_Shading_WaitingPeriod' => 1200,
# 'ASC_Shading_Fast_Open:on,off' => 'none',
# 'ASC_Shading_Fast_Close:on,off' => 'none',
'ASC_Drive_Offset' => -1,
'ASC_WindowRec_subType:twostate,threestate' => 'twostate',
'ASC_ShuttersPlace:window,terrace' => 'window',
@ -269,7 +266,6 @@ sub Define($$) {
. ' devStateIcon selfeDefense.terrace:fts_door_tilt created.new.drive.timer:clock .*asleep:scene_sleeping roommate.(awoken|home):user_available residents.(home|awoken):status_available manual:fts_shutter_manual selfeDefense.active:status_locked selfeDefense.inactive:status_open day.open:scene_day night.close:scene_night shading.in:weather_sun shading.out:weather_cloudy'
) if ( AttrVal( $name, 'devStateIcon', 'none' ) eq 'none' );
addToAttrList('ASC:0,1,2');
Log3( $name, 3, "AutoShuttersControl ($name) - defined" );
@ -298,37 +294,12 @@ sub Attr(@) {
my ( $cmd, $name, $attrName, $attrVal ) = @_;
my $hash = $defs{$name};
if ( $attrName eq 'disable' ) {
if ( $cmd eq 'set' and $attrVal eq '1' ) {
Log3( $name, 3, "AutoShuttersControl ($name) - disabled" );
}
elsif ( $cmd eq 'del' ) {
Log3( $name, 3, "AutoShuttersControl ($name) - enabled" );
}
}
elsif ( $attrName eq 'disabledForIntervals' ) {
if ( $cmd eq 'set' ) {
return
'check disabledForIntervals Syntax HH:MM-HH:MM or \'HH:MM-HH:MM HH:MM-HH:MM ...\''
unless ( $attrVal =~ /^((\d{2}:\d{2})-(\d{2}:\d{2})\s?)+$/ );
Log3( $name, 3,
"AutoShuttersControl ($name) - disabledForIntervals" );
#readingsSingleUpdate ($hash,"state","disabled",1);
}
elsif ( $cmd eq 'del' ) {
Log3( $name, 3, "AutoShuttersControl ($name) - enabled" );
#readingsSingleUpdate ($hash,"state","active",1);
}
}
return undef;
}
sub Notify($$) {
my ( $hash, $dev ) = @_;
my $name = $hash->{NAME};
return if ( IsDisabled($name) );
my $devname = $dev->{NAME};
my $devtype = $dev->{TYPE};
@ -365,10 +336,10 @@ sub Notify($$) {
if ( $ascDev->getSunriseTimeWeHoliday eq 'none' );
readingsSingleUpdate( $hash, 'selfDefense', 'off', 0 )
if ( $ascDev->getSelfDefense eq 'none' );
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
# Ist der Event ein globaler und passt zum Rest der Abfrage oben wird nach neuen Rolläden Devices gescannt und eine Liste im Rolladenmodul sortiert nach Raum generiert
ShuttersDeviceScan($hash)
@ -1172,7 +1143,7 @@ sub EventProcessingBrightness($@) {
else {
$brightnessMinVal = $ascDev->getBrightnessMinVal;
}
my $brightnessMaxVal;
if ( $shutters->getBrightnessMaxVal > -1 ) {
$brightnessMaxVal = $shutters->getBrightnessMaxVal;
@ -1235,6 +1206,7 @@ sub EventProcessingBrightness($@) {
)
and $1 < $brightnessMinVal
and $shutters->getDown eq 'brightness'
and IsAfterShuttersManualBlocking($shuttersDev)
)
{
Log3( $name, 4,
@ -1258,8 +1230,7 @@ sub EventProcessingBrightness($@) {
or $homemode eq 'none'
or $shutters->getModeDown eq 'always' )
{
ShuttersCommandSet( $hash, $shuttersDev,
$posValue );
ShuttersCommandSet( $hash, $shuttersDev, $posValue );
}
else {
EventProcessingShadingBrightness( $hash, $shuttersDev,
@ -1287,10 +1258,14 @@ sub EventProcessingShadingBrightness($@) {
$shutters->getDirection, $shutters->getShadingAngleLeft,
$shutters->getShadingAngleRight
)
if ( ( $shutters->getShadingMode eq 'always'
or $shutters->getShadingMode eq $homemode)
and IsDay( $hash, $shuttersDev ) );
if (
(
$shutters->getShadingMode eq 'always'
or $shutters->getShadingMode eq $homemode
)
and IsDay( $hash, $shuttersDev )
);
}
}
@ -1474,7 +1449,9 @@ sub EventProcessingPartyMode($) {
foreach my $shuttersDev ( @{ $hash->{helper}{shuttersList} } ) {
$shutters->setShuttersDev($shuttersDev);
if ( not IsDay( $hash, $shuttersDev ) ) {
if ( not IsDay( $hash, $shuttersDev )
and $shutters->getModeDown ne 'off' )
{
if ( CheckIfShuttersWindowRecOpen($shuttersDev) == 2
and $shutters->getSubTyp eq 'threestate' )
{
@ -1502,6 +1479,10 @@ sub EventProcessingPartyMode($) {
);
}
}
elsif ( IsDay( $hash, $shuttersDev ) ) {
$shutters->setLastDrive('drive after party mode');
ShuttersCommandSet( $hash, $shuttersDev, $shutters->getDelayCmd );
}
}
}
@ -1536,21 +1517,19 @@ sub ShuttersCommandSet($$$) {
);
if (
(
$posValue != $shutters->getShadingPos
and ( $shutters->getPartyMode eq 'on'
and $ascDev->getPartyMode eq 'on' )
or ( CheckIfShuttersWindowRecOpen($shuttersDev) == 2
and $shutters->getSubTyp eq 'threestate'
and $ascDev->getAutoShuttersControlComfort eq 'off'
and $shutters->getVentilateOpen eq 'on' )
or (
CheckIfShuttersWindowRecOpen($shuttersDev) == 2
and ( $shutters->getLockOut eq 'soft'
or $shutters->getLockOut eq 'hard' )
and $ascDev->getHardLockOut eq 'on'
and not $queryShuttersPosValue
)
$posValue != $shutters->getShadingPos
and ( $shutters->getPartyMode eq 'on'
and $ascDev->getPartyMode eq 'on' )
or ( CheckIfShuttersWindowRecOpen($shuttersDev) == 2
and $shutters->getSubTyp eq 'threestate'
and $ascDev->getAutoShuttersControlComfort eq 'off'
and $shutters->getVentilateOpen eq 'on' )
or (
CheckIfShuttersWindowRecOpen($shuttersDev) == 2
and ( $shutters->getLockOut eq 'soft'
or $shutters->getLockOut eq 'hard' )
and $ascDev->getHardLockOut eq 'on'
and not $queryShuttersPosValue
)
)
{
@ -1741,10 +1720,13 @@ sub SunSetShuttersAfterTimerFn($) {
$homemode = $ascDev->getResidentsStatus if ( $homemode eq 'none' );
if (
$shutters->getModeDown eq $homemode
or ( $shutters->getModeDown eq 'absent'
and $homemode eq 'gone' )
or $shutters->getModeDown eq 'always'
(
$shutters->getModeDown eq $homemode
or ( $shutters->getModeDown eq 'absent'
and $homemode eq 'gone' )
or $shutters->getModeDown eq 'always'
)
and IsAfterShuttersManualBlocking($shuttersDev)
)
{
$shutters->setLastDrive('night close');
@ -2244,6 +2226,19 @@ sub IsAfterShuttersTimeBlocking($$) {
else { return 1 }
}
sub IsAfterShuttersManualBlocking($) {
my $shuttersDev = shift;
$shutters->setShuttersDev($shuttersDev);
if ( ( int( gettimeofday() ) - $shutters->getLastManPosTimestamp ) <
$shutters->getBlockingTimeAfterManual )
{
return 0;
}
else { return 1 }
}
sub ShuttersSunset($$$) {
my ( $hash, $shuttersDev, $tm ) =
@_; # Tm steht für Timemode und bedeutet Realzeit oder Unixzeit
@ -2533,7 +2528,7 @@ sub setDriveCmd {
$offSet = $shutters->getOffset if ( $shutters->getOffset > 0 );
$offSet = $ascDev->getShuttersOffset if ( $shutters->getOffset == -1 );
InternalTimer( gettimeofday() + int( rand($offSet) ),
InternalTimer( gettimeofday() + int( rand($offSet) + 3 ),
'AutoShuttersControl::SetCmdFn', \%h )
if ( $offSet > 0 and not $shutters->getNoOffset );
AutoShuttersControl::SetCmdFn( \%h )
@ -3730,8 +3725,6 @@ sub getRainSensorShuttersClosedPos {
<li>ASC_autoShuttersControlMorning - on/off if the shutters shall be controlled by time in the morning.</li>
<li>ASC_temperatureReading - Reading for outside temperature.</li>
<li>ASC_temperatureSensor - Device for outside temperature.</li>
<li>ASC_timeUpHolidayDevice - Device for holiday detection or similar.</li>
<li>ASC_timeUpHolidayReading - corrsponding reading for ASC_timeUpHolidayDevice to detect holiday or similar / has to content 0 or 1.</li>
<li>ASC_residentsDevice - devicename of the residents device</li>
<li>ASC_residentsDeviceReading - state of the residents device</li>
<li>ASC_brightnessMinVal - minimum brightness value to activate check of conditions</li>
@ -3870,8 +3863,6 @@ sub getRainSensorShuttersClosedPos {
<li>ASC_autoShuttersControlMorning - on/off - ob Morgens die Rolll&auml;den automatisch nach Zeit gesteuert werden sollen</li>
<li>ASC_temperatureReading - Reading f&uuml;r die Aussentemperatur</li>
<li>ASC_temperatureSensor - Device f&uuml;r die Aussentemperatur</li>
<li>ASC_timeUpHolidayDevice - Device zur Urlaubserkennung oder Sonstiges / muss 0 oder 1 im Reading beinhalten.</li>
<li>ASC_timeUpHolidayReading - passendes Reading zum ASC_timeUpHolidayDevice zur Urlaubserkennung oder Sonstiges / muss 0 oder 1 beinhalten.</li>
<li>ASC_residentsDevice - Devicenamen des Residents Device der obersten Ebene</li>
<li>ASC_residentsDeviceReading - Status Reading vom Residents Device der obersten Ebene</li>
<li>ASC_brightnessMinVal - minimaler Lichtwert, bei dem Schaltbedingungen gepr&uuml;ft werden sollen</li>