From e85d8368c13b1fb4863c90568b753aa0e0725a01 Mon Sep 17 00:00:00 2001
From: LeonGaultier
Date: Sat, 8 Jun 2019 12:52:17 +0000
Subject: [PATCH] 73_AutoShuttersControl: fix litte bugs and change manual
drive detection
git-svn-id: https://svn.fhem.de/fhem/trunk@19579 2b470e98-0d58-463d-a4d8-8e2adae1ed80
---
fhem/CHANGED | 2 +
fhem/FHEM/73_AutoShuttersControl.pm | 465 ++++++++++++++++------------
2 files changed, 270 insertions(+), 197 deletions(-)
diff --git a/fhem/CHANGED b/fhem/CHANGED
index 1e83543a7..4058d1d79 100644
--- a/fhem/CHANGED
+++ b/fhem/CHANGED
@@ -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.
+ - bugfix: 73_AutoShuttersControl: fix litte bugs and change manual drive
+ detection
- feature: 49_SSCam: In detailview are buttons provided to open the camera
native setup screen or Synology Surveillance Station and
the Synology Surveillance Station online help
diff --git a/fhem/FHEM/73_AutoShuttersControl.pm b/fhem/FHEM/73_AutoShuttersControl.pm
index 845ad345f..70779ee3c 100644
--- a/fhem/FHEM/73_AutoShuttersControl.pm
+++ b/fhem/FHEM/73_AutoShuttersControl.pm
@@ -48,22 +48,22 @@ use strict;
use warnings;
use FHEM::Meta;
-my $version = '0.6.15';
+my $version = '0.6.16';
sub AutoShuttersControl_Initialize($) {
my ($hash) = @_;
-# ### alte Attribute welche entfernt werden
-# my $oldAttr =
-# 'ASC_temperatureSensor '
-# . 'ASC_temperatureReading '
-# . 'ASC_residentsDevice '
-# . 'ASC_residentsDeviceReading '
-# . 'ASC_rainSensorDevice '
-# . 'ASC_rainSensorReading '
-# . 'ASC_rainSensorShuttersClosedPos:0,10,20,30,40,50,60,70,80,90,100 '
-# . 'ASC_brightnessMinVal '
-# . 'ASC_brightnessMaxVal ';
+ # ### alte Attribute welche entfernt werden
+ # my $oldAttr =
+ # 'ASC_temperatureSensor '
+ # . 'ASC_temperatureReading '
+ # . 'ASC_residentsDevice '
+ # . 'ASC_residentsDeviceReading '
+ # . 'ASC_rainSensorDevice '
+ # . 'ASC_rainSensorReading '
+ # . 'ASC_rainSensorShuttersClosedPos:0,10,20,30,40,50,60,70,80,90,100 '
+ # . 'ASC_brightnessMinVal '
+ # . 'ASC_brightnessMaxVal ';
## 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
@@ -92,7 +92,8 @@ sub AutoShuttersControl_Initialize($) {
. 'ASC_expert:1 '
. 'ASC_blockAscDrivesAfterManual:0,1 '
. 'ASC_debug:1 '
-# . $oldAttr
+
+ # . $oldAttr
. $readingFnAttributes;
$hash->{NotifyOrderPrefix} = '51-'; # Order Nummer für NotifyFn
@@ -675,7 +676,7 @@ sub ShuttersDeviceScan($) {
# . AttrVal( $name, 'ASC_brightnessMinVal', 500 ) . ':'
# . AttrVal( $name, 'ASC_brightnessMaxVal', 800 ) )
# if ( AttrVal( $name, 'ASC_brightnessMinVal', 'none' ) ne 'none' );
-#
+#
# CommandDeleteAttr( undef, $name . ' ASC_temperatureSensor' )
# if ( AttrVal( $name, 'ASC_temperatureSensor', 'none' ) ne 'none' );
# CommandDeleteAttr( undef, $name . ' ASC_temperatureReading' )
@@ -916,25 +917,26 @@ sub EventProcessingWindowRec($@) {
if ( $match =~ /open/
and $shutters->getShuttersPlace eq 'terrace' );
- my $queryShuttersPosWinRecTilted = (
- $shutters->getShuttersPosCmdValueNegate
- ? $shutters->getStatus > $shutters->getVentilatePos
- : $shutters->getStatus < $shutters->getVentilatePos
- );
- my $queryShuttersPosWinRecComfort = (
- $shutters->getShuttersPosCmdValueNegate
- ? $shutters->getStatus > $shutters->getComfortOpenPos
- : $shutters->getStatus < $shutters->getComfortOpenPos
- );
+ # my $queryShuttersPosWinRecTilted = (
+ # $shutters->getShuttersPosCmdValueNegate
+ # ? $shutters->getStatus > $shutters->getVentilatePos
+ # : $shutters->getStatus < $shutters->getVentilatePos
+ # );
+ # my $queryShuttersPosWinRecComfort = (
+ # $shutters->getShuttersPosCmdValueNegate
+ # ? $shutters->getStatus > $shutters->getComfortOpenPos
+ # : $shutters->getStatus < $shutters->getComfortOpenPos
+ # );
ASC_Debug( 'EventProcessingWindowRec: '
. $shutters->getShuttersDev
. ' - HOMEMODE: '
. $homemode
. ' QueryShuttersPosWinRecTilted:'
- . $queryShuttersPosWinRecTilted
+ . $shutters->getQueryShuttersPos( $shutters->getVentilatePos )
. ' QueryShuttersPosWinRecComfort: '
- . $queryShuttersPosWinRecComfort );
+ . $shutters->getQueryShuttersPos( $shutters->getComfortOpenPos )
+ );
if (
$match =~ /close/
@@ -993,7 +995,7 @@ sub EventProcessingWindowRec($@) {
and $shutters->getSubTyp eq 'twostate' )
)
and $shutters->getVentilateOpen eq 'on'
- and $queryShuttersPosWinRecTilted
+ and $shutters->getQueryShuttersPos( $shutters->getVentilatePos )
)
{
$shutters->setLastDrive('ventilate - window open');
@@ -1006,12 +1008,13 @@ sub EventProcessingWindowRec($@) {
my $posValue;
my $setLastDrive;
if ( $ascDev->getAutoShuttersControlComfort eq 'on'
- and $queryShuttersPosWinRecComfort )
+ and
+ $shutters->getQueryShuttersPos( $shutters->getComfortOpenPos ) )
{
$posValue = $shutters->getComfortOpenPos;
$setLastDrive = 'comfort - window open';
}
- elsif ( $queryShuttersPosWinRecTilted
+ elsif ( $shutters->getQueryShuttersPos( $shutters->getVentilatePos )
and $shutters->getVentilateOpen eq 'on' )
{
$posValue = $shutters->getVentilatePos;
@@ -2197,11 +2200,11 @@ sub ShuttersCommandSet($$$) {
my $name = $hash->{NAME};
$shutters->setShuttersDev($shuttersDev);
- my $queryShuttersPosValue = (
- $shutters->getShuttersPosCmdValueNegate
- ? $shutters->getStatus > $posValue
- : $shutters->getStatus < $posValue
- );
+ # my $queryShuttersPosValue = (
+ # $shutters->getShuttersPosCmdValueNegate
+ # ? $shutters->getStatus > $posValue
+ # : $shutters->getStatus < $posValue
+ # );
if (
$posValue != $shutters->getShadingPos
@@ -2226,11 +2229,11 @@ sub ShuttersCommandSet($$$) {
and ( $shutters->getLockOut eq 'soft'
or $shutters->getLockOut eq 'hard' )
and $ascDev->getHardLockOut eq 'on'
- and not $queryShuttersPosValue
+ and not $shutters->getQueryShuttersPos($posValue)
)
or ( CheckIfShuttersWindowRecOpen($shuttersDev) == 2
and $shutters->getShuttersPlace eq 'terrace'
- and not $queryShuttersPosValue )
+ and not $shutters->getQueryShuttersPos($posValue) )
)
)
{
@@ -2382,7 +2385,7 @@ sub RenewSunRiseSetShuttersTimer($) {
# . AttrVal( $_, 'ASC_BrightnessMinVal', 500 ) . ':'
# . AttrVal( $_, 'ASC_BrightnessMaxVal', 700 )
# if ( AttrVal( $_, 'ASC_Brightness_Sensor', 'none' ) ne 'none' );
-#
+#
# delFromDevAttrList( $_, 'ASC_Brightness_Sensor' )
# ; # temporär muss später gelöscht werden ab Version 0.4.11beta9
# delFromDevAttrList( $_, 'ASC_Brightness_Reading' )
@@ -2462,11 +2465,15 @@ sub SunSetShuttersAfterTimerFn($) {
$shutters->setSunrise(0);
my $posValue;
+
if ( CheckIfShuttersWindowRecOpen($shuttersDev) == 0
or $shutters->getVentilateOpen eq 'off' )
{
$posValue = $shutters->getClosedPos;
}
+ elsif ( $shutters->getQueryShuttersPos( $shutters->getVentilatePos ) ) {
+ $posValue = $shutters->getStatus;
+ }
else { $posValue = $shutters->getVentilatePos; }
my $homemode = $shutters->getRoommatesStatus;
@@ -2482,14 +2489,15 @@ sub SunSetShuttersAfterTimerFn($) {
and IsAfterShuttersManualBlocking($shuttersDev)
)
{
- my $queryShuttersPosPrivacyDown = (
- $shutters->getShuttersPosCmdValueNegate
- ? $shutters->getStatus > $shutters->getPrivacyDownPos
- : $shutters->getStatus < $shutters->getPrivacyDownPos
- );
+ # my $queryShuttersPosPrivacyDown = (
+ # $shutters->getShuttersPosCmdValueNegate
+ # ? $shutters->getStatus > $shutters->getPrivacyDownPos
+ # : $shutters->getStatus < $shutters->getPrivacyDownPos
+ # );
if ( $funcHash->{privacyMode} == 1
- and not $queryShuttersPosPrivacyDown )
+ and
+ not $shutters->getQueryShuttersPos( $shutters->getPrivacyDownPos ) )
{
$shutters->setLastDrive('privacy position');
ShuttersCommandSet( $hash, $shuttersDev,
@@ -3705,6 +3713,12 @@ sub setInTimerFuncHash {
return 0;
}
+sub getIsDay {
+ my $self = shift;
+
+ return FHEM::AutoShuttersControl::IsDay( $self->{shuttersDev} );
+}
+
sub getFreezeStatus {
use POSIX qw(strftime);
my $self = shift;
@@ -3733,6 +3747,18 @@ sub getShuttersPosCmdValueNegate {
return ( $shutters->getOpenPos < $shutters->getClosedPos ? 1 : 0 );
}
+sub getQueryShuttersPos
+{ # Es wird geschaut ob die aktuelle Position des Rollos unterhalb der Zielposition ist
+ my ( $self, $posValue ) =
+ @_; # wenn dem so ist wird 1 zurück gegeben ansonsten 0
+
+ return (
+ $shutters->getShuttersPosCmdValueNegate
+ ? $shutters->getStatus > $posValue
+ : $shutters->getStatus < $posValue
+ );
+}
+
sub getPosSetCmd {
my $self = shift;
@@ -5153,29 +5179,35 @@ sub getblockAscDrivesAfterManual {
Define
+
+ This creates an new AutoShuttersControl device, called myASControl.
+ Now was the new global attribute ASC added to the FHEM installation.
+ Each shutter that is to be controlled by AutoShuttersControl must now have the attribute ASC set to 1 or 2.
+ The value 1 is to be used with devices whose state is given as position (i.e. ROLLO or Siro, shutters
+ openend is 0, shutters closed is 100), 2 with devices whose state is given as percent closed (i.e. HomeMatic,
+ shutters opened is 100, closed is 0).
+
+
+ After setting the attributes to all devices who should be controlled, the automatic scan at the main device
+ can be started for example with
+ set myASControl scanForShutters
+
Readings
- Within the ASC device:
+ Within the ASC device:
- ..._nextAstroTimeEvent - Next astro event: sunrise, sunset or fixed time
- ..._PosValue - current position
@@ -5183,25 +5215,25 @@ sub getblockAscDrivesAfterManual {
- ..._lastDelayPosValue - last specified order, will be executed with the next matching
event
- - partyMode - on/off - is working mode set to part?y
- - ascEnable - on/off - are the associated shutters control by ASC completely?
- - controlShading - on/off - are the associated shutters controlled for shading by ASC?
+
- partyMode on|off - is working mode set to part?y
+ - ascEnable on|off - are the associated shutters control by ASC completely?
+ - controlShading on|off - are the associated shutters controlled for shading by ASC?
- - hardLockOut - on/off - switch for preventing a global hard lock out
+ - hardLockOut on|off - switch for preventing a global hard lock out
- room_... - list of every found shutter for every room: room_Sleeping: Patio
- selfDefense - state of the self defense mode
- state - state of the ASC device: active, enabled, disabled or other state information
- - sunriseTimeWeHoliday - on/off - state of the weekend and holiday support
+ - sunriseTimeWeHoliday on|off - state of the weekend and holiday support
- userAttrList - ASC sets some user defined attributes (userattr)
for the shutter devices. This readings shows the current state of the given user attributes to the
shutter devices.
-
- Within the shutter devices:
+
+ Within the shutter devices:
- - ASC_Enable - on/off - shutter is controlled by ASC or not
+ - ASC_Enable on|off - shutter is controlled by ASC or not
- ASC_Time_DriveUp - if the astro mode is used, the next sunrise is shown.
If the brightness or time mode is used, the value from ASC_Time_Up_Late is shown.
@@ -5216,17 +5248,17 @@ sub getblockAscDrivesAfterManual {
Set
- - ascEnable - on/off - enable or disable the global control by ASC
- - controlShading - on/off - enable or disable the global shading control by ASC
+ - ascEnable on|off - enable or disable the global control by ASC
+ - controlShading on|off - enable or disable the global shading control by ASC
- createNewNotifyDev - re-creates the internal structure for NOTIFYDEV. Is only present if
the
ASC_Expert attribute is set to 1.
- - hardLockOut - on/off - controls the global hard lock out protection for shutters, whose
+
- hardLockOut on|off - controls the global hard lock out protection for shutters, whose
ASC_LockOut
attribute is set accordingly. See the attributes section below.
- - partyMode - on/off - controls the global party mode for shutters. Every shutters whose
+
- partyMode on|off - controls the global party mode for shutters. Every shutters whose
ASC_Partymode attribute is set to on, is not longer controlled by ASC. The last saved
working command send to the device, i.e. by a event, created by a window or presence event, will be executed
once the party mode is disabled.
@@ -5237,14 +5269,14 @@ sub getblockAscDrivesAfterManual {
- scanForShutters - scans the whole FHEM installation for (new) devices whose ASC
attribute is set (to 1 or 2, see above).
- - selfDefense - on/off - controls the self defense function. This function listens for
+
- selfDefense on|off - controls the self defense function. This function listens for
example on a residents device. If this device is set to absent and a window is still open, ASC will close
the shutter for a rudimentary burglary protection.
- - shutterASCenableToggle - on/off - controls if the ASC controls are shown at a associated
+
- shutterASCenableToggle on|off - controls if the ASC controls are shown at a associated
shutter device.
- - sunriseTimeWeHoliday - on/off - controls the weekend and holiday support. If enabled, the
+
- sunriseTimeWeHoliday on|off - controls the weekend and holiday support. If enabled, the
ASC_Time_Up_WE_Holiday attribute is considered.
- wiggle - wiggles a device for a given value (default 5%, controlled by
@@ -5267,7 +5299,8 @@ sub getblockAscDrivesAfterManual {
Attributes
- - ASC_rainSensor - DEVICENAME[:READINGNAME] MAXTRIGGER[:HYSTERESE] [CLOSEDPOS] - Contains
+
- ASC_rainSensor DEVICENAME[:READINGNAME] MAXTRIGGER[:HYSTERESE] [CLOSEDPOS] - Contains
settings for the rain protection. DEVICNAME specifies a rain sensor, the optional
READINGNAME the name of the reading at the DEVICENAME. The READINGNAME
should contain the values rain and dry or a numeral rain amount. MAXTRIGGER
@@ -5328,7 +5361,7 @@ sub getblockAscDrivesAfterManual {
the threshold is reached. HYSTERESE sets a hysteresis for MAXTRIGGER.
- - ASC_residentsDev - DEVICENAME[:READINGNAME] - DEVICENAME points to a device
+
- ASC_residentsDev DEVICENAME[:READINGNAME] - DEVICENAME points to a device
for presence, e.g. of type RESIDENTS. READINGNAME points to a reading at
DEVICENAME which contains a presence state, e.g. rgr_Residents:presence. The target
should contain values alike the RESIDENTS family.
@@ -5338,7 +5371,7 @@ sub getblockAscDrivesAfterManual {
the operating time. 0 equals to no delay.
- - ASC_tempSensor - DEVICENAME[:READINGNAME] - DEVICENAME points to a device
+
- ASC_tempSensor DEVICENAME[:READINGNAME] - DEVICENAME points to a device
with a temperature, READINGNAME to a reading located at the DEVICENAME, for example
OUTDOOR_TEMP:measured-temp. READINGNAME defaults to temperature.
@@ -5347,7 +5380,7 @@ sub getblockAscDrivesAfterManual {
the sun position. Supports currently devices of type Twilight or Astro.
- - ASC_windSensor - DEVICENAME[:READINGNAME] - DEVICENAME points to a device
+
- ASC_windSensor DEVICENAME[:READINGNAME] - DEVICENAME points to a device
containing a wind speed. Reads from the wind reading, if not otherwise specified by
READINGNAME.
@@ -5375,8 +5408,8 @@ sub getblockAscDrivesAfterManual {
ASC_brightnessMaxVal - Warning! Deprecated! Don't use anymore!
-
- At shutter devices, controlled by ASC
+
+ At shutter devices, controlled by ASC:
- ASC - 0/1/2
@@ -5424,13 +5457,13 @@ sub getblockAscDrivesAfterManual {
EVENING-VALUE. Gets the brightness from DEVICE, reads by default from the
brightness reading, unless READING is specified. Defaults to none.
- - ASC_Closed_Pos - A value from 0 to 100 in increments of 10. Depends on the ASC
- attribute.
+
- ASC_Closed_Pos - The closed position value from 0 to 100 percent in increments of 10.
+ Depends on the ASC attribute.
- - ASC_ComfortOpen_Pos - A value from 0 to 100 in increments of 10. Default: depends on the
- ASC attribute.
+
- ASC_ComfortOpen_Pos - The comfort opening position, ranging
+ from 0 to 100 percent in increments of 10. Default: depends on the ASC attribute.
- - ASC_Down - [astro|time|brightness] - Drive the shutter depending on this setting:
+
- ASC_Down - astro|time|brightness - Drive the shutter depending on this setting:
AutoShuttersControl API description
- It's possible to access internal data of the ASC module by calling the API function.
+ It's possible to access internal data of the ASC module by calling the API function.
Data points of a shutter device, controlled by ASC
@@ -5975,6 +6045,7 @@ sub getblockAscDrivesAfterManual {
DelayCmd | letzter Fahrbefehl welcher in die Warteschlange kam. Grund z.B. Partymodus. |
Status | Position des Rollladens |
ASCenable | Abfrage ob für den Rollladen die ASC Steuerung aktiv ist. |
+ IsDay | Abfrage ob das Rollo im Tag oder Nachtmodus ist. Also nach Sunset oder nach Sunrise |
Übersicht für das ASC Device