2018-08-15 10:27:53 +02:00
###############################################################################
2018-10-14 18:19:23 +02:00
#
2018-08-15 10:27:53 +02:00
# Developed with Kate
#
2019-01-27 14:19:51 +01:00
# (c) 2018-2019 Copyright: Marko Oldenburg (leongaultier at gmail dot com)
2018-08-15 10:27:53 +02:00
# All rights reserved
#
# Special thanks goes to:
2018-09-02 23:00:40 +02:00
# - Bernd (Cluni) this module is based on the logic of his script "Rollladensteuerung für HM/ROLLO inkl. Abschattung und Komfortfunktionen in Perl" (https://forum.fhem.de/index.php/topic,73964.0.html)
2019-06-03 07:44:35 +02:00
# - Beta-User for many tests, many suggestions and good discussions
2018-11-11 12:31:20 +01:00
# - pc1246 write english commandref
2019-05-17 22:18:13 +02:00
# - FunkOdyssey commandref style
2018-11-12 12:56:18 +01:00
# - sledge fix many typo in commandref
# - many User that use with modul and report bugs
2019-05-24 11:22:58 +02:00
# - Christoph (christoph.kaiser.in) Patch that expand RegEx for Window Events
2019-05-24 11:31:07 +02:00
# - Julian (Loredo) expand Residents Events for new Residents functions
2019-06-03 07:44:35 +02:00
# - Christoph (Christoph Morrison) for fix Commandref, many suggestions and good discussions
2018-08-15 10:27:53 +02:00
#
#
# This script is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
2018-10-14 18:19:23 +02:00
# the Free Software Foundation; either version 2 of the License,or
2018-08-15 10:27:53 +02:00
# any later version.
#
# The GNU General Public License can be found at
# http://www.gnu.org/copyleft/gpl.html.
# A copy is found in the textfile GPL.txt and important notices to the license
# from the author is found in LICENSE.txt distributed with these scripts.
#
# This script is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
#
# $Id$
#
###############################################################################
2018-09-24 15:29:39 +02:00
### Notizen
2018-09-28 08:57:25 +02:00
# - Feststellen ob ein Rolladen fährt oder nicht
2019-04-08 10:19:09 +02:00
# !!!!! - Innerhalb einer Shutterschleife kein CommandAttr verwenden. Bring Fehler!!! Kommen Raumnamen in die Shutterliste !!!!!!
#
2018-08-15 10:27:53 +02:00
package main ;
use strict ;
use warnings ;
2019-03-27 08:41:15 +01:00
use FHEM::Meta ;
2018-08-15 10:27:53 +02:00
2019-06-10 21:52:01 +02:00
my $ version = '0.6.16.13' ;
2018-08-15 10:27:53 +02:00
sub AutoShuttersControl_Initialize ($) {
my ( $ hash ) = @ _ ;
2019-04-09 12:13:46 +02:00
2019-06-04 06:37:38 +02:00
# ### 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 ';
2018-08-15 10:27:53 +02:00
2018-08-29 14:58:10 +02:00
## Da ich mit package arbeite müssen in die Initialize für die jeweiligen hash Fn Funktionen der Funktionsname
2018-10-14 18:19:23 +02:00
# und davor mit :: getrennt der eigentliche package Name des Modules
2019-03-27 08:41:15 +01:00
$ hash - > { SetFn } = 'FHEM::AutoShuttersControl::Set' ;
$ hash - > { GetFn } = 'FHEM::AutoShuttersControl::Get' ;
$ hash - > { DefFn } = 'FHEM::AutoShuttersControl::Define' ;
$ hash - > { NotifyFn } = 'FHEM::AutoShuttersControl::Notify' ;
$ hash - > { UndefFn } = 'FHEM::AutoShuttersControl::Undef' ;
$ hash - > { AttrFn } = 'FHEM::AutoShuttersControl::Attr' ;
2018-10-14 18:19:23 +02:00
$ hash - > { AttrList } =
2019-04-17 16:25:05 +02:00
'ASC_tempSensor '
2019-03-20 21:44:00 +01:00
. 'ASC_brightnessDriveUpDown '
2018-11-28 13:07:52 +01:00
. 'ASC_autoShuttersControlMorning:on,off '
. 'ASC_autoShuttersControlEvening:on,off '
. 'ASC_autoShuttersControlComfort:on,off '
2019-03-04 14:02:54 +01:00
. 'ASC_residentsDev '
. 'ASC_rainSensor '
2018-11-28 13:07:52 +01:00
. 'ASC_autoAstroModeMorning:REAL,CIVIL,NAUTIC,ASTRONOMIC,HORIZON '
. 'ASC_autoAstroModeMorningHorizon:-9,-8,-7,-6,-5,-4,-3,-2,-1,0,1,2,3,4,5,6,7,8,9 '
. '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_shuttersDriveOffset '
. 'ASC_twilightDevice '
2019-03-04 08:40:58 +01:00
. 'ASC_windSensor '
2018-11-28 13:07:52 +01:00
. 'ASC_expert:1 '
2019-03-27 11:22:06 +01:00
. 'ASC_blockAscDrivesAfterManual:0,1 '
2019-04-02 19:28:54 +02:00
. 'ASC_debug:1 '
2019-06-04 06:37:38 +02:00
# . $oldAttr
2018-10-14 18:19:23 +02:00
. $ readingFnAttributes ;
2018-11-28 13:07:52 +01:00
$ hash - > { NotifyOrderPrefix } = '51-' ; # Order Nummer für NotifyFn
2019-04-09 12:13:46 +02:00
2019-03-27 08:41:15 +01:00
return FHEM::Meta:: InitMod ( __FILE__ , $ hash ) ;
2018-08-15 10:27:53 +02:00
}
2019-05-20 13:52:05 +02:00
sub ascAPIget ($;$) {
2019-05-20 14:23:11 +02:00
my ( $ getCommand , $ shutterDev ) = @ _ ;
2019-05-20 13:52:05 +02:00
2019-05-20 14:23:11 +02:00
return FHEM::AutoShuttersControl:: ascAPIget ( $ getCommand , $ shutterDev ) ;
2019-05-20 13:52:05 +02:00
}
2018-10-15 14:51:04 +02:00
## unserer packagename
2019-03-27 08:41:15 +01:00
package FHEM::AutoShuttersControl ;
2018-11-09 09:11:13 +01:00
2018-08-15 10:27:53 +02:00
use strict ;
use warnings ;
use POSIX ;
2019-03-27 08:41:15 +01:00
use FHEM::Meta ;
2018-08-15 10:27:53 +02:00
2018-10-14 18:19:23 +02:00
use GPUtils qw( :all )
; # wird für den Import der FHEM Funktionen aus der fhem.pl benötigt
use Data::Dumper ; #only for Debugging
2018-08-28 19:49:01 +02:00
use Date::Parse ;
2018-08-15 10:27:53 +02:00
2019-06-10 21:52:01 +02:00
# my $missingModul = '';
# eval "use JSON qw(decode_json encode_json);1" or $missingModul .= 'JSON ';
# try to use JSON::MaybeXS wrapper
# for chance of better performance + open code
eval {
require JSON::MaybeXS ;
import JSON:: MaybeXS qw( decode_json encode_json ) ;
1 ;
} ;
2019-06-11 08:05:54 +02:00
2019-06-10 21:52:01 +02:00
if ( $@ ) {
$@ = undef ;
# try to use JSON wrapper
# for chance of better performance
eval {
# JSON preference order
local $ ENV { PERL_JSON_BACKEND } =
'Cpanel::JSON::XS,JSON::XS,JSON::PP,JSON::backportPP'
unless ( defined ( $ ENV { PERL_JSON_BACKEND } ) ) ;
require JSON ;
import JSON qw( decode_json encode_json ) ;
1 ;
} ;
if ( $@ ) {
$@ = undef ;
# In rare cases, Cpanel::JSON::XS may
# be installed but JSON|JSON::MaybeXS not ...
eval {
require Cpanel::JSON::XS ;
import Cpanel::JSON:: XS qw( decode_json encode_json ) ;
1 ;
} ;
if ( $@ ) {
$@ = undef ;
# In rare cases, JSON::XS may
# be installed but JSON not ...
eval {
require JSON::XS ;
import JSON:: XS qw( decode_json encode_json ) ;
1 ;
} ;
if ( $@ ) {
$@ = undef ;
# Fallback to built-in JSON which SHOULD
# be available since 5.014 ...
eval {
require JSON::PP ;
import JSON:: PP qw( decode_json encode_json ) ;
1 ;
} ;
if ( $@ ) {
$@ = undef ;
# Fallback to JSON::backportPP in really rare cases
require JSON::backportPP ;
import JSON:: backportPP qw( decode_json encode_json ) ;
1 ;
}
}
}
}
}
2018-08-15 10:27:53 +02:00
2018-08-29 14:58:10 +02:00
## Import der FHEM Funktionen
2018-08-15 10:27:53 +02:00
BEGIN {
2018-10-14 18:19:23 +02:00
GP_Import (
qw( devspec2array
readingsSingleUpdate
readingsBulkUpdate
readingsBulkUpdateIfChanged
readingsBeginUpdate
readingsEndUpdate
defs
modules
Log3
CommandAttr
attr
CommandDeleteAttr
CommandDeleteReading
CommandSet
AttrVal
ReadingsVal
Value
IsDisabled
deviceEvents
init_done
addToDevAttrList
addToAttrList
delFromDevAttrList
delFromAttrList
gettimeofday
sunset_abs
sunrise_abs
InternalTimer
RemoveInternalTimer
computeAlignTime
ReplaceEventMap )
) ;
}
2018-08-15 10:27:53 +02:00
2018-08-29 14:58:10 +02:00
## Die Attributsliste welche an die Rolläden verteilt wird. Zusammen mit Default Werten
2018-10-14 18:19:23 +02:00
my % userAttrList = (
2019-04-25 17:15:56 +02:00
'ASC_Mode_Up:absent,always,off,home' = > '-' ,
'ASC_Mode_Down:absent,always,off,home' = > '-' ,
'ASC_Up:time,astro,brightness' = > '-' ,
'ASC_Down:time,astro,brightness' = > '-' ,
'ASC_AutoAstroModeMorning:REAL,CIVIL,NAUTIC,ASTRONOMIC,HORIZON' = > '-' ,
2018-12-07 13:04:41 +01:00
'ASC_AutoAstroModeMorningHorizon:-9,-8,-7,-6,-5,-4,-3,-2,-1,0,1,2,3,4,5,6,7,8,9'
2019-04-25 17:15:56 +02:00
= > '-' ,
'ASC_AutoAstroModeEvening:REAL,CIVIL,NAUTIC,ASTRONOMIC,HORIZON' = > '-' ,
2018-12-07 13:04:41 +01:00
'ASC_AutoAstroModeEveningHorizon:-9,-8,-7,-6,-5,-4,-3,-2,-1,0,1,2,3,4,5,6,7,8,9'
2019-04-25 17:15:56 +02:00
= > '-' ,
2018-10-14 18:19:23 +02:00
'ASC_Open_Pos:0,10,20,30,40,50,60,70,80,90,100' = > [ '' , 0 , 100 ] ,
2019-04-25 21:34:46 +02:00
'ASC_Closed_Pos:0,10,20,30,40,50,60,70,80,90,100' = > [ '' , 100 , 0 ] ,
2018-11-28 13:11:32 +01:00
'ASC_Pos_Reading' = > [ '' , 'position' , 'pct' ] ,
2019-04-25 17:15:56 +02:00
'ASC_Time_Up_Early' = > '-' ,
'ASC_Time_Up_Late' = > '-' ,
'ASC_Time_Up_WE_Holiday' = > '-' ,
'ASC_Time_Down_Early' = > '-' ,
'ASC_Time_Down_Late' = > '-' ,
'ASC_PrivacyDownTime_beforNightClose' = > '-' ,
'ASC_PrivacyDown_Pos' = > '-' ,
'ASC_WindowRec' = > '-' ,
'ASC_Ventilate_Window_Open:on,off' = > '-' ,
'ASC_LockOut:soft,hard,off' = > '-' ,
'ASC_LockOut_Cmd:inhibit,blocked,protection' = > '-' ,
'ASC_BlockingTime_afterManual' = > '-' ,
'ASC_BlockingTime_beforNightClose' = > '-' ,
'ASC_BlockingTime_beforDayOpen' = > '-' ,
'ASC_BrightnessSensor' = > '-' ,
'ASC_Shading_Direction' = > '-' ,
2019-04-25 21:49:11 +02:00
'ASC_Shading_Pos:10,20,30,40,50,60,70,80,90,100' = > [ '' , 80 , 20 ] ,
'ASC_Shading_Mode:absent,always,off,home' = > '-' ,
'ASC_Shading_Angle_Left' = > '-' ,
'ASC_Shading_Angle_Right' = > '-' ,
'ASC_Shading_StateChange_Sunny' = > '-' ,
'ASC_Shading_StateChange_Cloudy' = > '-' ,
2019-06-10 13:41:46 +02:00
'ASC_Shading_MinMax_Elevation' = > '-' ,
2019-04-25 21:49:11 +02:00
'ASC_Shading_Min_OutsideTemperature' = > '-' ,
'ASC_Shading_WaitingPeriod' = > '-' ,
2019-04-25 17:15:56 +02:00
'ASC_Drive_Offset' = > '-' ,
'ASC_Drive_OffsetStart' = > '-' ,
'ASC_WindowRec_subType:twostate,threestate' = > '-' ,
'ASC_ShuttersPlace:window,terrace' = > '-' ,
2018-11-19 09:06:50 +01:00
'ASC_Ventilate_Pos:10,20,30,40,50,60,70,80,90,100' = > [ '' , 70 , 30 ] ,
'ASC_ComfortOpen_Pos:0,10,20,30,40,50,60,70,80,90,100' = > [ '' , 20 , 80 ] ,
2019-04-25 17:15:56 +02:00
'ASC_GuestRoom:on,off' = > '-' ,
'ASC_Antifreeze:off,soft,hard,am,pm' = > '-' ,
2018-12-07 13:04:41 +01:00
'ASC_Antifreeze_Pos:5,10,15,20,25,30,35,40,45,50,55,60,65,70,75,80,85,90,95,100'
2018-11-19 09:06:50 +01:00
= > [ '' , 85 , 15 ] ,
2019-04-25 17:15:56 +02:00
'ASC_Partymode:on,off' = > '-' ,
'ASC_Roommate_Device' = > '-' ,
'ASC_Roommate_Reading' = > '-' ,
'ASC_Self_Defense_Exclude:on,off' = > '-' ,
'ASC_WiggleValue' = > '-' ,
'ASC_WindParameters' = > '-' ,
'ASC_DriveUpMaxDuration' = > '-' ,
2019-04-28 22:13:27 +02:00
'ASC_WindProtection:on,off' = > '-' ,
2019-04-29 13:22:37 +02:00
'ASC_RainProtection:on,off' = > '-' ,
2018-10-14 18:19:23 +02:00
) ;
2018-11-07 08:22:11 +01:00
my % posSetCmds = (
2018-11-08 08:32:47 +01:00
ZWave = > 'dim' ,
2019-05-31 11:15:42 +02:00
Siro = > 'pct' ,
2018-11-08 08:32:47 +01:00
CUL_HM = > 'pct' ,
ROLLO = > 'pct' ,
SOMFY = > 'position' ,
tahoma = > 'dim' ,
KLF200Node = > 'pct' ,
DUOFERN = > 'position' ,
2018-11-28 12:14:06 +01:00
HM485 = > 'level' ,
2018-11-07 08:22:11 +01:00
) ;
2018-10-14 18:19:23 +02:00
my $ shutters = new ASC_Shutters ( ) ;
my $ ascDev = new ASC_Dev ( ) ;
2018-10-10 10:43:42 +02:00
2019-05-20 13:52:05 +02:00
sub ascAPIget ($;$) {
2019-05-20 14:23:11 +02:00
my ( $ getCommand , $ shutterDev ) = @ _ ;
2019-05-20 13:52:05 +02:00
2019-05-20 14:23:11 +02:00
my $ getter = 'get' . $ getCommand ;
2019-05-20 13:52:05 +02:00
if ( defined ( $ shutterDev ) and $ shutterDev ) {
$ shutters - > setShuttersDev ( $ shutterDev ) ;
return $ shutters - > $ getter ;
}
else {
return $ ascDev - > $ getter ;
}
}
2018-10-14 18:19:23 +02:00
sub Define ($$) {
my ( $ hash , $ def ) = @ _ ;
2018-11-28 13:07:52 +01:00
my @ a = split ( '[ \t][ \t]*' , $ def ) ;
2018-08-15 10:27:53 +02:00
2019-03-27 08:41:15 +01:00
return $@ unless ( FHEM::Meta:: SetInternals ( $ hash ) ) ;
2018-11-28 13:07:52 +01:00
return 'only one AutoShuttersControl instance allowed'
2018-10-14 18:19:23 +02:00
if ( devspec2array ( 'TYPE=AutoShuttersControl' ) > 1 )
; # es wird geprüft ob bereits eine Instanz unseres Modules existiert,wenn ja wird abgebrochen
2018-11-28 13:07:52 +01:00
return 'too few parameters: define <name> ShuttersControl' if ( @ a != 2 ) ;
2019-06-10 21:52:01 +02:00
# return
# 'Cannot define ShuttersControl device. Perl modul '
# . ${missingModul}
# . 'is missing.'
# if ($missingModul)
# ; # Abbruch wenn benötigte Hilfsmodule nicht vorhanden sind / vorerst unwichtig
2018-10-14 18:19:23 +02:00
my $ name = $ a [ 0 ] ;
$ hash - > { VERSION } = $ version ;
$ hash - > { MID } = 'da39a3ee5e6b4b0d3255bfef95601890afd80709'
; # eine Ein Eindeutige ID für interne FHEM Belange / nicht weiter wichtig
2018-11-28 13:07:52 +01:00
$ hash - > { NOTIFYDEV } = 'global,'
2018-10-14 18:19:23 +02:00
. $ name ; # Liste aller Devices auf deren Events gehört werden sollen
2019-05-20 14:23:11 +02:00
#$hash->{shutters} = $shutters;
#$hash->{ascDev} = $ascDev;
2018-10-14 18:19:23 +02:00
$ ascDev - > setName ( $ name ) ;
2018-08-15 10:27:53 +02:00
2018-11-15 10:15:36 +01:00
readingsSingleUpdate (
$ hash ,
2018-11-28 13:07:52 +01:00
'state' ,
'please set attribute ASC with value 1 or 2 in all auto controlled shutter devices and then execute \'set DEVICENAME scanForShutters\'' ,
2018-11-15 10:15:36 +01:00
1
) ;
2018-11-15 00:44:41 +01:00
2018-10-14 18:19:23 +02:00
CommandAttr ( undef , $ name . ' room ASC' )
if ( AttrVal ( $ name , 'room' , 'none' ) eq 'none' ) ;
CommandAttr ( undef , $ name . ' icon fts_shutter_automatic' )
if ( AttrVal ( $ name , 'icon' , 'none' ) eq 'none' ) ;
2019-05-04 23:01:57 +02:00
2018-11-08 08:32:47 +01:00
CommandAttr ( undef ,
$ name
2018-12-06 15:24:16 +01:00
. ' 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'
2018-11-08 08:32:47 +01:00
) if ( AttrVal ( $ name , 'devStateIcon' , 'none' ) eq 'none' ) ;
2018-08-15 10:27:53 +02:00
2018-10-14 18:19:23 +02:00
addToAttrList ( 'ASC:0,1,2' ) ;
2018-08-15 10:27:53 +02:00
2018-10-14 18:19:23 +02:00
Log3 ( $ name , 3 , "AutoShuttersControl ($name) - defined" ) ;
2018-08-15 10:27:53 +02:00
2018-10-14 18:19:23 +02:00
$ modules { AutoShuttersControl } { defptr } { $ hash - > { MID } } = $ hash ;
2018-08-15 10:27:53 +02:00
return undef ;
}
sub Undef ($$) {
2018-10-14 18:19:23 +02:00
my ( $ hash , $ arg ) = @ _ ;
2018-08-15 10:27:53 +02:00
my $ name = $ hash - > { NAME } ;
2018-10-14 18:19:23 +02:00
UserAttributs_Readings_ForShutters ( $ hash , 'del' )
; # es sollen alle Attribute und Readings in den Rolläden Devices gelöscht werden welche vom Modul angelegt wurden
2018-09-27 10:19:41 +02:00
delFromAttrList ( 'ASC:0,1,2' ) ;
2018-10-14 18:19:23 +02:00
delete ( $ modules { AutoShuttersControl } { defptr } { $ hash - > { MID } } ) ;
Log3 ( $ name , 3 , "AutoShuttersControl ($name) - delete device $name" ) ;
2018-08-15 10:27:53 +02:00
return undef ;
}
sub Attr (@) {
my ( $ cmd , $ name , $ attrName , $ attrVal ) = @ _ ;
2019-06-03 07:44:35 +02:00
# my $hash = $defs{$name};
2018-08-15 10:27:53 +02:00
return undef ;
}
sub Notify ($$) {
2018-10-14 18:19:23 +02:00
my ( $ hash , $ dev ) = @ _ ;
2018-08-15 10:27:53 +02:00
my $ name = $ hash - > { NAME } ;
2018-09-03 22:19:25 +02:00
2018-08-15 10:27:53 +02:00
my $ devname = $ dev - > { NAME } ;
my $ devtype = $ dev - > { TYPE } ;
2018-10-14 18:19:23 +02:00
my $ events = deviceEvents ( $ dev , 1 ) ;
return if ( ! $ events ) ;
2019-03-06 15:53:48 +01:00
Log3 ( $ name , 4 ,
2018-10-14 18:19:23 +02:00
"AutoShuttersControl ($name) - Devname: "
. $ devname
. " Name: "
. $ name
. " Notify: "
. Dumper $ events ) ; # mit Dumper
if (
(
grep /^DEFINED.$name$/ ,
@ { $ events } and $ devname eq 'global' and $ init_done
)
or (
grep /^INITIALIZED$/ ,
@ { $ events } or grep /^REREADCFG$/ ,
@ { $ events } or grep /^MODIFIED.$name$/ ,
@ { $ events }
)
2018-08-15 10:27:53 +02:00
and $ devname eq 'global'
2018-10-14 18:19:23 +02:00
)
{
readingsSingleUpdate ( $ hash , 'partyMode' , 'off' , 0 )
2018-11-03 19:01:29 +01:00
if ( $ ascDev - > getPartyMode eq 'none' ) ;
2018-12-06 15:24:16 +01:00
readingsSingleUpdate ( $ hash , 'hardLockOut' , 'off' , 0 )
if ( $ ascDev - > getHardLockOut eq 'none' ) ;
2018-10-14 18:19:23 +02:00
readingsSingleUpdate ( $ hash , 'sunriseTimeWeHoliday' , 'off' , 0 )
if ( $ ascDev - > getSunriseTimeWeHoliday eq 'none' ) ;
readingsSingleUpdate ( $ hash , 'selfDefense' , 'off' , 0 )
if ( $ ascDev - > getSelfDefense eq 'none' ) ;
2019-05-04 23:01:57 +02:00
readingsSingleUpdate ( $ hash , 'controlShading' , 'off' , 0 )
if ( $ ascDev - > getAutoShuttersControlShading eq 'none' ) ;
2019-05-17 14:20:57 +02:00
readingsSingleUpdate ( $ hash , 'ascEnable' , 'on' , 0 )
if ( $ ascDev - > getASCenable eq 'none' ) ;
2019-01-02 09:38:00 +01:00
2018-10-14 18:19:23 +02:00
# 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 )
unless ( ReadingsVal ( $ name , 'userAttrList' , 'none' ) eq 'none' ) ;
}
return
unless ( ref ( $ hash - > { helper } { shuttersList } ) eq 'ARRAY'
and scalar ( @ { $ hash - > { helper } { shuttersList } } ) > 0 ) ;
2018-10-19 20:13:01 +02:00
2018-10-17 15:58:05 +02:00
my $ posReading = $ shutters - > getPosCmd ;
2018-10-14 18:19:23 +02:00
if ( $ devname eq $ name ) {
if ( grep /^userAttrList:.rolled.out$/ , @ { $ events } ) {
unless ( scalar ( @ { $ hash - > { helper } { shuttersList } } ) == 0 ) {
2018-09-04 11:42:47 +02:00
WriteReadingsShuttersList ( $ hash ) ;
2018-10-14 18:19:23 +02:00
UserAttributs_Readings_ForShutters ( $ hash , 'add' ) ;
InternalTimer ( gettimeofday ( ) + 3 ,
2019-03-27 08:41:15 +01:00
'FHEM::AutoShuttersControl::RenewSunRiseSetShuttersTimer' ,
2018-10-14 18:19:23 +02:00
$ hash ) ;
2018-11-15 00:44:41 +01:00
InternalTimer ( gettimeofday ( ) + 5 ,
2019-03-27 08:41:15 +01:00
'FHEM::AutoShuttersControl::AutoSearchTwilightDev' , $ hash ) ;
2018-09-04 11:42:47 +02:00
}
2018-10-14 18:19:23 +02:00
}
elsif ( grep /^partyMode:.off$/ , @ { $ events } ) {
2018-11-12 12:56:18 +01:00
EventProcessingPartyMode ( $ hash ) ;
2018-10-14 18:19:23 +02:00
}
elsif ( grep /^sunriseTimeWeHoliday:.(on|off)$/ , @ { $ events } ) {
2018-09-18 09:35:45 +02:00
RenewSunRiseSetShuttersTimer ( $ hash ) ;
2018-09-04 11:42:47 +02:00
}
2018-10-14 18:19:23 +02:00
}
elsif ( $ devname eq "global" )
{ # Kommt ein globales Event und beinhaltet folgende Syntax wird die Funktion zur Verarbeitung aufgerufen
if (
grep
2019-03-24 16:41:48 +01:00
/^(ATTR|DELETEATTR)\s(.*ASC_Time_Up_WE_Holiday|.*ASC_Up|.*ASC_Down|.*ASC_AutoAstroModeMorning|.*ASC_AutoAstroModeMorningHorizon|.*ASC_AutoAstroModeEvening|.*ASC_AutoAstroModeEveningHorizon|.*ASC_Time_Up_Early|.*ASC_Time_Up_Late|.*ASC_Time_Down_Early|.*ASC_Time_Down_Late|.*ASC_autoAstroModeMorning|.*ASC_autoAstroModeMorningHorizon|.*ASC_PrivacyDownTime_beforNightClose|.*ASC_autoAstroModeEvening|.*ASC_autoAstroModeEveningHorizon|.*ASC_Roommate_Device|.*ASC_WindowRec|.*ASC_residentsDev|.*ASC_rainSensor|.*ASC_windSensor|.*ASC_BrightnessSensor|.*ASC_twilightDevice)(\s.*|$)/ ,
2018-10-27 13:36:11 +02:00
@ { $ events }
)
2018-10-14 18:19:23 +02:00
{
2018-11-12 12:56:18 +01:00
EventProcessingGeneral ( $ hash , undef , join ( ' ' , @ { $ events } ) ) ;
2018-08-16 10:37:09 +02:00
}
2018-08-15 10:27:53 +02:00
}
2018-10-19 20:13:01 +02:00
elsif ( grep /^($posReading):\s\d+$/ , @ { $ events } ) {
2018-11-12 12:56:18 +01:00
EventProcessingShutters ( $ hash , $ devname , join ( ' ' , @ { $ events } ) ) ;
2018-10-19 20:13:01 +02:00
}
2018-10-14 18:19:23 +02:00
else {
2018-11-12 12:56:18 +01:00
EventProcessingGeneral ( $ hash , $ devname , join ( ' ' , @ { $ events } ) )
2018-10-14 18:19:23 +02:00
; # bei allen anderen Events wird die entsprechende Funktion zur Verarbeitung aufgerufen
}
2018-08-15 10:27:53 +02:00
return ;
}
2018-11-12 12:56:18 +01:00
sub EventProcessingGeneral ($$$) {
2018-10-14 18:19:23 +02:00
my ( $ hash , $ devname , $ events ) = @ _ ;
my $ name = $ hash - > { NAME } ;
2018-08-16 10:37:09 +02:00
2018-10-14 18:19:23 +02:00
if ( defined ( $ devname ) and ( $ devname ) )
{ # es wird lediglich der Devicename der Funktion mitgegeben wenn es sich nicht um global handelt daher hier die Unterschiedung
while ( my ( $ device , $ deviceAttr ) =
each % { $ hash - > { monitoredDevs } { $ devname } } )
{
2018-11-12 12:56:18 +01:00
EventProcessingWindowRec ( $ hash , $ device , $ events )
2018-10-14 18:19:23 +02:00
if ( $ deviceAttr eq 'ASC_WindowRec' )
; # ist es ein Fensterdevice wird die Funktion gestartet
2018-11-12 12:56:18 +01:00
EventProcessingRoommate ( $ hash , $ device , $ events )
2018-10-14 18:19:23 +02:00
if ( $ deviceAttr eq 'ASC_Roommate_Device' )
; # ist es ein Bewohner Device wird diese Funktion gestartet
2018-11-12 12:56:18 +01:00
EventProcessingResidents ( $ hash , $ device , $ events )
2019-03-04 14:02:54 +01:00
if ( $ deviceAttr eq 'ASC_residentsDev' ) ;
2018-11-12 12:56:18 +01:00
EventProcessingRain ( $ hash , $ device , $ events )
2019-03-04 14:02:54 +01:00
if ( $ deviceAttr eq 'ASC_rainSensor' ) ;
2019-02-26 12:04:10 +01:00
EventProcessingWind ( $ hash , $ device , $ events )
2019-03-04 10:57:39 +01:00
if ( $ deviceAttr eq 'ASC_windSensor' ) ;
2018-11-14 03:41:38 +01:00
EventProcessingTwilightDevice ( $ hash , $ device , $ events )
if ( $ deviceAttr eq 'ASC_twilightDevice' ) ;
2018-10-14 18:19:23 +02:00
$ shutters - > setShuttersDev ( $ device )
2019-03-24 16:41:48 +01:00
if ( $ deviceAttr eq 'ASC_BrightnessSensor' ) ;
2018-11-14 03:41:38 +01:00
if (
2019-03-24 16:41:48 +01:00
$ deviceAttr eq 'ASC_BrightnessSensor'
2018-11-19 09:06:50 +01:00
and ( $ shutters - > getDown eq 'brightness'
or $ shutters - > getUp eq 'brightness' )
)
{
2018-11-14 03:41:38 +01:00
EventProcessingBrightness ( $ hash , $ device , $ events ) ;
}
2019-03-24 16:41:48 +01:00
elsif ( $ deviceAttr eq 'ASC_BrightnessSensor' ) {
2018-11-14 03:41:38 +01:00
EventProcessingShadingBrightness ( $ hash , $ device , $ events ) ;
}
2018-08-28 19:49:01 +02:00
}
2018-10-14 18:19:23 +02:00
}
else { # alles was kein Devicenamen mit übergeben hat landet hier
if ( $ events =~
2019-03-24 16:41:48 +01:00
m #^ATTR\s(.*)\s(ASC_Roommate_Device|ASC_WindowRec|ASC_residentsDev|ASC_rainSensor|ASC_windSensor|ASC_BrightnessSensor|ASC_twilightDevice)\s(.*)$#
2018-10-14 18:19:23 +02:00
)
{ # wurde den Attributen unserer Rolläden ein Wert zugewiesen ?
2018-11-07 08:22:11 +01:00
AddNotifyDev ( $ hash , $ 3 , $ 1 , $ 2 ) if ( $ 3 ne 'none' ) ;
2018-10-14 18:19:23 +02:00
Log3 ( $ name , 4 ,
"AutoShuttersControl ($name) - EventProcessing: ATTR" ) ;
2018-08-28 19:49:01 +02:00
}
2018-10-14 18:19:23 +02:00
elsif ( $ events =~
2019-03-24 16:41:48 +01:00
m #^DELETEATTR\s(.*)\s(ASC_Roommate_Device|ASC_WindowRec|ASC_residentsDev|ASC_rainSensor|ASC_windSensor|ASC_BrightnessSensor|ASC_twilightDevice)$#
2018-10-14 18:19:23 +02:00
)
{ # wurde das Attribut unserer Rolläden gelöscht ?
Log3 ( $ name , 4 ,
"AutoShuttersControl ($name) - EventProcessing: DELETEATTR" ) ;
DeleteNotifyDev ( $ hash , $ 1 , $ 2 ) ;
2018-08-27 11:08:08 +02:00
}
2018-10-27 13:36:11 +02:00
elsif ( $ events =~
2019-05-28 09:23:10 +02:00
m #^(DELETEATTR|ATTR)\s(.*)\s(ASC_Time_Up_WE_Holiday|ASC_Up|ASC_Down|ASC_AutoAstroModeMorning|ASC_AutoAstroModeMorningHorizon|ASC_PrivacyDownTime_beforNightClose|ASC_AutoAstroModeEvening|ASC_AutoAstroModeEveningHorizon|ASC_Time_Up_Early|ASC_Time_Up_Late|ASC_Time_Down_Early|ASC_Time_Down_Late)(.*)?#
2018-10-27 13:36:11 +02:00
)
{
2019-05-28 09:23:10 +02:00
CreateSunRiseSetShuttersTimer ( $ hash , $ 2 )
2018-10-27 13:36:11 +02:00
if (
2019-05-28 09:23:10 +02:00
$ 3 ne 'ASC_Time_Up_WE_Holiday'
or ( $ 3 eq 'ASC_Time_Up_WE_Holiday'
2018-10-27 13:36:11 +02:00
and $ ascDev - > getSunriseTimeWeHoliday eq 'on' )
) ;
}
2018-11-07 08:22:11 +01:00
elsif ( $ events =~
2019-05-28 09:23:10 +02:00
m #^(DELETEATTR|ATTR)\s(.*)\s(ASC_autoAstroModeMorning|ASC_autoAstroModeMorningHorizon|ASC_autoAstroModeEvening|ASC_autoAstroModeEveningHorizon)(.*)?#
2018-11-07 08:22:11 +01:00
)
{
RenewSunRiseSetShuttersTimer ( $ hash ) ;
}
2018-08-16 10:37:09 +02:00
}
}
2018-08-15 10:27:53 +02:00
sub Set ($$@) {
2018-10-14 18:19:23 +02:00
my ( $ hash , $ name , @ aa ) = @ _ ;
my ( $ cmd , @ args ) = @ aa ;
if ( lc $ cmd eq 'renewsetsunrisesunsettimer' ) {
return "usage: $cmd" if ( @ args != 0 ) ;
2018-08-29 14:58:10 +02:00
RenewSunRiseSetShuttersTimer ( $ hash ) ;
2018-10-14 18:19:23 +02:00
}
elsif ( lc $ cmd eq 'scanforshutters' ) {
return "usage: $cmd" if ( @ args != 0 ) ;
2018-09-03 22:19:25 +02:00
ShuttersDeviceScan ( $ hash ) ;
2018-10-14 18:19:23 +02:00
}
elsif ( lc $ cmd eq 'createnewnotifydev' ) {
return "usage: $cmd" if ( @ args != 0 ) ;
2018-10-08 03:59:51 +02:00
CreateNewNotifyDev ( $ hash ) ;
2018-10-14 18:19:23 +02:00
}
elsif ( lc $ cmd eq 'partymode' ) {
return "usage: $cmd" if ( @ args > 1 ) ;
2019-02-11 21:26:42 +01:00
readingsSingleUpdate ( $ hash , $ cmd , join ( ' ' , @ args ) , 1 )
2019-04-09 12:13:46 +02:00
if ( join ( ' ' , @ args ) ne ReadingsVal ( $ name , 'partyMode' , 0 ) ) ;
2018-10-14 18:19:23 +02:00
}
2018-11-21 21:56:29 +01:00
elsif ( lc $ cmd eq 'hardlockout' ) {
2018-10-14 18:19:23 +02:00
return "usage: $cmd" if ( @ args > 1 ) ;
readingsSingleUpdate ( $ hash , $ cmd , join ( ' ' , @ args ) , 1 ) ;
2018-11-21 08:38:32 +01:00
HardewareBlockForShutters ( $ hash , join ( ' ' , @ args ) ) ;
2018-10-14 18:19:23 +02:00
}
elsif ( lc $ cmd eq 'sunrisetimeweholiday' ) {
return "usage: $cmd" if ( @ args > 1 ) ;
readingsSingleUpdate ( $ hash , $ cmd , join ( ' ' , @ args ) , 1 ) ;
}
2019-05-04 23:01:57 +02:00
elsif ( lc $ cmd eq 'controlshading' ) {
return "usage: $cmd" if ( @ args > 1 ) ;
readingsSingleUpdate ( $ hash , $ cmd , join ( ' ' , @ args ) , 1 ) ;
}
2018-10-14 18:19:23 +02:00
elsif ( lc $ cmd eq 'selfdefense' ) {
return "usage: $cmd" if ( @ args > 1 ) ;
readingsSingleUpdate ( $ hash , $ cmd , join ( ' ' , @ args ) , 1 ) ;
}
2019-05-17 14:20:57 +02:00
elsif ( lc $ cmd eq 'ascenable' ) {
return "usage: $cmd" if ( @ args > 1 ) ;
readingsSingleUpdate ( $ hash , $ cmd , join ( ' ' , @ args ) , 1 ) ;
}
elsif ( lc $ cmd eq 'shutterascenabletoggle' ) {
return "usage: $cmd" if ( @ args > 1 ) ;
readingsSingleUpdate (
$ defs { $ args [ 0 ] } ,
'ASC_Enable' ,
(
ReadingsVal ( $ args [ 0 ] , 'ASC_Enable' , 'off' ) eq 'on'
? 'off'
: 'on'
) ,
1
) ;
}
2018-11-07 08:22:11 +01:00
elsif ( lc $ cmd eq 'wiggle' ) {
return "usage: $cmd" if ( @ args > 1 ) ;
2018-11-08 08:32:47 +01:00
( $ args [ 0 ] eq 'all' ? wiggleAll ( $ hash ) : wiggle ( $ hash , $ args [ 0 ] ) ) ;
2018-11-07 08:22:11 +01:00
}
2018-10-14 18:19:23 +02:00
else {
2019-05-17 14:20:57 +02:00
my $ list = 'scanForShutters:noArg' ;
2018-10-14 18:19:23 +02:00
$ list . =
2019-05-17 14:20:57 +02:00
' renewSetSunriseSunsetTimer:noArg partyMode:on,off hardLockOut:on,off sunriseTimeWeHoliday:on,off controlShading:on,off selfDefense:on,off ascEnable:on,off wiggle:all,'
2018-11-08 08:32:47 +01:00
. join ( ',' , @ { $ hash - > { helper } { shuttersList } } )
2018-10-27 14:09:02 +02:00
if ( ReadingsVal ( $ name , 'userAttrList' , 'none' ) eq 'rolled out' ) ;
2019-05-17 14:20:57 +02:00
$ list . = ' createNewNotifyDev:noArg'
2018-10-28 18:12:40 +01:00
if ( ReadingsVal ( $ name , 'userAttrList' , 'none' ) eq 'rolled out'
2018-11-11 12:31:20 +01:00
and AttrVal ( $ name , 'ASC_expert' , 0 ) == 1 ) ;
2019-05-17 14:20:57 +02:00
$ list . =
' shutterASCenableToggle:'
. join ( ',' , @ { $ hash - > { helper } { shuttersList } } )
if ( ReadingsVal ( $ name , 'userAttrList' , 'none' ) eq 'rolled out' ) ;
2018-10-08 03:59:51 +02:00
2018-10-14 18:19:23 +02:00
return "Unknown argument $cmd,choose one of $list" ;
2018-08-15 10:27:53 +02:00
}
return undef ;
}
2018-09-21 08:44:38 +02:00
sub Get ($$@) {
2018-10-14 18:19:23 +02:00
my ( $ hash , $ name , @ aa ) = @ _ ;
2018-09-21 08:44:38 +02:00
2018-10-14 18:19:23 +02:00
my ( $ cmd , @ args ) = @ aa ;
2018-09-21 08:44:38 +02:00
2018-10-14 18:19:23 +02:00
if ( lc $ cmd eq 'showshuttersinformations' ) {
return "usage: $cmd" if ( @ args != 0 ) ;
2018-09-21 08:44:38 +02:00
my $ ret = GetShuttersInformation ( $ hash ) ;
return $ ret ;
2018-10-14 18:19:23 +02:00
}
elsif ( lc $ cmd eq 'shownotifydevsinformations' ) {
return "usage: $cmd" if ( @ args != 0 ) ;
2018-10-08 03:59:51 +02:00
my $ ret = GetMonitoredDevs ( $ hash ) ;
return $ ret ;
2018-10-14 18:19:23 +02:00
}
else {
2018-09-21 08:44:38 +02:00
my $ list = "" ;
2018-10-28 18:12:40 +01:00
$ list . = " showShuttersInformations:noArg"
2018-10-14 18:19:23 +02:00
if ( ReadingsVal ( $ name , 'userAttrList' , 'none' ) eq 'rolled out' ) ;
2018-10-27 14:09:02 +02:00
$ list . = " showNotifyDevsInformations:noArg"
2018-10-27 13:36:11 +02:00
if ( ReadingsVal ( $ name , 'userAttrList' , 'none' ) eq 'rolled out'
2018-11-11 12:31:20 +01:00
and AttrVal ( $ name , 'ASC_expert' , 0 ) == 1 ) ;
2018-10-28 18:12:40 +01:00
2018-10-14 18:19:23 +02:00
return "Unknown argument $cmd,choose one of $list" ;
2018-09-21 08:44:38 +02:00
}
}
2018-08-15 10:27:53 +02:00
sub ShuttersDeviceScan ($) {
2018-10-14 18:19:23 +02:00
my $ hash = shift ;
my $ name = $ hash - > { NAME } ;
2018-09-13 10:38:35 +02:00
delete $ hash - > { helper } { shuttersList } ;
2018-08-15 10:27:53 +02:00
my @ list ;
2018-09-27 10:19:41 +02:00
@ list = devspec2array ( 'ASC=[1-2]' ) ;
2018-09-13 15:21:29 +02:00
2018-10-14 18:19:23 +02:00
CommandDeleteReading ( undef , $ name . ' .*_nextAstroTimeEvent' ) ;
unless ( scalar ( @ list ) > 0 ) {
2018-09-03 22:19:25 +02:00
readingsBeginUpdate ( $ hash ) ;
2018-10-14 18:19:23 +02:00
readingsBulkUpdate ( $ hash , 'userAttrList' , 'none' ) ;
readingsBulkUpdate ( $ hash , 'state' , 'no shutters found' ) ;
readingsEndUpdate ( $ hash , 1 ) ;
2018-09-03 22:19:25 +02:00
return ;
}
2018-10-17 15:58:05 +02:00
my $ shuttersList = '' ;
2018-10-14 18:19:23 +02:00
foreach ( @ list ) {
push ( @ { $ hash - > { helper } { shuttersList } } , $ _ )
; ## einem Hash wird ein Array zugewiesen welches die Liste der erkannten Rollos beinhaltet
2019-03-07 17:58:30 +01:00
2019-06-03 07:44:35 +02:00
# delFromDevAttrList( $_, 'ASC_Wind_SensorDevice' )
# ; # temporär muss später gelöscht werden ab Version 0.4.0.10
# delFromDevAttrList( $_, 'ASC_Wind_SensorReading' )
# ; # temporär muss später gelöscht werden ab Version 0.4.0.10
# delFromDevAttrList( $_, 'ASC_Wind_minMaxSpeed' )
# ; # temporär muss später gelöscht werden ab Version 0.4.11beta6
# delFromDevAttrList( $_, 'ASC_Wind_Pos' )
# ; # temporär muss später gelöscht werden ab Version 0.4.11beta6
# CommandDeleteReading( undef, $_ . ' ASC_Time_PrivacyDriveUp' )
# if ( ReadingsVal( $_, 'ASC_Time_PrivacyDriveUp', 'none' ) ne 'none' )
# ; # temporär muss später gelöscht werden ab Version 0.6.3
2019-03-07 17:58:30 +01:00
2018-10-17 15:58:05 +02:00
$ shuttersList = $ shuttersList . ',' . $ _ ;
$ shutters - > setShuttersDev ( $ _ ) ;
2018-10-19 20:13:01 +02:00
$ shutters - > setLastManPos ( $ shutters - > getStatus ) ;
2018-10-28 18:12:40 +01:00
$ shutters - > setLastPos ( $ shutters - > getStatus ) ;
2018-10-27 13:36:11 +02:00
$ shutters - > setDelayCmd ( 'none' ) ;
2018-11-07 08:22:11 +01:00
$ shutters - > setNoOffset ( 0 ) ;
2018-11-12 09:12:04 +01:00
$ shutters - > setPosSetCmd ( $ posSetCmds { $ defs { $ _ } - > { TYPE } } ) ;
2019-04-09 12:13:46 +02:00
$ shutters - > setShadingStatus (
( $ shutters - > getStatus != $ shutters - > getShadingPos ? 'out' : 'in' )
) ;
2019-05-17 14:20:57 +02:00
readingsSingleUpdate ( $ defs { $ _ } , 'ASC_Enable' , 'on' , 0 )
if ( ReadingsVal ( $ _ , 'ASC_Enable' , 'none' ) eq 'none' ) ;
2018-08-15 10:27:53 +02:00
}
2019-03-07 17:58:30 +01:00
2019-06-03 11:32:50 +02:00
# ### Temporär und muss später entfernt werden
# CommandAttr( undef,
# $name
# . ' ASC_tempSensor '
# . AttrVal( $name, 'ASC_temperatureSensor', 'none' ) . ':'
# . AttrVal( $name, 'ASC_temperatureReading', 'temperature' ) )
# if ( AttrVal( $name, 'ASC_temperatureSensor', 'none' ) ne 'none' );
# CommandAttr( undef,
# $name
# . ' ASC_residentsDev '
# . AttrVal( $name, 'ASC_residentsDevice', 'none' ) . ':'
# . AttrVal( $name, 'ASC_residentsDeviceReading', 'state' ) )
# if ( AttrVal( $name, 'ASC_residentsDevice', 'none' ) ne 'none' );
# CommandAttr( undef,
# $name
# . ' ASC_rainSensor '
# . AttrVal( $name, 'ASC_rainSensorDevice', 'none' ) . ':'
# . AttrVal( $name, 'ASC_rainSensorReading', 'rain' ) . ' 100 '
# . AttrVal( $name, 'ASC_rainSensorShuttersClosedPos', 50 ) )
# if ( AttrVal( $name, 'ASC_rainSensorDevice', 'none' ) ne 'none' );
# CommandAttr( undef,
# $name
# . ' ASC_brightnessDriveUpDown '
# . AttrVal( $name, 'ASC_brightnessMinVal', 500 ) . ':'
# . AttrVal( $name, 'ASC_brightnessMaxVal', 800 ) )
# if ( AttrVal( $name, 'ASC_brightnessMinVal', 'none' ) ne 'none' );
2019-06-04 06:37:38 +02:00
#
2019-06-03 11:32:50 +02:00
# CommandDeleteAttr( undef, $name . ' ASC_temperatureSensor' )
# if ( AttrVal( $name, 'ASC_temperatureSensor', 'none' ) ne 'none' );
# CommandDeleteAttr( undef, $name . ' ASC_temperatureReading' )
# if ( AttrVal( $name, 'ASC_temperatureReading', 'none' ) ne 'none' );
# CommandDeleteAttr( undef, $name . ' ASC_residentsDevice' )
# if ( AttrVal( $name, 'ASC_residentsDevice', 'none' ) ne 'none' );
# CommandDeleteAttr( undef, $name . ' ASC_residentsDeviceReading' )
# if ( AttrVal( $name, 'ASC_residentsDeviceReading', 'none' ) ne 'none' );
# CommandDeleteAttr( undef, $name . ' ASC_rainSensorDevice' )
# if ( AttrVal( $name, 'ASC_rainSensorDevice', 'none' ) ne 'none' );
# CommandDeleteAttr( undef, $name . ' ASC_rainSensorReading' )
# if ( AttrVal( $name, 'ASC_rainSensorReading', 'none' ) ne 'none' );
# CommandDeleteAttr( undef, $name . ' ASC_rainSensorShuttersClosedPos' )
# if (
# AttrVal( $name, 'ASC_rainSensorShuttersClosedPos', 'none' ) ne 'none' );
# CommandDeleteAttr( undef, $name . ' ASC_brightnessMinVal' )
# if ( AttrVal( $name, 'ASC_brightnessMinVal', 'none' ) ne 'none' );
# CommandDeleteAttr( undef, $name . ' ASC_brightnessMaxVal' )
# if ( AttrVal( $name, 'ASC_brightnessMaxVal', 'none' ) ne 'none' );
2018-11-14 03:41:38 +01:00
2018-11-19 09:06:50 +01:00
$ hash - > { NOTIFYDEV } = "global," . $ name . $ shuttersList ;
2018-10-19 20:13:01 +02:00
2018-10-14 18:19:23 +02:00
if ( $ ascDev - > getMonitoredDevs ne 'none' ) {
$ hash - > { monitoredDevs } =
eval { decode_json ( $ ascDev - > getMonitoredDevs ) } ;
2018-09-07 14:10:46 +02:00
my $ notifyDevString = $ hash - > { NOTIFYDEV } ;
2018-10-14 18:19:23 +02:00
while ( each % { $ hash - > { monitoredDevs } } ) {
2018-10-19 20:13:01 +02:00
$ notifyDevString . = ',' . $ _ ;
2018-08-16 10:37:09 +02:00
}
2018-10-14 18:19:23 +02:00
$ hash - > { NOTIFYDEV } = $ notifyDevString ;
2018-08-16 10:37:09 +02:00
}
2018-10-14 18:19:23 +02:00
readingsSingleUpdate ( $ hash , 'userAttrList' , 'rolled out' , 1 ) ;
2018-08-15 10:27:53 +02:00
}
2018-08-29 14:58:10 +02:00
## Die Funktion schreibt in das Moduldevice Readings welche Rolläden in welchen Räumen erfasst wurden.
2018-08-15 10:27:53 +02:00
sub WriteReadingsShuttersList ($) {
2018-10-14 18:19:23 +02:00
my $ hash = shift ;
my $ name = $ hash - > { NAME } ;
2018-08-15 10:27:53 +02:00
2018-10-14 18:19:23 +02:00
CommandDeleteReading ( undef , $ name . ' room_.*' ) ;
2018-08-15 10:27:53 +02:00
readingsBeginUpdate ( $ hash ) ;
2018-10-14 18:19:23 +02:00
foreach ( @ { $ hash - > { helper } { shuttersList } } ) {
readingsBulkUpdate (
$ hash ,
'room_' . makeReadingName ( AttrVal ( $ _ , 'room' , 'unsorted' ) ) ,
ReadingsVal (
$ name ,
'room_' . makeReadingName ( AttrVal ( $ _ , 'room' , 'unsorted' ) ) ,
''
)
. ','
. $ _
)
if (
ReadingsVal (
$ name ,
'room_' . makeReadingName ( AttrVal ( $ _ , 'room' , 'unsorted' ) ) ,
'none'
) ne 'none'
) ;
readingsBulkUpdate ( $ hash ,
'room_' . makeReadingName ( AttrVal ( $ _ , 'room' , 'unsorted' ) ) , $ _ )
if (
ReadingsVal (
$ name ,
'room_' . makeReadingName ( AttrVal ( $ _ , 'room' , 'unsorted' ) ) ,
'none'
) eq 'none'
) ;
2018-08-15 10:27:53 +02:00
}
2018-10-14 18:19:23 +02:00
readingsBulkUpdate ( $ hash , 'state' , 'active' ) ;
readingsEndUpdate ( $ hash , 0 ) ;
2018-08-15 10:27:53 +02:00
}
2018-08-31 09:32:16 +02:00
sub UserAttributs_Readings_ForShutters ($$) {
2018-10-14 18:19:23 +02:00
my ( $ hash , $ cmd ) = @ _ ;
my $ name = $ hash - > { NAME } ;
2018-08-15 10:27:53 +02:00
2018-10-14 18:19:23 +02:00
while ( my ( $ attrib , $ attribValue ) = each % { userAttrList } ) {
foreach ( @ { $ hash - > { helper } { shuttersList } } ) {
addToDevAttrList ( $ _ , $ attrib )
; ## fhem.pl bietet eine Funktion um ein userAttr Attribut zu befüllen. Wir schreiben also in den Attribut userAttr alle unsere Attribute rein. Pro Rolladen immer ein Attribut pro Durchlauf
2018-08-29 14:58:10 +02:00
## Danach werden die Attribute die im userAttr stehen gesetzt und mit default Werten befüllt
2019-04-04 19:11:23 +02:00
## CommandAttr hat nicht funktioniert. Führte zu Problemen
2019-04-09 12:13:46 +02:00
## https://github.com/LeonGaultier/fhem-AutoShuttersControl/commit/e33d3cc7815031b087736c1054b98c57817e7083
2018-10-14 18:19:23 +02:00
if ( $ cmd eq 'add' ) {
if ( ref ( $ attribValue ) ne 'ARRAY' ) {
$ attr { $ _ } { ( split ( ':' , $ attrib ) ) [ 0 ] } = $ attribValue
if (
2019-04-25 21:34:46 +02:00
not defined ( $ attr { $ _ } { ( split ( ':' , $ attrib ) ) [ 0 ] } )
2019-04-25 17:15:56 +02:00
and $ attribValue ne '-' ) ;
2018-10-14 18:19:23 +02:00
}
else {
$ attr { $ _ } { ( split ( ':' , $ attrib ) ) [ 0 ] } =
$ attribValue - > [ AttrVal ( $ _ , 'ASC' , 2 ) ]
if (
2019-04-25 21:34:46 +02:00
not defined ( $ attr { $ _ } { ( split ( ':' , $ attrib ) ) [ 0 ] } )
2019-04-25 17:15:56 +02:00
and $ attrib eq 'ASC_Pos_Reading' ) ;
2018-09-03 22:19:25 +02:00
}
2019-05-03 13:36:39 +02:00
### associatedWith damit man sieht das der Rollladen mit einem ASC Device verbunden ist
my $ associatedString =
ReadingsVal ( $ _ , 'associatedWith' , 'none' ) ;
if ( $ associatedString ne 'none' ) {
my % hash ;
% hash = map { ( $ _ = > 1 ) }
split ( ',' , "$associatedString,$name" ) ;
readingsSingleUpdate ( $ defs { $ _ } ,
'associatedWith' , join ( ',' , sort keys % hash ) , 0 ) ;
}
else {
readingsSingleUpdate ( $ defs { $ _ } ,
'associatedWith' , $ name , 0 ) ;
}
#######################################
2018-10-14 18:19:23 +02:00
}
2019-03-07 17:58:30 +01:00
## Oder das Attribut wird wieder gelöscht.
2018-10-14 18:19:23 +02:00
elsif ( $ cmd eq 'del' ) {
2018-10-17 09:50:11 +02:00
$ shutters - > setShuttersDev ( $ _ ) ;
RemoveInternalTimer ( $ shutters - > getInTimerFuncHash ) ;
2018-10-14 18:19:23 +02:00
CommandDeleteReading ( undef ,
$ _ . ' .?(AutoShuttersControl|ASC)_.*' ) ;
CommandDeleteAttr ( undef , $ _ . ' ASC' ) ;
delFromDevAttrList ( $ _ , $ attrib ) ;
2019-05-03 13:36:39 +02:00
### associatedWith wird wieder entfernt
my $ associatedString =
ReadingsVal ( $ _ , 'associatedWith' , 'none' ) ;
my % hash ;
% hash = map { ( $ _ = > 1 ) }
grep { " $name " !~ m/ $_ / }
split ( ',' , "$associatedString,$name" ) ;
if ( keys % hash > 1 ) {
readingsSingleUpdate ( $ defs { $ _ } ,
'associatedWith' , join ( ',' , sort keys % hash ) , 0 ) ;
}
else { CommandDeleteReading ( undef , $ _ . ' associatedWith' ) ; }
###################################
2018-08-16 10:37:09 +02:00
}
2018-08-15 10:27:53 +02:00
}
}
}
2018-08-29 14:58:10 +02:00
## Fügt dem NOTIFYDEV Hash weitere Devices hinzu
2018-08-27 11:08:08 +02:00
sub AddNotifyDev ($@) {
2019-03-04 08:40:58 +01:00
### Beispielaufruf: AddNotifyDev( $hash, $3, $1, $2 ) if ( $3 ne 'none' );
2018-10-14 18:19:23 +02:00
my ( $ hash , $ dev , $ shuttersDev , $ shuttersAttr ) = @ _ ;
2019-04-09 12:13:46 +02:00
$ dev = ( split ( ':' , $ dev ) ) [ 0 ] ;
my ( $ key , $ value ) = split ( ':' , ( split ( ' ' , $ dev ) ) [ 0 ] , 2 )
; ## Wir versuchen die Device Attribute anders zu setzen. device=DEVICE reading=READING
2019-03-06 15:53:48 +01:00
$ dev = $ key ;
2019-03-07 17:58:30 +01:00
2018-10-14 18:19:23 +02:00
my $ name = $ hash - > { NAME } ;
2019-03-07 17:58:30 +01:00
2018-10-14 18:19:23 +02:00
my $ notifyDev = $ hash - > { NOTIFYDEV } ;
2019-03-06 15:53:48 +01:00
$ notifyDev = '' if ( ! $ notifyDev ) ;
2018-08-16 10:37:09 +02:00
2019-03-06 15:53:48 +01:00
my % hash ;
2018-10-14 18:19:23 +02:00
% hash = map { ( $ _ = > 1 ) }
2019-05-03 13:36:39 +02:00
split ( ',' , "$notifyDev,$dev" ) ;
2018-08-29 14:58:10 +02:00
2019-05-03 13:36:39 +02:00
$ hash - > { NOTIFYDEV } = join ( ',' , sort keys % hash ) ;
2018-10-14 18:19:23 +02:00
my @ devs = split ( ',' , $ dev ) ;
foreach ( @ devs ) {
$ hash - > { monitoredDevs } { $ _ } { $ shuttersDev } = $ shuttersAttr ;
2018-09-30 21:05:30 +02:00
}
2018-10-14 18:19:23 +02:00
readingsSingleUpdate ( $ hash , '.monitoredDevs' ,
eval { encode_json ( $ hash - > { monitoredDevs } ) } , 0 ) ;
2018-08-16 10:37:09 +02:00
}
2018-08-29 14:58:10 +02:00
## entfernt aus dem NOTIFYDEV Hash Devices welche als Wert in Attributen steckten
2018-09-30 21:05:30 +02:00
sub DeleteNotifyDev ($@) {
2018-10-14 18:19:23 +02:00
my ( $ hash , $ shuttersDev , $ shuttersAttr ) = @ _ ;
my $ name = $ hash - > { NAME } ;
2018-08-16 10:37:09 +02:00
2018-10-14 18:19:23 +02:00
my $ notifyDevs =
ExtractNotifyDevFromEvent ( $ hash , $ shuttersDev , $ shuttersAttr ) ;
2018-08-27 11:08:08 +02:00
2018-10-14 18:19:23 +02:00
foreach my $ notifyDev ( keys ( % { $ notifyDevs } ) ) {
Log3 ( $ name , 4 ,
"AutoShuttersControl ($name) - DeleteNotifyDev - NotifyDev: "
. $ _ ) ;
2018-09-30 21:05:30 +02:00
delete $ hash - > { monitoredDevs } { $ notifyDev } { $ shuttersDev } ;
2018-08-27 11:08:08 +02:00
2018-10-14 18:19:23 +02:00
if ( ! keys % { $ hash - > { monitoredDevs } { $ notifyDev } } ) {
2018-09-30 21:05:30 +02:00
delete $ hash - > { monitoredDevs } { $ notifyDev } ;
2018-10-14 18:19:23 +02:00
my $ notifyDevString = $ hash - > { NOTIFYDEV } ;
2019-05-03 13:36:39 +02:00
$ notifyDevString = '' if ( ! $ notifyDevString ) ;
2018-09-30 21:05:30 +02:00
my % hash ;
2018-10-14 18:19:23 +02:00
% hash = map { ( $ _ = > 1 ) }
grep { " $notifyDev " !~ m/ $_ / }
2019-05-03 13:36:39 +02:00
split ( ',' , "$notifyDevString,$notifyDev" ) ;
2018-09-30 21:05:30 +02:00
2019-05-03 13:36:39 +02:00
$ hash - > { NOTIFYDEV } = join ( ',' , sort keys % hash ) ;
2018-09-30 21:05:30 +02:00
}
2018-09-01 08:14:42 +02:00
}
2018-10-14 18:19:23 +02:00
readingsSingleUpdate ( $ hash , '.monitoredDevs' ,
eval { encode_json ( $ hash - > { monitoredDevs } ) } , 0 ) ;
2018-08-27 11:08:08 +02:00
}
2018-08-29 14:58:10 +02:00
## Sub zum steuern der Rolläden bei einem Fenster Event
2018-11-12 12:56:18 +01:00
sub EventProcessingWindowRec ($@) {
2018-10-14 18:19:23 +02:00
my ( $ hash , $ shuttersDev , $ events ) = @ _ ;
my $ name = $ hash - > { NAME } ;
2018-08-29 14:58:10 +02:00
2019-06-10 17:55:53 +02:00
if ( $ events =~ m #.*state:.*?([Oo]pen(?>ed)?|[Cc]losed?|tilt(?>ed)?)#
2019-05-24 11:36:06 +02:00
and IsAfterShuttersManualBlocking ( $ shuttersDev ) )
2019-01-27 14:19:51 +01:00
{
2019-05-24 11:49:40 +02:00
my $ match = $ 1 ;
2019-05-24 11:22:58 +02:00
ASC_Debug ( 'EventProcessingWindowRec: '
2019-05-24 11:36:06 +02:00
. $ shutters - > getShuttersDev
. ' - RECEIVED EVENT: '
. $ events
. ' - IDENTIFIED EVENT: '
. $ 1
. ' - STORED EVENT: '
. $ match ) ;
2019-05-24 11:22:58 +02:00
2018-10-10 10:43:42 +02:00
$ shutters - > setShuttersDev ( $ shuttersDev ) ;
2019-02-08 08:13:45 +01:00
my $ homemode = $ shutters - > getRoommatesStatus ;
$ homemode = $ ascDev - > getResidentsStatus if ( $ homemode eq 'none' ) ;
2018-11-21 21:56:29 +01:00
#### Hardware Lock der Rollläden
2018-11-28 13:11:32 +01:00
$ shutters - > setHardLockOut ( 'off' )
2019-06-10 16:06:17 +02:00
if ( $ match =~ /[Cc]lose/ and $ shutters - > getShuttersPlace eq 'terrace' ) ;
2018-11-28 13:11:32 +01:00
$ shutters - > setHardLockOut ( 'on' )
2019-06-10 16:06:17 +02:00
if ( $ match =~ /[Oo]pen/
2019-04-09 12:13:46 +02:00
and $ shutters - > getShuttersPlace eq 'terrace' ) ;
2018-11-28 13:11:32 +01:00
2019-06-04 06:37:38 +02:00
# my $queryShuttersPosWinRecTilted = (
# $shutters->getShuttersPosCmdValueNegate
# ? $shutters->getStatus > $shutters->getVentilatePos
# : $shutters->getStatus < $shutters->getVentilatePos
# );
# my $queryShuttersPosWinRecComfort = (
# $shutters->getShuttersPosCmdValueNegate
# ? $shutters->getStatus > $shutters->getComfortOpenPos
# : $shutters->getStatus < $shutters->getComfortOpenPos
# );
2019-04-30 09:56:19 +02:00
2019-04-30 09:53:45 +02:00
ASC_Debug ( 'EventProcessingWindowRec: '
2019-04-30 09:56:19 +02:00
. $ shutters - > getShuttersDev
. ' - HOMEMODE: '
. $ homemode
2019-05-27 13:45:38 +02:00
. ' QueryShuttersPosWinRecTilted:'
2019-06-04 06:37:38 +02:00
. $ shutters - > getQueryShuttersPos ( $ shutters - > getVentilatePos )
2019-04-30 09:56:19 +02:00
. ' QueryShuttersPosWinRecComfort: '
2019-06-04 06:37:38 +02:00
. $ shutters - > getQueryShuttersPos ( $ shutters - > getComfortOpenPos )
) ;
2018-10-14 18:19:23 +02:00
2019-04-09 12:13:46 +02:00
if (
2019-06-10 14:23:00 +02:00
$ match =~ /[Cc]lose/
2019-04-20 21:53:05 +02:00
and IsAfterShuttersTimeBlocking ( $ shuttersDev )
2019-04-09 12:13:46 +02:00
and ( $ shutters - > getStatus == $ shutters - > getVentilatePos
or $ shutters - > getStatus == $ shutters - > getComfortOpenPos
or $ shutters - > getStatus == $ shutters - > getOpenPos )
)
2019-01-28 18:20:19 +01:00
{
2019-05-01 10:11:53 +02:00
ASC_Debug ( 'EventProcessingWindowRec: '
2019-05-01 11:45:46 +02:00
. $ shutters - > getShuttersDev
. ' Event Closed' ) ;
2019-03-12 23:02:02 +01:00
if (
2019-05-01 11:45:46 +02:00
IsDay ( $ shuttersDev )
2019-04-30 09:56:19 +02:00
and ( ( $ homemode ne 'asleep' and $ homemode ne 'gotosleep' )
2019-03-12 23:02:02 +01:00
or $ homemode eq 'none' )
2019-04-30 09:53:45 +02:00
and $ shutters - > getModeUp ne 'absent'
and $ shutters - > getModeUp ne 'off'
2019-04-09 12:13:46 +02:00
)
2019-03-12 23:02:02 +01:00
{
2019-05-01 11:45:46 +02:00
if ( $ shutters - > getShadingStatus eq 'in'
and $ shutters - > getShuttersPlace eq 'terrace'
and $ shutters - > getShadingPos != $ shutters - > getStatus )
2019-05-01 10:11:53 +02:00
{
$ shutters - > setLastDrive ( 'shading in' ) ;
$ shutters - > setNoOffset ( 1 ) ;
2019-05-01 11:45:46 +02:00
$ shutters - > setDriveCmd ( $ shutters - > getShadingPos ) ;
2019-05-01 10:11:53 +02:00
}
elsif ( $ shutters - > getStatus != $ shutters - > getOpenPos ) {
$ shutters - > setLastDrive ( 'window closed at day' ) ;
$ shutters - > setNoOffset ( 1 ) ;
2019-05-20 13:52:05 +02:00
$ shutters - > setDriveCmd ( $ shutters - > getOpenPos ) ;
2019-05-01 10:11:53 +02:00
}
2019-03-12 23:02:02 +01:00
}
2018-11-28 13:11:32 +01:00
2019-04-30 09:56:19 +02:00
elsif (
$ shutters - > getModeUp ne 'absent'
2019-04-30 09:53:45 +02:00
and $ shutters - > getModeUp ne 'off'
2019-04-30 09:56:19 +02:00
and ( not IsDay ( $ shuttersDev )
or $ homemode eq 'asleep'
or $ homemode eq 'gotosleep' )
2019-04-30 09:53:45 +02:00
and $ shutters - > getModeDown ne 'absent'
and $ shutters - > getModeDown ne 'off'
)
2019-03-12 23:02:02 +01:00
{
2019-04-30 09:53:45 +02:00
$ shutters - > setLastDrive ( 'window closed at night' ) ;
2019-04-02 19:28:54 +02:00
$ shutters - > setNoOffset ( 1 ) ;
2019-04-09 12:13:46 +02:00
$ shutters - > setDriveCmd ( $ shutters - > getClosedPos ) ;
2018-11-17 18:23:10 +01:00
}
2018-10-14 18:19:23 +02:00
}
elsif (
(
2019-05-24 11:36:06 +02:00
$ match =~ /tilt/
2019-06-10 14:23:00 +02:00
or ( $ match =~ /[Oo]pen/
2019-04-09 12:13:46 +02:00
and $ shutters - > getSubTyp eq 'twostate' )
2018-10-14 18:19:23 +02:00
)
and $ shutters - > getVentilateOpen eq 'on'
2019-06-04 06:37:38 +02:00
and $ shutters - > getQueryShuttersPos ( $ shutters - > getVentilatePos )
2018-10-14 18:19:23 +02:00
)
{
2018-11-18 16:49:09 +01:00
$ shutters - > setLastDrive ( 'ventilate - window open' ) ;
2019-04-02 19:28:54 +02:00
$ shutters - > setNoOffset ( 1 ) ;
2019-04-09 12:13:46 +02:00
$ shutters - > setDriveCmd ( $ shutters - > getVentilatePos ) ;
2018-10-14 18:19:23 +02:00
}
2019-06-10 14:40:24 +02:00
elsif ( $ match =~ /[Oo]pen/
2019-03-12 23:02:02 +01:00
and $ shutters - > getSubTyp eq 'threestate' )
2018-10-14 18:19:23 +02:00
{
2019-03-12 23:02:02 +01:00
my $ posValue ;
my $ setLastDrive ;
2019-04-09 12:13:46 +02:00
if ( $ ascDev - > getAutoShuttersControlComfort eq 'on'
2019-06-04 06:37:38 +02:00
and
$ shutters - > getQueryShuttersPos ( $ shutters - > getComfortOpenPos ) )
2019-03-12 23:02:02 +01:00
{
2019-04-09 12:13:46 +02:00
$ posValue = $ shutters - > getComfortOpenPos ;
2019-03-12 23:02:02 +01:00
$ setLastDrive = 'comfort - window open' ;
}
2019-06-04 06:37:38 +02:00
elsif ( $ shutters - > getQueryShuttersPos ( $ shutters - > getVentilatePos )
2019-04-09 12:13:46 +02:00
and $ shutters - > getVentilateOpen eq 'on' )
2019-03-12 23:02:02 +01:00
{
2019-04-09 12:13:46 +02:00
$ posValue = $ shutters - > getVentilatePos ;
2019-03-12 23:02:02 +01:00
$ setLastDrive = 'ventilate - window open' ;
}
2019-04-09 12:13:46 +02:00
2019-04-02 19:28:54 +02:00
if ( defined ( $ posValue ) and $ posValue ) {
$ shutters - > setLastDrive ( $ setLastDrive ) ;
$ shutters - > setNoOffset ( 1 ) ;
$ shutters - > setDriveCmd ( $ posValue ) ;
}
2018-08-29 14:58:10 +02:00
}
2018-08-27 11:08:08 +02:00
}
}
2018-08-29 14:58:10 +02:00
## Sub zum steuern der Rolladen bei einem Bewohner/Roommate Event
2018-11-12 12:56:18 +01:00
sub EventProcessingRoommate ($@) {
2018-10-14 18:19:23 +02:00
my ( $ hash , $ shuttersDev , $ events ) = @ _ ;
my $ name = $ hash - > { NAME } ;
2018-11-07 08:22:11 +01:00
2018-10-10 10:43:42 +02:00
$ shutters - > setShuttersDev ( $ shuttersDev ) ;
2018-10-14 18:19:23 +02:00
my $ reading = $ shutters - > getRoommatesReading ;
2018-10-30 08:18:09 +01:00
if ( $ events =~ m #$reading:\s(absent|gotosleep|asleep|awoken|home)# ) {
2018-10-14 18:19:23 +02:00
Log3 ( $ name , 4 ,
2018-11-19 09:06:50 +01:00
"AutoShuttersControl ($name) - EventProcessingRoommate: "
. $ shutters - > getRoommatesReading ) ;
2018-10-14 18:19:23 +02:00
Log3 ( $ name , 4 ,
2018-11-19 09:06:50 +01:00
"AutoShuttersControl ($name) - EventProcessingRoommate: $shuttersDev und Events $events"
2018-10-14 18:19:23 +02:00
) ;
2019-04-09 12:13:46 +02:00
my $ getModeUp = $ shutters - > getModeUp ;
my $ getModeDown = $ shutters - > getModeDown ;
2019-03-04 10:40:31 +01:00
my $ getRoommatesLastStatus = $ shutters - > getRoommatesLastStatus ;
2018-10-30 19:10:50 +01:00
2018-10-30 08:18:09 +01:00
if (
2018-10-30 19:10:50 +01:00
( $ 1 eq 'home' or $ 1 eq 'awoken' )
and ( $ shutters - > getRoommatesStatus eq 'home'
or $ shutters - > getRoommatesStatus eq 'awoken' )
and $ ascDev - > getAutoShuttersControlMorning eq 'on'
2019-03-04 10:10:53 +01:00
and ( $ getModeUp eq 'home'
2019-04-09 12:13:46 +02:00
or $ getModeUp eq 'always'
or $ getModeDown eq 'home'
or $ getModeDown eq 'always' )
and IsAfterShuttersManualBlocking ( $ shuttersDev )
)
2018-10-30 08:18:09 +01:00
{
2018-11-15 15:01:34 +01:00
Log3 ( $ name , 4 ,
2018-11-19 09:06:50 +01:00
"AutoShuttersControl ($name) - EventProcessingRoommate_1: $shuttersDev und Events $events"
) ;
2018-10-30 19:10:50 +01:00
if (
2019-04-09 12:13:46 +02:00
(
2019-03-04 10:10:53 +01:00
$ getRoommatesLastStatus eq 'asleep'
or $ getRoommatesLastStatus eq 'awoken'
2019-04-09 12:13:46 +02:00
)
2019-04-20 21:53:05 +02:00
and IsDay ( $ shuttersDev )
and IsAfterShuttersTimeBlocking ( $ shuttersDev )
2019-04-09 12:13:46 +02:00
and ( $ getModeUp eq 'home'
2019-03-04 10:10:53 +01:00
or $ getModeUp eq 'always' )
2019-04-09 12:13:46 +02:00
)
2018-10-30 08:18:09 +01:00
{
2018-11-15 15:01:34 +01:00
Log3 ( $ name , 4 ,
2018-11-19 09:06:50 +01:00
"AutoShuttersControl ($name) - EventProcessingRoommate_2: $shuttersDev und Events $events"
) ;
2018-10-30 08:18:09 +01:00
$ shutters - > setLastDrive ( 'roommate awoken' ) ;
2018-10-30 19:10:50 +01:00
ShuttersCommandSet ( $ hash , $ shuttersDev ,
$ shutters - > getOpenPos ) ;
2018-10-30 08:18:09 +01:00
}
2018-10-30 19:10:50 +01:00
if (
2019-04-09 12:13:46 +02:00
(
2019-03-04 10:10:53 +01:00
$ getRoommatesLastStatus eq 'absent'
or $ getRoommatesLastStatus eq 'gone'
2019-04-26 23:07:30 +02:00
# or $getRoommatesLastStatus eq 'home'
2019-04-09 12:13:46 +02:00
)
and $ shutters - > getRoommatesStatus eq 'home'
)
2018-10-30 08:18:09 +01:00
{
2019-04-09 12:13:46 +02:00
if (
2019-04-20 21:53:05 +02:00
not IsDay ( $ shuttersDev )
and IsAfterShuttersTimeBlocking ( $ shuttersDev )
2019-03-04 10:10:53 +01:00
and ( $ getModeDown eq 'home'
or $ getModeDown eq 'always' )
2019-04-09 12:13:46 +02:00
)
2018-12-07 12:57:45 +01:00
{
2018-10-30 15:26:04 +01:00
my $ position ;
2018-11-15 15:01:34 +01:00
$ shutters - > setLastDrive ( 'roommate home' ) ;
2018-11-19 09:06:50 +01:00
2018-10-30 15:26:04 +01:00
if ( CheckIfShuttersWindowRecOpen ( $ shuttersDev ) == 0
or $ shutters - > getVentilateOpen eq 'off' )
{
$ position = $ shutters - > getClosedPos ;
}
2018-11-15 15:01:34 +01:00
else {
$ position = $ shutters - > getVentilatePos ;
2018-11-19 09:06:50 +01:00
$ shutters - > setLastDrive (
$ shutters - > getLastDrive . ' - ventilate mode' ) ;
2018-11-15 15:01:34 +01:00
}
2018-11-19 09:06:50 +01:00
2018-10-30 15:26:04 +01:00
ShuttersCommandSet ( $ hash , $ shuttersDev , $ position ) ;
}
2019-04-09 12:13:46 +02:00
elsif (
2019-04-20 21:53:05 +02:00
IsDay ( $ shuttersDev )
2018-12-07 12:57:45 +01:00
and $ shutters - > getStatus == $ shutters - > getClosedPos
2019-04-20 21:53:05 +02:00
and IsAfterShuttersTimeBlocking ( $ shuttersDev )
2019-03-04 10:10:53 +01:00
and ( $ getModeUp eq 'home'
2019-04-09 12:13:46 +02:00
or $ getModeUp eq 'always' )
and not $ shutters - > getIfInShading
)
2018-10-30 19:10:50 +01:00
{
2018-10-30 15:26:04 +01:00
$ shutters - > setLastDrive ( 'roommate home' ) ;
2018-10-30 19:10:50 +01:00
ShuttersCommandSet ( $ hash , $ shuttersDev ,
$ shutters - > getOpenPos ) ;
2018-10-30 08:18:09 +01:00
}
}
2018-10-30 19:10:50 +01:00
}
elsif (
(
2019-03-04 10:10:53 +01:00
$ getModeDown eq 'always'
or $ getModeDown eq 'home'
2018-10-30 19:10:50 +01:00
)
and ( $ 1 eq 'gotosleep' or $ 1 eq 'asleep' )
and $ ascDev - > getAutoShuttersControlEvening eq 'on'
2019-03-27 11:22:06 +01:00
and IsAfterShuttersManualBlocking ( $ shuttersDev )
2018-10-30 19:10:50 +01:00
)
2018-10-14 18:19:23 +02:00
{
2018-09-13 08:11:10 +02:00
my $ position ;
2018-11-15 15:01:34 +01:00
$ shutters - > setLastDrive ( 'roommate asleep' ) ;
2018-11-19 09:06:50 +01:00
2018-10-14 18:19:23 +02:00
if ( CheckIfShuttersWindowRecOpen ( $ shuttersDev ) == 0
or $ shutters - > getVentilateOpen eq 'off' )
{
$ position = $ shutters - > getClosedPos ;
2018-09-13 08:11:10 +02:00
}
2018-11-15 15:01:34 +01:00
else {
$ position = $ shutters - > getVentilatePos ;
2018-11-19 09:06:50 +01:00
$ shutters - > setLastDrive (
$ shutters - > getLastDrive . ' - ventilate mode' ) ;
2018-11-15 15:01:34 +01:00
}
2018-10-14 18:19:23 +02:00
ShuttersCommandSet ( $ hash , $ shuttersDev , $ position ) ;
2018-09-10 08:27:11 +02:00
}
2019-03-04 10:10:53 +01:00
elsif ( $ getModeDown eq 'absent'
2018-12-05 09:09:46 +01:00
and $ 1 eq 'absent'
2019-04-20 21:53:05 +02:00
and not IsDay ( $ shuttersDev ) )
2018-10-30 08:18:09 +01:00
{
$ shutters - > setLastDrive ( 'roommate absent' ) ;
ShuttersCommandSet ( $ hash , $ shuttersDev , $ shutters - > getClosedPos ) ;
}
2018-08-28 19:49:01 +02:00
}
2018-08-27 11:08:08 +02:00
}
2018-11-12 12:56:18 +01:00
sub EventProcessingResidents ($@) {
2018-10-14 18:19:23 +02:00
my ( $ hash , $ device , $ events ) = @ _ ;
2018-10-09 18:05:55 +02:00
2019-04-09 12:13:46 +02:00
my $ name = $ device ;
my $ reading = $ ascDev - > getResidentsReading ;
2019-03-04 10:10:53 +01:00
my $ getResidentsLastStatus = $ ascDev - > getResidentsLastStatus ;
2018-10-14 18:19:23 +02:00
2019-05-24 11:31:07 +02:00
if ( $ events =~ m #$reading:\s((?:pet_[a-z]+)|(?:absent))# ) {
2018-10-14 18:19:23 +02:00
foreach my $ shuttersDev ( @ { $ hash - > { helper } { shuttersList } } ) {
2018-10-10 10:43:42 +02:00
$ shutters - > setShuttersDev ( $ shuttersDev ) ;
2019-04-09 12:13:46 +02:00
my $ getModeUp = $ shutters - > getModeUp ;
2019-03-04 10:40:31 +01:00
my $ getModeDown = $ shutters - > getModeDown ;
2018-11-28 13:07:52 +01:00
$ shutters - > setHardLockOut ( 'off' ) ;
2018-10-30 19:10:50 +01:00
if (
2018-11-03 19:01:29 +01:00
CheckIfShuttersWindowRecOpen ( $ shuttersDev ) != 0
and $ ascDev - > getSelfDefense eq 'on'
2018-10-30 19:10:50 +01:00
and $ shutters - > getSelfDefenseExclude eq 'off'
2018-11-03 19:01:29 +01:00
or (
(
2019-03-04 10:10:53 +01:00
$ getModeDown eq 'absent'
or $ getModeDown eq 'always'
2018-11-03 19:01:29 +01:00
)
2019-04-20 21:53:05 +02:00
and not IsDay ( $ shuttersDev )
and IsAfterShuttersTimeBlocking ( $ shuttersDev )
2018-11-03 19:01:29 +01:00
)
2018-10-30 19:10:50 +01:00
)
2018-10-30 15:26:04 +01:00
{
2018-11-03 19:01:29 +01:00
if ( CheckIfShuttersWindowRecOpen ( $ shuttersDev ) != 0
and $ ascDev - > getSelfDefense eq 'on'
and $ shutters - > getSelfDefenseExclude eq 'off' )
{
$ shutters - > setLastDrive ( 'selfeDefense active' ) ;
}
else { $ shutters - > setLastDrive ( 'residents absent' ) ; }
2018-10-30 15:26:04 +01:00
$ shutters - > setDriveCmd ( $ shutters - > getClosedPos ) ;
}
2018-10-14 18:19:23 +02:00
}
}
2018-10-22 08:05:19 +02:00
elsif ( $ events =~ m #$reading:\s(gone)#
and $ ascDev - > getSelfDefense eq 'on' )
{
foreach my $ shuttersDev ( @ { $ hash - > { helper } { shuttersList } } ) {
$ shutters - > setShuttersDev ( $ shuttersDev ) ;
2019-04-09 12:13:46 +02:00
my $ getModeUp = $ shutters - > getModeUp ;
2019-03-04 10:40:31 +01:00
my $ getModeDown = $ shutters - > getModeDown ;
2018-11-28 13:07:52 +01:00
$ shutters - > setHardLockOut ( 'off' ) ;
2018-10-30 15:26:04 +01:00
if ( $ shutters - > getShuttersPlace eq 'terrace' ) {
$ shutters - > setLastDrive ( 'selfeDefense terrace' ) ;
$ shutters - > setDriveCmd ( $ shutters - > getClosedPos ) ;
}
2018-10-22 08:05:19 +02:00
}
}
2018-10-27 13:36:11 +02:00
elsif (
2019-05-24 11:31:07 +02:00
$ events =~ m #$reading:\s((?:[a-z]+_)?home)#
2019-03-04 10:10:53 +01:00
and ( $ getResidentsLastStatus eq 'absent'
or $ getResidentsLastStatus eq 'gone'
or $ getResidentsLastStatus eq 'asleep'
or $ getResidentsLastStatus eq 'awoken' )
2018-10-27 13:36:11 +02:00
)
2018-10-14 18:19:23 +02:00
{
foreach my $ shuttersDev ( @ { $ hash - > { helper } { shuttersList } } ) {
2018-10-22 08:05:19 +02:00
$ shutters - > setShuttersDev ( $ shuttersDev ) ;
2019-04-09 12:13:46 +02:00
my $ getModeUp = $ shutters - > getModeUp ;
2019-03-04 10:40:31 +01:00
my $ getModeDown = $ shutters - > getModeDown ;
2018-10-30 19:10:50 +01:00
2018-11-03 19:01:29 +01:00
if (
$ shutters - > getStatus != $ shutters - > getClosedPos
2019-04-20 21:53:05 +02:00
and not IsDay ( $ shuttersDev )
2018-11-03 19:01:29 +01:00
and $ shutters - > getRoommatesStatus eq 'none'
2019-03-04 10:10:53 +01:00
and ( $ getModeDown eq 'home'
or $ getModeDown eq 'always' )
and ( $ getResidentsLastStatus ne 'asleep'
or $ getResidentsLastStatus ne 'awoken' )
2019-04-20 21:53:05 +02:00
and IsAfterShuttersTimeBlocking ( $ shuttersDev )
2018-11-03 19:01:29 +01:00
)
2018-10-30 08:18:09 +01:00
{
$ shutters - > setLastDrive ( 'residents home' ) ;
$ shutters - > setDriveCmd ( $ shutters - > getClosedPos ) ;
}
2019-05-20 09:47:28 +02:00
elsif (
$ shutters - > getShadingMode eq 'home'
and IsDay ( $ shuttersDev )
and $ shutters - > getIfInShading
and $ shutters - > getStatus != $ shutters - > getShadingPos
and not ( CheckIfShuttersWindowRecOpen ( $ shuttersDev ) == 2
and $ shutters - > getShuttersPlace eq 'terrace' )
)
{
$ shutters - > setLastDrive ( 'shading in' ) ;
$ shutters - > setDriveCmd ( $ shutters - > getShadingPos ) ;
}
2019-05-28 15:44:44 +02:00
elsif (
$ shutters - > getShadingMode eq 'absent'
and IsDay ( $ shuttersDev )
and $ shutters - > getIfInShading
and $ shutters - > getStatus == $ shutters - > getShadingPos
and not ( CheckIfShuttersWindowRecOpen ( $ shuttersDev ) == 2
and $ shutters - > getShuttersPlace eq 'terrace' )
)
{
$ shutters - > setLastDrive ( 'shading out' ) ;
$ shutters - > setDriveCmd ( $ shutters - > getLastPos ) ;
}
2018-10-30 19:10:50 +01:00
elsif (
$ ascDev - > getSelfDefense eq 'on'
2018-10-30 08:18:09 +01:00
and CheckIfShuttersWindowRecOpen ( $ shuttersDev ) != 0
2018-10-27 13:36:11 +02:00
and $ shutters - > getSelfDefenseExclude eq 'off'
2019-03-04 10:10:53 +01:00
or ( $ getResidentsLastStatus eq 'gone'
2018-10-27 13:36:11 +02:00
and $ shutters - > getShuttersPlace eq 'terrace' )
2019-03-04 10:10:53 +01:00
and ( $ getModeUp eq 'absent'
or $ getModeUp eq 'off' )
2019-03-31 17:17:56 +02:00
and not $ shutters - > getIfInShading
2018-10-30 08:18:09 +01:00
)
2018-10-30 19:10:50 +01:00
{
2018-10-30 08:18:09 +01:00
$ shutters - > setLastDrive ( 'selfeDefense inactive' ) ;
$ shutters - > setDriveCmd ( $ shutters - > getLastPos ) ;
2018-11-28 13:11:32 +01:00
$ shutters - > setHardLockOut ( 'on' )
if ( CheckIfShuttersWindowRecOpen ( $ shuttersDev ) == 2
and $ shutters - > getShuttersPlace eq 'terrace' ) ;
2018-10-30 08:18:09 +01:00
}
2018-11-03 19:01:29 +01:00
elsif (
$ shutters - > getStatus == $ shutters - > getClosedPos
2019-04-20 21:53:05 +02:00
and IsDay ( $ shuttersDev )
2018-11-03 19:01:29 +01:00
and $ shutters - > getRoommatesStatus eq 'none'
2019-03-04 10:10:53 +01:00
and ( $ getModeUp eq 'home'
or $ getModeUp eq 'always' )
2019-04-20 21:53:05 +02:00
and IsAfterShuttersTimeBlocking ( $ shuttersDev )
2019-03-31 17:17:56 +02:00
and not $ shutters - > getIfInShading
2018-11-03 19:01:29 +01:00
)
{
2019-03-04 10:10:53 +01:00
if ( $ getResidentsLastStatus eq 'asleep'
or $ getResidentsLastStatus eq 'awoken' )
2018-11-03 19:01:29 +01:00
{
$ shutters - > setLastDrive ( 'residents awoken' ) ;
}
else { $ shutters - > setLastDrive ( 'residents home' ) ; }
$ shutters - > setDriveCmd ( $ shutters - > getOpenPos ) ;
}
2018-10-27 13:36:11 +02:00
}
}
}
2018-11-12 12:56:18 +01:00
sub EventProcessingRain ($@) {
2018-10-27 13:36:11 +02:00
my ( $ hash , $ device , $ events ) = @ _ ;
2018-11-08 08:32:47 +01:00
my $ name = $ device ;
2018-10-27 13:36:11 +02:00
my $ reading = $ ascDev - > getRainSensorReading ;
2019-04-29 11:04:27 +02:00
if ( $ events =~ m #$reading:\s(\d+(\.\d+)?|rain|dry)# ) {
2019-03-06 15:53:48 +01:00
my $ val ;
2019-03-07 10:52:23 +01:00
my $ triggerMax = $ ascDev - > getRainTriggerMax ;
2019-03-06 15:53:48 +01:00
my $ triggerMin = $ ascDev - > getRainTriggerMin ;
2019-04-09 12:13:46 +02:00
my $ closedPos = $ ascDev - > getRainSensorShuttersClosedPos ;
2019-03-07 10:52:23 +01:00
if ( $ 1 eq 'rain' ) { $ val = $ triggerMax + 1 }
elsif ( $ 1 eq 'dry' ) { $ val = $ triggerMin }
2018-10-28 18:12:40 +01:00
else { $ val = $ 1 }
foreach my $ shuttersDev ( @ { $ hash - > { helper } { shuttersList } } ) {
$ shutters - > setShuttersDev ( $ shuttersDev ) ;
2019-04-29 13:22:37 +02:00
next
2019-04-29 13:24:01 +02:00
if ( $ shutters - > getRainProtection eq 'off' ) ;
2019-04-29 13:22:37 +02:00
2019-03-06 15:53:48 +01:00
if ( $ val > $ triggerMax
2019-04-09 12:13:46 +02:00
and $ shutters - > getStatus != $ closedPos
2019-05-02 11:49:22 +02:00
and IsAfterShuttersManualBlocking ( $ shuttersDev )
2019-06-03 07:44:35 +02:00
and $ shutters - > getRainProtectionStatus eq 'unprotected' )
2018-10-28 18:12:40 +01:00
{
2019-06-03 07:44:35 +02:00
$ shutters - > setLastDrive ( 'rain protected' ) ;
2019-04-09 12:13:46 +02:00
$ shutters - > setDriveCmd ( $ closedPos ) ;
2019-06-03 07:44:35 +02:00
$ shutters - > setRainProtectionStatus ( 'protected' ) ;
2018-10-27 13:36:11 +02:00
}
2019-04-09 12:13:46 +02:00
elsif ( ( $ val == 0 or $ val < $ triggerMax )
and $ shutters - > getStatus == $ closedPos
2019-05-02 11:49:22 +02:00
and IsAfterShuttersManualBlocking ( $ shuttersDev )
2019-06-03 07:44:35 +02:00
and $ shutters - > getRainProtectionStatus eq 'protected' )
2018-10-28 18:12:40 +01:00
{
2019-06-03 07:44:35 +02:00
$ shutters - > setLastDrive ( 'rain un-protected' ) ;
2018-10-28 18:12:40 +01:00
$ shutters - > setDriveCmd ( $ shutters - > getLastPos ) ;
2019-06-03 07:44:35 +02:00
$ shutters - > setRainProtectionStatus ( 'unprotected' ) ;
2018-10-27 13:36:11 +02:00
}
2018-10-09 18:05:55 +02:00
}
}
}
2019-02-26 12:04:10 +01:00
sub EventProcessingWind ($@) {
2019-02-28 09:05:23 +01:00
my ( $ hash , $ shuttersDev , $ events ) = @ _ ;
my $ name = $ hash - > { NAME } ;
$ shutters - > setShuttersDev ( $ shuttersDev ) ;
2019-02-26 12:04:10 +01:00
2019-03-04 08:40:58 +01:00
my $ reading = $ ascDev - > getWindSensorReading ;
2019-04-29 11:04:27 +02:00
if ( $ events =~ m #$reading:\s(\d+(\.\d+)?)# ) {
2019-02-26 12:04:10 +01:00
foreach my $ shuttersDev ( @ { $ hash - > { helper } { shuttersList } } ) {
$ shutters - > setShuttersDev ( $ shuttersDev ) ;
2019-04-25 17:15:56 +02:00
ASC_Debug ( 'EventProcessingWind: '
2019-04-25 21:34:46 +02:00
. $ shutters - > getShuttersDev
. ' - WindProtection1: '
2019-04-28 22:13:27 +02:00
. $ shutters - > getWindProtectionStatus
2019-04-25 21:34:46 +02:00
. ' WindMax1: '
. $ shutters - > getWindMax
. ' WindMin1: '
. $ shutters - > getWindMin
. ' Bekommender Wert1: '
. $ 1 ) ;
2019-04-25 17:15:56 +02:00
2019-04-09 12:13:46 +02:00
next
2019-04-28 22:13:27 +02:00
if (
(
CheckIfShuttersWindowRecOpen ( $ shuttersDev ) != 0
and $ shutters - > getShuttersPlace eq 'terrace'
)
or $ shutters - > getWindProtection eq 'off'
) ;
2019-02-28 09:05:23 +01:00
2019-04-09 12:13:46 +02:00
if ( $ 1 > $ shutters - > getWindMax
2019-06-03 07:44:35 +02:00
and $ shutters - > getWindProtectionStatus eq 'unprotected' )
2019-02-26 12:04:10 +01:00
{
2019-06-03 07:44:35 +02:00
$ shutters - > setLastDrive ( 'wind protected' ) ;
2019-04-09 12:13:46 +02:00
$ shutters - > setDriveCmd ( $ shutters - > getWindPos ) ;
2019-06-03 07:44:35 +02:00
$ shutters - > setWindProtectionStatus ( 'protected' ) ;
2019-02-26 12:04:10 +01:00
}
2019-02-28 09:05:23 +01:00
elsif ( $ 1 < $ shutters - > getWindMin
2019-06-03 07:44:35 +02:00
and $ shutters - > getWindProtectionStatus eq 'protected' )
2019-02-26 12:04:10 +01:00
{
2019-06-03 07:44:35 +02:00
$ shutters - > setLastDrive ( 'wind un-protected' ) ;
2019-02-26 12:04:10 +01:00
$ shutters - > setDriveCmd ( $ shutters - > getLastPos ) ;
2019-06-03 07:44:35 +02:00
$ shutters - > setWindProtectionStatus ( 'unprotected' ) ;
2019-02-26 12:04:10 +01:00
}
2019-04-25 21:34:46 +02:00
2019-04-25 17:15:56 +02:00
ASC_Debug ( 'EventProcessingWind: '
2019-04-25 21:34:46 +02:00
. $ shutters - > getShuttersDev
. ' - WindProtection2: '
2019-04-28 22:13:27 +02:00
. $ shutters - > getWindProtectionStatus
2019-04-25 21:34:46 +02:00
. ' WindMax2: '
. $ shutters - > getWindMax
. ' WindMin2: '
. $ shutters - > getWindMin
. ' Bekommender Wert2: '
. $ 1 ) ;
2019-02-26 12:04:10 +01:00
}
}
}
2019-02-28 09:05:23 +01:00
##########
2019-02-26 12:04:10 +01:00
2018-11-12 12:56:18 +01:00
sub EventProcessingBrightness ($@) {
2018-10-14 18:19:23 +02:00
my ( $ hash , $ shuttersDev , $ events ) = @ _ ;
my $ name = $ hash - > { NAME } ;
2018-10-12 06:32:01 +02:00
$ shutters - > setShuttersDev ( $ shuttersDev ) ;
2019-04-09 12:13:46 +02:00
ASC_Debug ( 'EventProcessingBrightness: '
. $ shutters - > getShuttersDev
. ' - Event von einem Helligkeitssensor erkannt. Verarbeitung läuft. Sollten keine weitere Meldungen aus der Funktion kommen, so befindet sich die aktuelle Zeit nicht innerhalb der Verarbeitungszeit für Sunset oder Sunrise'
) ;
2018-10-12 06:32:01 +02:00
2018-11-19 09:06:50 +01:00
return EventProcessingShadingBrightness ( $ hash , $ shuttersDev , $ events )
unless (
2019-04-09 12:13:46 +02:00
(
$ shutters - > getModeDown eq 'brightness'
or $ shutters - > getModeUp eq 'brightness'
)
or (
(
2019-04-28 07:32:48 +02:00
(
(
int ( gettimeofday ( ) / 86400 ) != int (
computeAlignTime ( '24:00' ,
$ shutters - > getTimeUpEarly ) / 86400
)
2019-05-17 14:20:57 +02:00
and (
not IsWe ( )
or ( IsWe ( )
and $ ascDev - > getSunriseTimeWeHoliday eq 'off' )
)
)
2019-04-28 07:32:48 +02:00
or (
int ( gettimeofday ( ) / 86400 ) != int (
computeAlignTime ( '24:00' ,
$ shutters - > getTimeUpWeHoliday ) / 86400
)
and IsWe ( )
and $ ascDev - > getSunriseTimeWeHoliday eq 'on'
)
2019-04-09 12:13:46 +02:00
)
and int ( gettimeofday ( ) / 86400 ) == int (
computeAlignTime ( '24:00' , $ shutters - > getTimeUpLate ) /
86400
)
)
or (
int ( gettimeofday ( ) / 86400 ) != int (
computeAlignTime ( '24:00' , $ shutters - > getTimeDownEarly ) /
86400
)
and int ( gettimeofday ( ) / 86400 ) == int (
computeAlignTime ( '24:00' , $ shutters - > getTimeDownLate ) /
86400
)
)
)
2018-11-19 09:06:50 +01:00
) ;
2019-04-09 12:13:46 +02:00
ASC_Debug ( 'EventProcessingBrightness: '
. $ shutters - > getShuttersDev
. ' - Die aktuelle Zeit befindet sich innerhalb der Sunset/Sunrise Brightness Verarbeitungszeit. Also zwischen Time Early und Time Late'
) ;
2018-10-14 18:19:23 +02:00
2018-12-07 12:57:45 +01:00
my $ reading = $ shutters - > getBrightnessReading ;
2019-04-29 11:04:27 +02:00
if ( $ events =~ m #$reading:\s(\d+(\.\d+)?)# ) {
2018-10-16 10:30:10 +02:00
my $ brightnessMinVal ;
if ( $ shutters - > getBrightnessMinVal > - 1 ) {
$ brightnessMinVal = $ shutters - > getBrightnessMinVal ;
}
else {
$ brightnessMinVal = $ ascDev - > getBrightnessMinVal ;
}
2019-01-02 09:38:00 +01:00
2018-12-21 19:40:16 +01:00
my $ brightnessMaxVal ;
if ( $ shutters - > getBrightnessMaxVal > - 1 ) {
$ brightnessMaxVal = $ shutters - > getBrightnessMaxVal ;
}
else {
$ brightnessMaxVal = $ ascDev - > getBrightnessMaxVal ;
}
2019-04-09 12:13:46 +02:00
ASC_Debug ( 'EventProcessingBrightness: '
. $ shutters - > getShuttersDev
. ' - Es wird geprüft ob Sunset oder Sunrise gefahren werden soll und der aktuelle übergebene Brightness-Wert: '
. $ 1
. ' Größer dem eingestellten Sunrise-Wert: '
. $ brightnessMaxVal
. ' oder kleiner dem eingestellten Sunset-Wert: '
. $ brightnessMinVal
2019-05-07 05:58:59 +02:00
. ' ist. Werte für weitere Parameter - getUp ist: '
. $ shutters - > getUp
. ' getDown ist: '
. $ shutters - > getDown
. ' getSunrise ist: '
. $ shutters - > getSunrise
. ' getSunset ist: '
2019-05-07 11:34:53 +02:00
. $ shutters - > getSunset ) ;
2018-10-16 10:30:10 +02:00
2018-10-14 18:19:23 +02:00
if (
2019-05-07 05:58:59 +02:00
(
(
(
int ( gettimeofday ( ) / 86400 ) != int (
computeAlignTime ( '24:00' ,
$ shutters - > getTimeUpEarly ) / 86400
)
2019-05-17 14:20:57 +02:00
and (
not IsWe ( )
or ( IsWe ( )
and $ ascDev - > getSunriseTimeWeHoliday eq 'off' )
)
)
2019-05-07 05:58:59 +02:00
or (
int ( gettimeofday ( ) / 86400 ) != int (
computeAlignTime ( '24:00' ,
$ shutters - > getTimeUpWeHoliday ) / 86400
)
and IsWe ( )
and $ ascDev - > getSunriseTimeWeHoliday eq 'on'
)
)
and int ( gettimeofday ( ) / 86400 ) == int (
computeAlignTime ( '24:00' , $ shutters - > getTimeUpLate ) /
86400
)
2018-10-14 18:19:23 +02:00
)
2018-12-21 19:40:16 +01:00
and $ 1 > $ brightnessMaxVal
2018-11-03 19:01:29 +01:00
and $ shutters - > getUp eq 'brightness'
2019-03-27 11:22:06 +01:00
and not $ shutters - > getSunrise
2018-10-14 18:19:23 +02:00
)
{
Log3 ( $ name , 4 ,
2018-11-12 12:56:18 +01:00
"AutoShuttersControl ($shuttersDev) - EventProcessingBrightness: Steuerung für Morgens"
2018-10-14 18:19:23 +02:00
) ;
2019-04-09 12:13:46 +02:00
ASC_Debug ( 'EventProcessingBrightness: '
. $ shutters - > getShuttersDev
. ' - Verarbeitungszeit für Sunrise wurd erkannt. Prüfe Status der Roommates'
) ;
2018-10-28 18:12:40 +01:00
my $ homemode = $ shutters - > getRoommatesStatus ;
$ homemode = $ ascDev - > getResidentsStatus
if ( $ homemode eq 'none' ) ;
2018-12-21 19:40:16 +01:00
$ shutters - > setLastDrive ( 'maximum brightness threshold exceeded' ) ;
2018-10-28 18:12:40 +01:00
2019-02-19 12:00:25 +01:00
if (
$ shutters - > getModeUp eq $ homemode
or ( $ shutters - > getModeUp eq 'absent'
and $ homemode eq 'gone' )
or $ shutters - > getModeUp eq 'always'
)
2018-10-28 18:12:40 +01:00
{
2018-11-14 03:41:38 +01:00
if (
2018-10-28 18:12:40 +01:00
(
$ shutters - > getRoommatesStatus eq 'home'
or $ shutters - > getRoommatesStatus eq 'awoken'
or $ shutters - > getRoommatesStatus eq 'absent'
or $ shutters - > getRoommatesStatus eq 'gone'
or $ shutters - > getRoommatesStatus eq 'none'
)
and $ ascDev - > getSelfDefense eq 'off'
or ( $ ascDev - > getSelfDefense eq 'on'
and CheckIfShuttersWindowRecOpen ( $ shuttersDev ) == 0 )
2018-11-19 09:06:50 +01:00
)
{
2019-03-27 11:22:06 +01:00
$ shutters - > setSunrise ( 1 ) ;
$ shutters - > setSunset ( 0 ) ;
2018-11-19 09:06:50 +01:00
ShuttersCommandSet ( $ hash , $ shuttersDev ,
$ shutters - > getOpenPos ) ;
2019-04-09 12:13:46 +02:00
ASC_Debug ( 'EventProcessingBrightness: '
. $ shutters - > getShuttersDev
. ' - Verarbeitung für Sunrise. Roommatestatus korrekt zum fahren. Fahrbefehl wird an die Funktion FnShuttersCommandSet gesendet. Grund des fahrens: '
. $ shutters - > getLastDrive ) ;
2018-11-19 09:06:50 +01:00
}
else {
EventProcessingShadingBrightness ( $ hash , $ shuttersDev ,
$ events ) ;
2019-04-09 12:13:46 +02:00
ASC_Debug ( 'EventProcessingBrightness: '
. $ shutters - > getShuttersDev
. ' - Verarbeitung für Sunrise. Roommatestatus nicht zum hochfahren oder Fenster sind offen. Fahrbebehl bleibt aus!!! Es wird an die Event verarbeitende Beschattungsfunktion weiter gereicht'
) ;
2018-11-19 09:06:50 +01:00
}
2018-10-28 18:12:40 +01:00
}
2018-10-14 18:19:23 +02:00
}
elsif (
int ( gettimeofday ( ) / 86400 ) != int (
computeAlignTime ( '24:00' , $ shutters - > getTimeDownEarly ) / 86400
)
and int ( gettimeofday ( ) / 86400 ) == int (
computeAlignTime ( '24:00' , $ shutters - > getTimeDownLate ) / 86400
)
2018-10-16 10:30:10 +02:00
and $ 1 < $ brightnessMinVal
2018-11-03 19:01:29 +01:00
and $ shutters - > getDown eq 'brightness'
2019-03-27 11:22:06 +01:00
and not $ shutters - > getSunset
2019-01-02 09:38:00 +01:00
and IsAfterShuttersManualBlocking ( $ shuttersDev )
2018-10-14 18:19:23 +02:00
)
{
Log3 ( $ name , 4 ,
2018-11-12 12:56:18 +01:00
"AutoShuttersControl ($shuttersDev) - EventProcessingBrightness: Steuerung für Abends"
2018-10-14 18:19:23 +02:00
) ;
2019-04-09 12:13:46 +02:00
ASC_Debug ( 'EventProcessingBrightness: '
. $ shutters - > getShuttersDev
. ' - Verarbeitungszeit für Sunset wurd erkannt. Prüfe Status der Roommates'
) ;
2018-10-28 18:12:40 +01:00
my $ posValue ;
2019-01-17 09:47:53 +01:00
if ( CheckIfShuttersWindowRecOpen ( $ shuttersDev ) == 2
2019-01-13 07:32:17 +01:00
and $ shutters - > getSubTyp eq 'threestate'
and $ ascDev - > getAutoShuttersControlComfort eq 'on' )
{
$ posValue = $ shutters - > getComfortOpenPos ;
}
elsif ( CheckIfShuttersWindowRecOpen ( $ shuttersDev ) == 0
2018-10-28 18:12:40 +01:00
or $ shutters - > getVentilateOpen eq 'off' )
{
$ posValue = $ shutters - > getClosedPos ;
}
else { $ posValue = $ shutters - > getVentilatePos ; }
my $ homemode = $ shutters - > getRoommatesStatus ;
$ homemode = $ ascDev - > getResidentsStatus
if ( $ homemode eq 'none' ) ;
2018-10-27 13:36:11 +02:00
$ shutters - > setLastDrive ( 'minimum brightness threshold fell below' ) ;
2018-10-28 18:12:40 +01:00
2019-02-19 12:00:25 +01:00
if (
2019-02-20 20:28:50 +01:00
$ shutters - > getModeDown eq $ homemode
or ( $ shutters - > getModeDown eq 'absent'
2019-02-19 12:00:25 +01:00
and $ homemode eq 'gone' )
2019-02-20 20:28:50 +01:00
or $ shutters - > getModeDown eq 'always'
2019-02-19 12:00:25 +01:00
)
2018-11-19 09:06:50 +01:00
{
2019-03-27 11:22:06 +01:00
$ shutters - > setSunrise ( 0 ) ;
$ shutters - > setSunset ( 1 ) ;
2019-01-02 09:38:00 +01:00
ShuttersCommandSet ( $ hash , $ shuttersDev , $ posValue ) ;
2019-04-09 12:13:46 +02:00
ASC_Debug ( 'EventProcessingBrightness: '
. $ shutters - > getShuttersDev
. ' - Verarbeitung für Sunset. Roommatestatus korrekt zum fahren. Fahrbefehl wird an die Funktion FnShuttersCommandSet gesendet. Zielposition: '
. $ posValue
. ' Grund des fahrens: '
. $ shutters - > getLastDrive ) ;
2018-11-19 09:06:50 +01:00
}
else {
EventProcessingShadingBrightness ( $ hash , $ shuttersDev ,
$ events ) ;
2019-04-09 12:13:46 +02:00
ASC_Debug ( 'EventProcessingBrightness: '
. $ shutters - > getShuttersDev
. ' - Verarbeitung für Sunset. Roommatestatus nicht zum runter fahren. Fahrbebehl bleibt aus!!! Es wird an die Event verarbeitende Beschattungsfunktion weiter gereicht'
) ;
2018-11-19 09:06:50 +01:00
}
2018-10-14 18:19:23 +02:00
}
2019-04-09 12:13:46 +02:00
else {
2019-05-01 11:45:46 +02:00
EventProcessingShadingBrightness ( $ hash , $ shuttersDev , $ events ) ;
2019-04-09 12:13:46 +02:00
ASC_Debug ( 'EventProcessingBrightness: '
. $ shutters - > getShuttersDev
. ' - Brightness Event kam nicht innerhalb der Verarbeitungszeit für Sunset oder Sunris oder aber für beide wurden die entsprechendne Verarbeitungsschwellen nicht erreicht.'
) ;
2019-04-02 19:28:54 +02:00
}
2018-11-19 09:06:50 +01:00
}
2019-04-02 19:28:54 +02:00
### Wenn es kein Brightness Reading ist muss auch die Shading Funktion nicht aufgerufen werden.
# else { EventProcessingShadingBrightness( $hash, $shuttersDev, $events ); }
2019-04-09 12:13:46 +02:00
else {
ASC_Debug ( 'EventProcessingBrightness: '
. $ shutters - > getShuttersDev
. ' - Leider konnte kein Korrekter Brightnesswert aus dem Event erkannt werden. Entweder passt das Reading oder der tatsächliche nummerishce Wert des Events nicht'
) ;
}
2018-11-14 03:41:38 +01:00
}
sub EventProcessingShadingBrightness ($@) {
my ( $ hash , $ shuttersDev , $ events ) = @ _ ;
my $ name = $ hash - > { NAME } ;
$ shutters - > setShuttersDev ( $ shuttersDev ) ;
2018-12-07 12:57:45 +01:00
my $ reading = $ shutters - > getBrightnessReading ;
2019-04-09 12:13:46 +02:00
2019-03-24 16:41:48 +01:00
Log3 ( $ name , 4 ,
2019-04-09 12:13:46 +02:00
"AutoShuttersControl ($shuttersDev) - EventProcessingShadingBrightness"
) ;
ASC_Debug ( 'EventProcessingShadingBrightness: '
. $ shutters - > getShuttersDev
. ' - Es wird nun geprüft ob der übergebene Event ein nummerischer Wert vom Brightnessreading ist.'
) ;
2018-11-19 09:06:50 +01:00
2019-04-29 11:04:27 +02:00
if ( $ events =~ m #$reading:\s(\d+(\.\d+)?)# ) {
2019-04-09 12:13:46 +02:00
Log3 (
$ name , 4 ,
" AutoShuttersControl ( $ shuttersDev ) - EventProcessingShadingBrightness
Brightness: " . $ 1
) ;
ASC_Debug ( 'EventProcessingShadingBrightness: '
. $ shutters - > getShuttersDev
. ' - Nummerischer Brightness-Wert wurde erkannt. Der Wert ist: '
2019-05-04 18:46:09 +02:00
. $ 1
. ' RainProtection: '
. $ shutters - > getRainProtectionStatus
. ' WindProtection: '
. $ shutters - > getWindProtectionStatus ) ;
2019-04-09 12:13:46 +02:00
2018-12-05 15:39:11 +01:00
my $ homemode = $ shutters - > getRoommatesStatus ;
$ homemode = $ ascDev - > getResidentsStatus if ( $ homemode eq 'none' ) ;
2018-12-07 13:04:41 +01:00
2019-04-02 19:28:54 +02:00
if (
2019-01-02 09:38:00 +01:00
(
$ shutters - > getShadingMode eq 'always'
or $ shutters - > getShadingMode eq $ homemode
)
2019-04-20 21:53:05 +02:00
and IsDay ( $ shuttersDev )
2019-05-02 10:37:14 +02:00
and $ ascDev - > getAutoShuttersControlShading eq 'on'
2019-06-03 07:44:35 +02:00
and $ shutters - > getRainProtectionStatus eq 'unprotected'
and $ shutters - > getWindProtectionStatus eq 'unprotected'
2019-04-02 19:28:54 +02:00
)
{
ShadingProcessing (
2019-04-09 12:13:46 +02:00
$ hash ,
$ shuttersDev ,
$ ascDev - > getAzimuth ,
$ ascDev - > getElevation ,
$ 1 ,
$ ascDev - > getOutTemp ,
$ shutters - > getDirection ,
$ shutters - > getShadingAngleLeft ,
2019-04-02 19:28:54 +02:00
$ shutters - > getShadingAngleRight
) ;
2019-04-09 12:13:46 +02:00
ASC_Debug ( 'EventProcessingShadingBrightness: '
. $ shutters - > getShuttersDev
. ' - Alle Bedingungen zur weiteren Beschattungsverarbeitung sind erfüllt. Es wird nun die eigentliche Beschattungsfunktion aufgerufen'
) ;
2019-04-02 19:28:54 +02:00
}
2019-05-24 22:24:11 +02:00
elsif ( $ shutters - > getShadingStatus eq 'in'
and $ shutters - > getShadingMode ne $ homemode
2019-06-03 07:44:35 +02:00
and $ shutters - > getRainProtectionStatus eq 'unprotected'
and $ shutters - > getWindProtectionStatus eq 'unprotected' )
2019-05-24 22:24:11 +02:00
{
$ shutters - > setShadingStatus ( 'out' ) ;
ShadingProcessingDriveCommand ( $ hash , $ shuttersDev ) ;
}
2018-10-12 06:32:01 +02:00
}
}
2018-09-04 11:42:47 +02:00
2018-11-14 03:41:38 +01:00
sub EventProcessingTwilightDevice ($@) {
my ( $ hash , $ device , $ events ) = @ _ ;
2018-12-07 13:04:41 +01:00
# Twilight
# azimuth = azimuth = Sonnenwinkel
# elevation = elevation = Sonnenhöhe
#
# Astro
# SunAz = azimuth = Sonnenwinkel
2019-02-27 21:30:35 +01:00
# SunAlt = elevation = Sonnenhöhe
2019-04-09 12:13:46 +02:00
ASC_Debug ( 'EventProcessingTwilightDevice: '
. $ shutters - > getShuttersDev
. ' - Event vom Astro oder Twilight Device wurde erkannt. Event wird verarbeitet'
) ;
2018-11-14 15:26:32 +01:00
2019-02-27 21:30:35 +01:00
if ( $ events =~ m #(azimuth|elevation|SunAz|SunAlt):\s(\d+.\d+)# ) {
2018-11-19 09:06:50 +01:00
my $ name = $ device ;
2018-12-05 15:39:11 +01:00
my ( $ azimuth , $ elevation ) ;
2018-11-19 09:06:50 +01:00
2019-04-09 12:13:46 +02:00
$ azimuth = $ 2 if ( $ 1 eq 'azimuth' or $ 1 eq 'SunAz' ) ;
2019-02-27 21:30:35 +01:00
$ elevation = $ 2 if ( $ 1 eq 'elevation' or $ 1 eq 'SunAlt' ) ;
2018-11-14 15:26:32 +01:00
2018-11-19 09:06:50 +01:00
$ azimuth = $ ascDev - > getAzimuth
if ( not defined ( $ azimuth ) and not $ azimuth ) ;
$ elevation = $ ascDev - > getElevation
if ( not defined ( $ elevation ) and not $ elevation ) ;
2019-04-09 12:13:46 +02:00
ASC_Debug ( 'EventProcessingTwilightDevice: '
. $ name
. ' - Passendes Event wurde erkannt. Verarbeitung über alle Rolllos beginnt'
) ;
2018-11-14 15:26:32 +01:00
foreach my $ shuttersDev ( @ { $ hash - > { helper } { shuttersList } } ) {
$ shutters - > setShuttersDev ( $ shuttersDev ) ;
2018-12-07 13:04:41 +01:00
2018-12-05 15:39:11 +01:00
my $ homemode = $ shutters - > getRoommatesStatus ;
$ homemode = $ ascDev - > getResidentsStatus if ( $ homemode eq 'none' ) ;
2018-12-07 13:04:41 +01:00
2019-05-04 18:46:09 +02:00
ASC_Debug ( 'EventProcessingTwilightDevice: '
. $ shutters - > getShuttersDev
. ' RainProtection: '
. $ shutters - > getRainProtectionStatus
. ' WindProtection: '
. $ shutters - > getWindProtectionStatus ) ;
2019-04-02 19:28:54 +02:00
if (
2018-11-19 09:06:50 +01:00
(
2018-12-07 19:57:48 +01:00
$ shutters - > getShadingMode eq 'always'
2018-12-05 15:39:11 +01:00
or $ shutters - > getShadingMode eq $ homemode
2018-11-19 09:06:50 +01:00
)
2019-04-20 21:53:05 +02:00
and IsDay ( $ shuttersDev )
2019-05-02 10:37:14 +02:00
and $ ascDev - > getAutoShuttersControlShading eq 'on'
2019-06-03 07:44:35 +02:00
and $ shutters - > getRainProtectionStatus eq 'unprotected'
and $ shutters - > getWindProtectionStatus eq 'unprotected'
2019-04-02 19:28:54 +02:00
)
{
ShadingProcessing (
$ hash ,
$ shuttersDev ,
$ azimuth ,
$ elevation ,
$ shutters - > getBrightness ,
$ ascDev - > getOutTemp ,
$ shutters - > getDirection ,
$ shutters - > getShadingAngleLeft ,
$ shutters - > getShadingAngleRight
) ;
2019-04-09 12:13:46 +02:00
ASC_Debug ( 'EventProcessingTwilightDevice: '
. $ shutters - > getShuttersDev
. ' - Alle Bedingungen zur weiteren Beschattungsverarbeitung sind erfüllt. Es wird nun die Beschattungsfunktion ausgeführt'
) ;
2019-04-02 19:28:54 +02:00
}
2019-04-09 12:13:46 +02:00
2019-04-02 19:28:54 +02:00
$ shutters - > setShadingStatus ( 'out' )
2019-04-20 21:53:05 +02:00
if ( not IsDay ( $ shuttersDev )
2019-04-02 19:28:54 +02:00
and $ shutters - > getShadingStatus ne 'out' ) ;
2018-11-14 15:26:32 +01:00
}
2018-11-14 03:41:38 +01:00
}
}
sub ShadingProcessing ($@) {
2018-12-05 15:39:11 +01:00
### angleMinus ist $shutters->getShadingAngleLeft
### anglePlus ist $shutters->getShadingAngleRight
### winPos ist die Fensterposition $shutters->getDirection
2018-11-19 09:06:50 +01:00
my (
2018-12-07 13:04:41 +01:00
$ hash , $ shuttersDev , $ azimuth , $ elevation , $ brightness ,
$ outTemp , $ winPos , $ angleMinus , $ anglePlus
2018-11-19 09:06:50 +01:00
) = @ _ ;
2018-11-14 03:41:38 +01:00
my $ name = $ hash - > { NAME } ;
2018-12-05 15:39:11 +01:00
$ shutters - > setShuttersDev ( $ shuttersDev ) ;
2019-04-09 12:13:46 +02:00
ASC_Debug (
'ShadingProcessing: '
. $ shutters - > getShuttersDev
. ' - Übergebende Werte - Azimuth:'
. $ azimuth
. ', Elevation: '
. $ elevation
. ', Brightness: '
. $ brightness
. ', OutTemp: '
. $ outTemp
. ', Fenster Position: '
. $ winPos
. ', Winkel Links: '
. $ angleMinus
. ', Winkel Rechts: '
. $ anglePlus
. ', Ist es nach der Zeitblockadezeit: '
2019-04-20 21:53:05 +02:00
. ( IsAfterShuttersTimeBlocking ( $ shuttersDev ) ? 'JA' : 'NEIN' )
2019-04-09 12:13:46 +02:00
. ', Ist es nach der manuellen Blockadezeit: '
. ( IsAfterShuttersManualBlocking ( $ shuttersDev ) ? 'JA' : 'NEIN' )
. ', Ist es nach der Hälfte der Beschattungswartezeit: '
. (
( int ( gettimeofday ( ) ) - $ shutters - > getShadingStatusTimestamp ) <
( $ shutters - > getShadingWaitingPeriod / 2 ) ? 'NEIN' : 'JA'
)
) ;
2019-04-02 19:28:54 +02:00
2019-03-31 17:17:56 +02:00
$ shutters - > setShadingStatus ( 'out' )
2019-04-20 21:53:05 +02:00
if ( not IsDay ( $ shuttersDev )
2019-03-31 17:17:56 +02:00
and $ shutters - > getShadingStatus ne 'out' ) ;
2018-11-19 09:06:50 +01:00
2019-01-23 19:32:48 +01:00
Log3 ( $ name , 4 ,
2018-12-07 13:04:41 +01:00
"AutoShuttersControl ($name) - Shading Processing, Rollladen: "
. $ shuttersDev
. " Azimuth: "
. $ azimuth
. " Elevation: "
. $ elevation
. " Brightness: "
. $ brightness
. " OutTemp: "
. $ outTemp ) ;
2018-12-05 15:39:11 +01:00
return
2018-12-07 13:04:41 +01:00
if ( $ azimuth == - 1
or $ elevation == - 1
or $ brightness == - 1
or $ outTemp == - 100
2019-03-31 17:17:56 +02:00
or ( int ( gettimeofday ( ) ) - $ shutters - > getShadingStatusTimestamp ) <
2018-12-07 13:04:41 +01:00
( $ shutters - > getShadingWaitingPeriod / 2 )
2019-04-20 21:53:05 +02:00
or not IsAfterShuttersTimeBlocking ( $ shuttersDev )
2019-03-27 11:22:06 +01:00
or not IsAfterShuttersManualBlocking ( $ shuttersDev ) ) ;
2018-12-07 13:04:41 +01:00
2019-02-16 19:14:25 +01:00
Log3 ( $ name , 4 ,
2018-12-07 13:04:41 +01:00
"AutoShuttersControl ($name) - Shading Processing, Rollladen: "
. $ shuttersDev
. " Nach dem return" ) ;
2019-04-09 12:13:46 +02:00
my $ getShadingPos = $ shutters - > getShadingPos ;
my $ getStatus = $ shutters - > getStatus ;
2019-04-02 19:28:54 +02:00
my $ oldShadingStatus = $ shutters - > getShadingStatus ;
2019-04-09 12:13:46 +02:00
ASC_Debug ( 'ShadingProcessing: '
. $ shutters - > getShuttersDev
. ' - Alle Werte für die weitere Verarbeitung sind korrekt vorhanden und es wird nun mit der Beschattungsverarbeitung begonnen'
) ;
2019-05-20 14:23:11 +02:00
# 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.
2019-05-20 09:47:28 +02:00
my $ winPosMin = $ winPos - $ angleMinus ;
my $ winPosMax = $ winPos + $ anglePlus ;
2019-04-09 12:13:46 +02:00
if (
(
2019-05-20 14:23:11 +02:00
$ outTemp < $ shutters - > getShadingMinOutsideTemperature - 3
2019-04-20 21:53:05 +02:00
or not IsDay ( $ shuttersDev )
2019-05-20 09:47:28 +02:00
or $ azimuth < $ winPosMin
or $ azimuth > $ winPosMax
2019-04-09 12:13:46 +02:00
)
and $ shutters - > getShadingStatus ne 'out'
and $ getStatus != $ getShadingPos
)
2019-03-23 12:45:50 +01:00
{
2019-03-31 17:17:56 +02:00
$ shutters - > setShadingStatus ( 'out' ) ;
2019-03-23 12:45:50 +01:00
$ shutters - > setLastDrive ( 'shading out' ) ;
2019-04-09 12:13:46 +02:00
2019-03-23 12:45:50 +01:00
ShuttersCommandSet ( $ hash , $ shuttersDev , $ shutters - > getLastPos ) ;
2019-04-09 12:13:46 +02:00
ASC_Debug ( 'ShadingProcessing: '
. $ shutters - > getShuttersDev
. ' - Es ist Nacht oder die Aussentemperatur unterhalb der Shading Temperatur. Die Beschattung wird Zwangsbeendet'
) ;
2019-04-02 19:28:54 +02:00
return Log3 ( $ name , 4 ,
2019-04-09 12:13:46 +02:00
"AutoShuttersControl ($name) - Shading Processing - Es ist Sonnenuntergang vorbei oder die Aussentemperatur unterhalb der Shading Temperatur "
) ;
2019-03-23 12:45:50 +01:00
}
2018-12-05 15:39:11 +01:00
2018-12-07 13:04:41 +01:00
if ( $ azimuth < $ winPosMin
or $ azimuth > $ winPosMax
or $ elevation < $ shutters - > getShadingMinElevation
2019-06-10 13:41:46 +02:00
or $ elevation > $ shutters - > getShadingMaxElevation
2019-04-09 12:47:36 +02:00
or $ brightness < $ shutters - > getShadingStateChangeCloudy
or $ outTemp < $ shutters - > getShadingMinOutsideTemperature )
2018-12-05 15:39:11 +01:00
{
2019-03-31 17:17:56 +02:00
$ shutters - > setShadingStatus ( 'out reserved' )
if ( $ shutters - > getShadingStatus eq 'in'
or $ shutters - > getShadingStatus eq 'in reserved' ) ;
2018-12-06 15:24:16 +01:00
2019-03-31 17:17:56 +02:00
$ shutters - > setShadingStatus ( 'out' )
2019-04-09 12:13:46 +02:00
if (
(
$ shutters - > getShadingStatus eq 'out reserved'
and
( int ( gettimeofday ( ) ) - $ shutters - > getShadingStatusTimestamp )
> $ shutters - > getShadingWaitingPeriod
)
or $ azimuth > $ winPosMax
) ;
2019-02-16 19:14:25 +01:00
Log3 ( $ name , 4 ,
2018-12-07 13:04:41 +01:00
"AutoShuttersControl ($name) - Shading Processing, Rollladen: "
. $ shuttersDev
. " In der Out Abfrage, Shadingwert: "
2019-03-31 17:17:56 +02:00
. $ shutters - > getShadingStatus
2018-12-07 13:04:41 +01:00
. ", Zeitstempel: "
2019-03-31 17:17:56 +02:00
. $ shutters - > getShadingStatusTimestamp ) ;
2019-04-09 12:13:46 +02:00
ASC_Debug ( 'ShadingProcessing: '
. $ shutters - > getShuttersDev
. ' - Einer der Beschattungsbedingungen wird nicht mehr erfüllt und somit wird der Beschattungsstatus um eine Stufe reduziert. Alter Status: '
. $ oldShadingStatus
. ' Neuer Status: '
. $ shutters - > getShadingStatus ) ;
2018-12-07 13:04:41 +01:00
}
2019-03-31 17:17:56 +02:00
elsif ( $ azimuth > $ winPosMin
and $ azimuth < $ winPosMax
and $ elevation > $ shutters - > getShadingMinElevation
2019-06-10 13:41:46 +02:00
and $ elevation < $ shutters - > getShadingMaxElevation
2019-04-09 12:47:36 +02:00
and $ brightness > $ shutters - > getShadingStateChangeSunny
and $ outTemp > $ shutters - > getShadingMinOutsideTemperature )
2018-12-05 15:39:11 +01:00
{
2019-03-31 17:17:56 +02:00
$ shutters - > setShadingStatus ( 'in reserved' )
if ( $ shutters - > getShadingStatus eq 'out'
or $ shutters - > getShadingStatus eq 'out reserved' ) ;
2018-12-07 13:04:41 +01:00
2019-03-31 17:17:56 +02:00
$ shutters - > setShadingStatus ( 'in' )
if ( $ shutters - > getShadingStatus eq 'in reserved'
2019-04-09 12:13:46 +02:00
and
( int ( gettimeofday ( ) ) - $ shutters - > getShadingStatusTimestamp ) >
2018-12-07 13:04:41 +01:00
( $ shutters - > getShadingWaitingPeriod / 2 ) ) ;
2019-02-16 19:14:25 +01:00
Log3 ( $ name , 4 ,
2018-12-07 13:04:41 +01:00
"AutoShuttersControl ($name) - Shading Processing, Rollladen: "
. $ shuttersDev
. " In der In Abfrage, Shadingwert: "
2019-03-31 17:17:56 +02:00
. $ shutters - > getShadingStatus
2018-12-07 13:04:41 +01:00
. ", Zeitstempel: "
2019-03-31 17:17:56 +02:00
. $ shutters - > getShadingStatusTimestamp ) ;
2019-04-09 12:13:46 +02:00
ASC_Debug ( 'ShadingProcessing: '
. $ shutters - > getShuttersDev
. ' - Alle Beschattungsbedingungen wurden erfüllt und somit wird der Beschattungsstatus um eine Stufe angehoben. Alter Status: '
. $ oldShadingStatus
. ' Neuer Status: '
. $ shutters - > getShadingStatus ) ;
2018-12-05 15:39:11 +01:00
}
2019-05-24 22:24:11 +02:00
ShadingProcessingDriveCommand ( $ hash , $ shuttersDev )
if ( $ shutters - > getShadingStatus eq 'out'
or $ shutters - > getShadingStatus eq 'in' ) ;
2019-05-24 19:58:26 +02:00
}
2018-12-07 13:04:41 +01:00
2019-05-24 19:58:26 +02:00
sub ShadingProcessingDriveCommand ($$) {
2019-05-24 22:24:11 +02:00
my ( $ hash , $ shuttersDev ) = @ _ ;
2019-03-04 10:10:53 +01:00
2019-05-24 19:58:26 +02:00
my $ name = $ hash - > { NAME } ;
$ shutters - > setShuttersDev ( $ shuttersDev ) ;
2018-12-07 13:04:41 +01:00
2019-05-24 22:24:11 +02:00
my $ getShadingPos = $ shutters - > getShadingPos ;
my $ getStatus = $ shutters - > getStatus ;
2019-04-09 12:13:46 +02:00
2019-05-24 19:58:26 +02:00
$ shutters - > setShadingStatus ( $ shutters - > getShadingStatus )
2019-05-24 22:24:11 +02:00
if (
2019-05-24 19:58:26 +02:00
( int ( gettimeofday ( ) ) - $ shutters - > getShadingStatusTimestamp ) >
( $ shutters - > getShadingWaitingPeriod / 2 ) ) ;
if ( $ shutters - > getShadingStatus eq 'in'
and $ getShadingPos != $ getStatus )
{
2019-06-10 14:03:03 +02:00
# my $queryShuttersShadingPos = (
# $shutters->getShuttersPosCmdValueNegate
# ? $getStatus > $getShadingPos
# : $getStatus < $getShadingPos
# );
2019-05-24 19:58:26 +02:00
if (
2019-06-10 14:03:03 +02:00
not $ shutters - > getQueryShuttersPos ( $ shutters - > getShadingPos )
2019-05-24 19:58:26 +02:00
and not ( CheckIfShuttersWindowRecOpen ( $ shuttersDev ) == 2
and $ shutters - > getShuttersPlace eq 'terrace' )
2019-05-24 22:24:11 +02:00
)
2018-12-06 15:24:16 +01:00
{
2019-05-24 19:58:26 +02:00
$ shutters - > setLastDrive ( 'shading in' ) ;
ShuttersCommandSet ( $ hash , $ shuttersDev , $ getShadingPos ) ;
2019-04-09 12:13:46 +02:00
ASC_Debug ( 'ShadingProcessing: '
2019-05-24 22:24:11 +02:00
. $ shutters - > getShuttersDev
. ' - Der aktuelle Beschattungsstatus ist: '
. $ shutters - > getShadingStatus
. ' und somit wird nun in die Position: '
. $ getShadingPos
. ' zum Beschatten gefahren' ) ;
2018-12-06 15:24:16 +01:00
}
2019-05-24 19:58:26 +02:00
}
elsif ( $ shutters - > getShadingStatus eq 'out'
and $ getShadingPos == $ getStatus )
{
$ shutters - > setLastDrive ( 'shading out' ) ;
ShuttersCommandSet (
$ hash ,
$ shuttersDev ,
(
2019-05-24 22:24:11 +02:00
$ shutters - > getShadingPos == $ shutters - > getLastPos
2019-05-24 19:58:26 +02:00
? $ shutters - > getOpenPos
: $ shutters - > getLastPos
)
) ;
2018-12-07 13:04:41 +01:00
2019-05-24 19:58:26 +02:00
ASC_Debug ( 'ShadingProcessing: '
2019-05-24 22:24:11 +02:00
. $ shutters - > getShuttersDev
. ' - Der aktuelle Beschattungsstatus ist: '
. $ shutters - > getShadingStatus
. ' und somit wird nun in die Position: '
. $ getShadingPos
. ' zum beenden der Beschattung gefahren' ) ;
2019-05-24 19:58:26 +02:00
}
Log3 ( $ name , 4 ,
2019-04-25 21:34:46 +02:00
"AutoShuttersControl ($name) - Shading Processing - In der Routine zum fahren der Rollläden, Shading Wert: "
2019-05-24 22:24:11 +02:00
. $ shutters - > getShadingStatus ) ;
2019-04-09 12:13:46 +02:00
2019-05-24 19:58:26 +02:00
ASC_Debug (
'ShadingProcessing: '
2019-05-24 22:24:11 +02:00
. $ shutters - > getShuttersDev
. ' - Der aktuelle Beschattungsstatus ist: '
. $ shutters - > getShadingStatus
. ', Beschattungsstatus Zeitstempel: '
. strftime (
2019-05-24 19:58:26 +02:00
"%Y.%m.%e %T" , localtime ( $ shutters - > getShadingStatusTimestamp )
2019-05-24 22:24:11 +02:00
)
2019-05-24 19:58:26 +02:00
) ;
2018-11-14 03:41:38 +01:00
}
2018-11-12 12:56:18 +01:00
sub EventProcessingPartyMode ($) {
2018-10-14 18:19:23 +02:00
my ( $ hash ) = @ _ ;
my $ name = $ hash - > { NAME } ;
2018-09-04 11:42:47 +02:00
2019-04-28 07:32:48 +02:00
foreach my $ shuttersDev ( @ { $ hash - > { helper } { shuttersList } } ) {
2018-10-10 10:43:42 +02:00
$ shutters - > setShuttersDev ( $ shuttersDev ) ;
2019-04-27 20:58:17 +02:00
next
if ( $ shutters - > getPartyMode eq 'off' ) ;
2019-04-28 07:32:48 +02:00
2019-04-20 21:53:05 +02:00
if ( not IsDay ( $ shuttersDev )
2019-03-27 11:22:06 +01:00
and $ shutters - > getModeDown ne 'off'
and IsAfterShuttersManualBlocking ( $ shuttersDev ) )
2019-01-01 18:54:08 +01:00
{
2018-11-03 19:01:29 +01:00
if ( CheckIfShuttersWindowRecOpen ( $ shuttersDev ) == 2
and $ shutters - > getSubTyp eq 'threestate' )
{
Log3 ( $ name , 4 ,
2018-11-12 12:56:18 +01:00
"AutoShuttersControl ($name) - EventProcessingPartyMode Fenster offen"
2018-11-03 19:01:29 +01:00
) ;
$ shutters - > setDelayCmd ( $ shutters - > getClosedPos ) ;
Log3 ( $ name , 4 ,
2018-11-12 12:56:18 +01:00
"AutoShuttersControl ($name) - EventProcessingPartyMode - Spring in ShuttersCommandDelaySet"
2018-11-03 19:01:29 +01:00
) ;
}
else {
Log3 ( $ name , 4 ,
2018-11-12 12:56:18 +01:00
"AutoShuttersControl ($name) - EventProcessingPartyMode Fenster nicht offen"
2018-11-03 19:01:29 +01:00
) ;
2018-11-14 05:44:02 +01:00
$ shutters - > setLastDrive ( 'drive after party mode' ) ;
2018-11-03 19:01:29 +01:00
ShuttersCommandSet (
$ hash ,
$ shuttersDev ,
(
CheckIfShuttersWindowRecOpen ( $ shuttersDev ) == 0
? $ shutters - > getClosedPos
: $ shutters - > getVentilatePos
)
) ;
}
2018-09-04 11:42:47 +02:00
}
2019-04-20 21:53:05 +02:00
elsif ( IsDay ( $ shuttersDev )
2019-04-09 12:13:46 +02:00
and IsAfterShuttersManualBlocking ( $ shuttersDev ) )
{
2019-01-01 18:54:08 +01:00
$ shutters - > setLastDrive ( 'drive after party mode' ) ;
2019-01-02 09:38:00 +01:00
ShuttersCommandSet ( $ hash , $ shuttersDev , $ shutters - > getDelayCmd ) ;
2019-01-01 18:54:08 +01:00
}
2018-09-04 11:42:47 +02:00
}
}
2018-11-12 12:56:18 +01:00
sub EventProcessingShutters ($@) {
2018-10-17 15:58:05 +02:00
my ( $ hash , $ shuttersDev , $ events ) = @ _ ;
2018-10-19 20:13:01 +02:00
my $ name = $ hash - > { NAME } ;
2018-10-17 15:58:05 +02:00
if ( $ events =~ m #.*:\s(\d+)# ) {
2018-10-19 20:13:01 +02:00
$ shutters - > setShuttersDev ( $ shuttersDev ) ;
2018-11-04 19:17:11 +01:00
$ ascDev - > setPosReading ;
2019-05-07 11:34:53 +02:00
2019-05-07 11:30:55 +02:00
ASC_Debug ( 'EventProcessingShutters: '
. $ shutters - > getShuttersDev
. ' - Event vom Rolllo erkannt. Es wird nun eine etwaige manuelle Fahrt ausgewertet.'
2019-05-07 11:34:53 +02:00
. ' Int von gettimeofday: '
. int ( gettimeofday ( ) )
2019-05-07 11:30:55 +02:00
. ' Last Position Timestamp: '
. $ shutters - > getLastPosTimestamp
. ' Drive Up Max Duration: '
. $ shutters - > getDriveUpMaxDuration
. ' Last Position: '
. $ shutters - > getLastPos
. ' aktuelle Position: '
2019-05-07 11:34:53 +02:00
. $ shutters - > getStatus ) ;
2019-04-25 21:34:46 +02:00
if ( ( int ( gettimeofday ( ) ) - $ shutters - > getLastPosTimestamp ) >
2019-05-07 11:34:53 +02:00
$ shutters - > getDriveUpMaxDuration
2019-05-07 11:30:55 +02:00
and ( int ( gettimeofday ( ) ) - $ shutters - > getLastManPosTimestamp ) >
2019-05-07 11:34:53 +02:00
$ shutters - > getDriveUpMaxDuration )
2018-11-03 19:01:29 +01:00
{
2018-10-27 13:36:11 +02:00
$ shutters - > setLastDrive ( 'manual' ) ;
$ shutters - > setLastDriveReading ;
2018-11-07 08:22:11 +01:00
$ ascDev - > setStateReading ;
2018-10-27 13:36:11 +02:00
$ shutters - > setLastManPos ( $ 1 ) ;
2019-06-03 06:24:53 +02:00
ASC_Debug (
'EventProcessingShutters: eine manualle Fahrt wurde erkannt!' ) ;
}
else {
$ shutters - > setLastDriveReading ;
$ ascDev - > setStateReading ;
ASC_Debug (
'EventProcessingShutters: eine automatisierte Fahrt durch ASC wurde erkannt! Es werden nun die LastDriveReading und StateReading Werte gesetzt!'
) ;
2018-10-27 13:36:11 +02:00
}
2018-10-17 15:58:05 +02:00
}
}
2018-08-29 14:58:10 +02:00
# Sub für das Zusammensetzen der Rolläden Steuerbefehle
2018-09-04 11:42:47 +02:00
sub ShuttersCommandSet ($$$) {
2018-10-14 18:19:23 +02:00
my ( $ hash , $ shuttersDev , $ posValue ) = @ _ ;
my $ name = $ hash - > { NAME } ;
$ shutters - > setShuttersDev ( $ shuttersDev ) ;
2018-11-19 09:06:50 +01:00
2019-06-04 06:37:38 +02:00
# my $queryShuttersPosValue = (
# $shutters->getShuttersPosCmdValueNegate
# ? $shutters->getStatus > $posValue
# : $shutters->getStatus < $posValue
# );
2018-10-30 19:10:50 +01:00
2018-12-07 13:04:41 +01:00
if (
2019-04-02 19:28:54 +02:00
$ posValue != $ shutters - > getShadingPos
2019-01-23 10:00:47 +01:00
and (
(
2019-04-09 12:13:46 +02:00
$ shutters - > getPartyMode eq 'on'
and $ ascDev - > getPartyMode eq 'on'
2019-01-23 10:00:47 +01:00
)
or (
CheckIfShuttersWindowRecOpen ( $ shuttersDev ) == 2
and $ shutters - > getSubTyp eq 'threestate'
and ( $ ascDev - > getAutoShuttersControlComfort eq 'off'
or $ shutters - > getComfortOpenPos != $ posValue )
and $ shutters - > getVentilateOpen eq 'on'
)
2019-05-17 14:20:57 +02:00
or ( CheckIfShuttersWindowRecOpen ( $ shuttersDev ) == 2
2019-05-11 09:50:02 +02:00
and $ shutters - > getSubTyp eq 'threestate'
and $ ascDev - > getAutoShuttersControlComfort eq 'on'
2019-05-17 14:20:57 +02:00
and $ shutters - > getVentilateOpen eq 'off' )
2019-01-23 10:00:47 +01:00
or (
2019-04-09 12:13:46 +02:00
CheckIfShuttersWindowRecOpen ( $ shuttersDev ) == 2
2019-01-23 10:00:47 +01:00
and ( $ shutters - > getLockOut eq 'soft'
or $ shutters - > getLockOut eq 'hard' )
and $ ascDev - > getHardLockOut eq 'on'
2019-06-04 06:37:38 +02:00
and not $ shutters - > getQueryShuttersPos ( $ posValue )
2019-01-23 10:00:47 +01:00
)
2019-04-09 12:13:46 +02:00
or ( CheckIfShuttersWindowRecOpen ( $ shuttersDev ) == 2
2019-04-02 19:28:54 +02:00
and $ shutters - > getShuttersPlace eq 'terrace'
2019-06-09 13:45:27 +02:00
and $ shutters - > getQueryShuttersPos ( $ posValue ) )
2018-12-07 13:04:41 +01:00
)
2018-10-14 18:19:23 +02:00
)
{
2018-10-27 13:36:11 +02:00
$ shutters - > setDelayCmd ( $ posValue ) ;
$ ascDev - > setDelayCmdReading ;
2019-04-02 19:28:54 +02:00
$ shutters - > setNoOffset ( 0 ) ;
2018-11-15 15:01:34 +01:00
Log3 ( $ name , 4 ,
2018-11-19 09:06:50 +01:00
"AutoShuttersControl ($name) - ShuttersCommandSet in Delay" ) ;
2019-04-09 12:13:46 +02:00
ASC_Debug ( 'FnShuttersCommandSet: '
. $ shutters - > getShuttersDev
. ' - Die Fahrt wird zurückgestellt. Grund kann ein geöffnetes Fenster sein oder ein aktivierter Party Modus'
) ;
2018-09-04 11:42:47 +02:00
}
2018-10-14 18:19:23 +02:00
else {
$ shutters - > setDriveCmd ( $ posValue ) ;
2018-10-27 13:36:11 +02:00
$ shutters - > setDelayCmd ( 'none' )
2018-10-14 18:19:23 +02:00
if ( $ shutters - > getDelayCmd ne 'none' )
2018-10-30 08:18:09 +01:00
; # setzt den Wert auf none da der Rolladen nun gesteuert werden kann.
2018-10-27 13:36:11 +02:00
$ ascDev - > setLastPosReading ;
2018-11-15 15:01:34 +01:00
Log3 ( $ name , 4 ,
2018-11-19 09:06:50 +01:00
"AutoShuttersControl ($name) - ShuttersCommandSet setDriveCmd wird aufgerufen"
) ;
2019-04-09 12:13:46 +02:00
ASC_Debug ( 'FnShuttersCommandSet: '
. $ shutters - > getShuttersDev
. ' - Das Rollo wird gefahren. Kein Partymodus aktiv und das zugordnete Fenster ist entweder nicht offen oder keine Terassentür'
) ;
2018-10-14 18:19:23 +02:00
}
2018-08-28 19:49:01 +02:00
}
2018-08-29 14:58:10 +02:00
## Sub welche die InternalTimer nach entsprechenden Sunset oder Sunrise zusammen stellt
2018-08-28 19:49:01 +02:00
sub CreateSunRiseSetShuttersTimer ($$) {
2018-10-14 18:19:23 +02:00
my ( $ hash , $ shuttersDev ) = @ _ ;
my $ name = $ hash - > { NAME } ;
my $ shuttersDevHash = $ defs { $ shuttersDev } ;
2018-10-10 10:43:42 +02:00
$ shutters - > setShuttersDev ( $ shuttersDev ) ;
2018-11-07 08:22:11 +01:00
2018-10-14 18:19:23 +02:00
return if ( IsDisabled ( $ name ) ) ;
2018-08-30 10:24:39 +02:00
2019-04-20 21:53:05 +02:00
my $ shuttersSunriseUnixtime = ShuttersSunrise ( $ shuttersDev , 'unix' ) + 1 ;
my $ shuttersSunsetUnixtime = ShuttersSunset ( $ shuttersDev , 'unix' ) + 1 ;
2018-09-13 08:11:10 +02:00
2018-10-28 18:12:40 +01:00
$ shutters - > setSunriseUnixTime ( $ shuttersSunriseUnixtime ) ;
$ shutters - > setSunsetUnixTime ( $ shuttersSunsetUnixtime ) ;
2018-10-14 18:19:23 +02:00
## In jedem Rolladen werden die errechneten Zeiten hinterlegt,es sei denn das autoShuttersControlEvening/Morning auf off steht
2018-09-13 08:11:10 +02:00
readingsBeginUpdate ( $ shuttersDevHash ) ;
2018-10-14 18:19:23 +02:00
readingsBulkUpdate (
$ shuttersDevHash ,
'ASC_Time_DriveDown' ,
(
$ ascDev - > getAutoShuttersControlEvening eq 'on'
? strftime (
"%e.%m.%Y - %H:%M" , localtime ( $ shuttersSunsetUnixtime )
)
: 'AutoShuttersControl off'
2019-02-19 21:18:06 +01:00
)
2018-10-14 18:19:23 +02:00
) ;
readingsBulkUpdate (
$ shuttersDevHash ,
'ASC_Time_DriveUp' ,
(
$ ascDev - > getAutoShuttersControlMorning eq 'on'
? strftime ( "%e.%m.%Y - %H:%M" ,
localtime ( $ shuttersSunriseUnixtime ) )
: 'AutoShuttersControl off'
2019-02-19 21:18:06 +01:00
)
2018-10-14 18:19:23 +02:00
) ;
2019-02-19 21:18:06 +01:00
readingsEndUpdate ( $ shuttersDevHash , 0 ) ;
2018-09-13 08:11:10 +02:00
2018-09-07 14:10:46 +02:00
readingsBeginUpdate ( $ hash ) ;
2018-10-14 18:19:23 +02:00
readingsBulkUpdateIfChanged (
$ hash ,
$ shuttersDev . '_nextAstroTimeEvent' ,
(
$ shuttersSunriseUnixtime < $ shuttersSunsetUnixtime
? strftime ( "%e.%m.%Y - %H:%M" ,
localtime ( $ shuttersSunriseUnixtime ) )
: strftime (
"%e.%m.%Y - %H:%M" , localtime ( $ shuttersSunsetUnixtime )
)
)
) ;
readingsEndUpdate ( $ hash , 1 ) ;
RemoveInternalTimer ( $ shutters - > getInTimerFuncHash )
2018-10-17 09:50:11 +02:00
if ( defined ( $ shutters - > getInTimerFuncHash ) ) ;
2018-09-13 08:11:10 +02:00
2018-08-29 14:58:10 +02:00
## kleine Hilfe für InternalTimer damit ich alle benötigten Variablen an die Funktion übergeben kann welche von Internal Timer aufgerufen wird.
2018-10-14 18:19:23 +02:00
my % funcHash = (
hash = > $ hash ,
shuttersdevice = > $ shuttersDev ,
2019-01-23 19:01:54 +01:00
privacyMode = > 0 ,
2018-10-14 18:19:23 +02:00
sunsettime = > $ shuttersSunsetUnixtime ,
sunrisetime = > $ shuttersSunriseUnixtime
) ;
## Ich brauche beim löschen des InternalTimer den Hash welchen ich mitgegeben habe,dieser muss gesichert werden
2018-10-17 09:50:11 +02:00
$ shutters - > setInTimerFuncHash ( \ % funcHash ) ;
2019-01-23 19:01:54 +01:00
## Abfrage für die Sichtschutzfahrt am Abend vor dem eigentlichen kompletten schließen
if ( $ shutters - > getPrivacyDownTime > 0 ) {
2019-01-23 19:04:28 +01:00
if ( ( $ shuttersSunsetUnixtime - $ shutters - > getPrivacyDownTime ) >
( gettimeofday ( ) + 1 ) )
{
$ shuttersSunsetUnixtime =
$ shuttersSunsetUnixtime - $ shutters - > getPrivacyDownTime ;
readingsSingleUpdate (
$ shuttersDevHash ,
2019-05-01 10:11:53 +02:00
'ASC_Time_PrivacyDriveDown' ,
2019-01-23 19:04:28 +01:00
strftime (
"%e.%m.%Y - %H:%M" ,
localtime ( $ shuttersSunsetUnixtime )
) ,
0
) ;
2019-01-23 19:01:54 +01:00
$ funcHash { privacyMode } = 1 ;
}
}
2018-10-14 18:19:23 +02:00
InternalTimer ( $ shuttersSunsetUnixtime ,
2019-06-10 13:41:46 +02:00
'FHEM::AutoShuttersControl::SunSetShuttersAfterTimerFn' , \ % funcHash ) ;
2018-10-14 18:19:23 +02:00
InternalTimer ( $ shuttersSunriseUnixtime ,
2019-06-10 13:41:46 +02:00
'FHEM::AutoShuttersControl::SunRiseShuttersAfterTimerFn' , \ % funcHash ) ;
2018-11-08 08:32:47 +01:00
2018-11-07 08:22:11 +01:00
$ ascDev - > setStateReading ( 'created new drive timer' ) ;
2018-08-28 19:49:01 +02:00
}
2018-08-29 14:58:10 +02:00
## Funktion zum neu setzen der Timer und der Readings für Sunset/Rise
sub RenewSunRiseSetShuttersTimer ($) {
2018-10-14 18:19:23 +02:00
my $ hash = shift ;
foreach ( @ { $ hash - > { helper } { shuttersList } } ) {
2018-10-17 09:50:11 +02:00
$ shutters - > setShuttersDev ( $ _ ) ;
RemoveInternalTimer ( $ shutters - > getInTimerFuncHash ) ;
$ shutters - > setInTimerFuncHash ( undef ) ;
2018-10-14 18:19:23 +02:00
CreateSunRiseSetShuttersTimer ( $ hash , $ _ ) ;
2019-03-07 17:58:30 +01:00
2019-06-03 11:32:50 +02:00
# ### Temporär angelegt damit die neue Attributs Parameter Syntax verteilt werden kann
2019-04-08 10:19:09 +02:00
# CommandAttr(undef, $_ . ' ASC_BrightnessSensor '.AttrVal($_, 'ASC_Brightness_Sensor', 'none').':'.AttrVal($_, 'ASC_Brightness_Reading', 'brightness').' '.AttrVal($_, 'ASC_BrightnessMinVal', 500).':'.AttrVal($_, 'ASC_BrightnessMaxVal', 700)) if ( AttrVal($_, 'ASC_Brightness_Sensor', 'none') ne 'none' );
2019-04-09 12:13:46 +02:00
2019-06-03 11:32:50 +02:00
# $attr{$_}{'ASC_BrightnessSensor'} =
# AttrVal( $_, 'ASC_Brightness_Sensor', 'none' ) . ':'
# . AttrVal( $_, 'ASC_Brightness_Reading', 'brightness' ) . ' '
# . AttrVal( $_, 'ASC_BrightnessMinVal', 500 ) . ':'
# . AttrVal( $_, 'ASC_BrightnessMaxVal', 700 )
# if ( AttrVal( $_, 'ASC_Brightness_Sensor', 'none' ) ne 'none' );
2019-06-04 06:37:38 +02:00
#
2019-06-03 07:44:35 +02:00
# delFromDevAttrList( $_, 'ASC_Brightness_Sensor' )
# ; # temporär muss später gelöscht werden ab Version 0.4.11beta9
# delFromDevAttrList( $_, 'ASC_Brightness_Reading' )
# ; # temporär muss später gelöscht werden ab Version 0.4.11beta9
# delFromDevAttrList( $_, 'ASC_BrightnessMinVal' )
# ; # temporär muss später gelöscht werden ab Version 0.4.11beta9
# delFromDevAttrList( $_, 'ASC_BrightnessMaxVal' )
# ; # temporär muss später gelöscht werden ab Version 0.4.11beta9
2019-06-10 13:41:46 +02:00
$ attr { $ _ } { 'ASC_Shading_MinMax_Elevation' } =
2019-06-10 14:03:03 +02:00
AttrVal ( $ _ , 'ASC_Shading_Min_Elevation' , 'none' )
if ( AttrVal ( $ _ , 'ASC_Shading_Min_Elevation' , 'none' ) ne 'none' ) ;
2019-03-07 17:58:30 +01:00
2019-06-10 14:03:03 +02:00
delFromDevAttrList ( $ _ , 'ASC_Shading_Min_Elevation' )
2019-06-10 13:41:46 +02:00
; # temporär muss später gelöscht werden ab Version 0.6.17
2018-08-29 14:58:10 +02:00
}
}
2018-09-14 20:46:55 +02:00
## Funktion zum hardwareseitigen setzen des lock-out oder blocking beim Rolladen selbst
2018-11-21 08:38:32 +01:00
sub HardewareBlockForShutters ($$) {
2018-10-14 18:19:23 +02:00
my ( $ hash , $ cmd ) = @ _ ;
foreach ( @ { $ hash - > { helper } { shuttersList } } ) {
2018-11-14 15:26:32 +01:00
$ shutters - > setShuttersDev ( $ _ ) ;
2018-11-21 08:38:32 +01:00
$ shutters - > setHardLockOut ( $ cmd ) ;
2018-09-14 20:46:55 +02:00
}
}
2018-11-07 08:22:11 +01:00
## Funktion für das wiggle aller Shutters zusammen
sub wiggleAll ($) {
my $ hash = shift ;
foreach ( @ { $ hash - > { helper } { shuttersList } } ) {
2018-11-08 08:32:47 +01:00
wiggle ( $ hash , $ _ ) ;
2018-11-07 08:22:11 +01:00
}
}
sub wiggle ($$) {
my ( $ hash , $ shuttersDev ) = @ _ ;
$ shutters - > setShuttersDev ( $ shuttersDev ) ;
$ shutters - > setNoOffset ( 1 ) ;
2018-11-29 21:33:08 +01:00
$ shutters - > setLastDrive ( 'wiggle begin drive' ) ;
2018-11-07 08:22:11 +01:00
2018-11-08 08:32:47 +01:00
my % h = (
2018-11-07 08:22:11 +01:00
shuttersDev = > $ shutters - > getShuttersDev ,
posValue = > $ shutters - > getStatus ,
2018-11-29 21:33:08 +01:00
lastDrive = > 'wiggle end drive' ,
2018-11-07 08:22:11 +01:00
) ;
if ( $ shutters - > getShuttersPosCmdValueNegate ) {
2018-11-19 21:58:55 +01:00
if ( $ shutters - > getStatus >= $ shutters - > getClosedPos / 2 ) {
2018-11-19 09:06:50 +01:00
$ shutters - > setDriveCmd (
2018-11-19 21:58:55 +01:00
$ shutters - > getStatus - $ shutters - > getWiggleValue ) ;
2018-11-19 09:06:50 +01:00
}
else {
$ shutters - > setDriveCmd (
2018-11-19 21:58:55 +01:00
$ shutters - > getStatus + $ shutters - > getWiggleValue ) ;
2018-11-07 08:22:11 +01:00
}
}
else {
if ( $ shutters - > getStatus >= $ shutters - > getOpenPos / 2 ) {
2018-11-19 09:06:50 +01:00
$ shutters - > setDriveCmd (
$ shutters - > getStatus - $ shutters - > getWiggleValue ) ;
}
else {
$ shutters - > setDriveCmd (
$ shutters - > getStatus + $ shutters - > getWiggleValue ) ;
2018-11-07 08:22:11 +01:00
}
}
2019-04-09 12:13:46 +02:00
InternalTimer ( gettimeofday ( ) + 60 ,
'FHEM::AutoShuttersControl::SetCmdFn' , \ % h ) ;
2018-11-07 08:22:11 +01:00
}
####
2018-08-29 14:58:10 +02:00
## Funktion welche beim Ablaufen des Timers für Sunset aufgerufen werden soll
2018-08-28 19:49:01 +02:00
sub SunSetShuttersAfterTimerFn ($) {
2018-10-14 18:19:23 +02:00
my $ funcHash = shift ;
my $ hash = $ funcHash - > { hash } ;
my $ shuttersDev = $ funcHash - > { shuttersdevice } ;
2018-10-10 10:43:42 +02:00
$ shutters - > setShuttersDev ( $ shuttersDev ) ;
2018-09-10 20:12:26 +02:00
2019-05-10 11:39:07 +02:00
$ shutters - > setSunset ( 1 ) ;
$ shutters - > setSunrise ( 0 ) ;
2019-05-17 14:20:57 +02:00
2018-09-10 20:12:26 +02:00
my $ posValue ;
2019-06-04 06:37:38 +02:00
2018-10-14 18:19:23 +02:00
if ( CheckIfShuttersWindowRecOpen ( $ shuttersDev ) == 0
or $ shutters - > getVentilateOpen eq 'off' )
{
$ posValue = $ shutters - > getClosedPos ;
2018-09-10 20:12:26 +02:00
}
2019-06-04 06:37:38 +02:00
elsif ( $ shutters - > getQueryShuttersPos ( $ shutters - > getVentilatePos ) ) {
$ posValue = $ shutters - > getStatus ;
}
2018-10-14 18:19:23 +02:00
else { $ posValue = $ shutters - > getVentilatePos ; }
2018-10-27 13:36:11 +02:00
2018-10-28 18:12:40 +01:00
my $ homemode = $ shutters - > getRoommatesStatus ;
$ homemode = $ ascDev - > getResidentsStatus if ( $ homemode eq 'none' ) ;
2019-06-10 14:03:03 +02:00
if (
$ ascDev - > getAutoShuttersControlEvening eq 'on'
and IsAfterShuttersManualBlocking ( $ shuttersDev )
and (
2019-01-02 09:38:00 +01:00
$ shutters - > getModeDown eq $ homemode
or ( $ shutters - > getModeDown eq 'absent'
and $ homemode eq 'gone' )
or $ shutters - > getModeDown eq 'always'
2019-06-10 14:03:03 +02:00
)
2018-11-19 09:06:50 +01:00
)
2018-10-31 09:58:23 +01:00
{
2019-06-04 06:37:38 +02:00
# my $queryShuttersPosPrivacyDown = (
# $shutters->getShuttersPosCmdValueNegate
# ? $shutters->getStatus > $shutters->getPrivacyDownPos
# : $shutters->getStatus < $shutters->getPrivacyDownPos
# );
2019-04-20 18:18:50 +02:00
if ( $ funcHash - > { privacyMode } == 1
2019-06-04 06:37:38 +02:00
and
not $ shutters - > getQueryShuttersPos ( $ shutters - > getPrivacyDownPos ) )
2019-04-12 13:58:26 +02:00
{
$ shutters - > setLastDrive ( 'privacy position' ) ;
2019-04-20 18:18:50 +02:00
ShuttersCommandSet ( $ hash , $ shuttersDev ,
2019-04-12 13:58:26 +02:00
$ shutters - > getPrivacyDownPos ) ;
}
elsif ( $ funcHash - > { privacyMode } == 0 ) {
$ shutters - > setLastDrive ( 'night close' ) ;
2019-04-20 18:18:50 +02:00
ShuttersCommandSet ( $ hash , $ shuttersDev , $ posValue ) ;
2019-04-12 13:58:26 +02:00
}
2018-10-30 19:10:50 +01:00
}
2018-09-10 20:12:26 +02:00
2018-10-14 18:19:23 +02:00
CreateSunRiseSetShuttersTimer ( $ hash , $ shuttersDev ) ;
2018-08-28 19:49:01 +02:00
}
2018-08-29 14:58:10 +02:00
## Funktion welche beim Ablaufen des Timers für Sunrise aufgerufen werden soll
2018-08-28 19:49:01 +02:00
sub SunRiseShuttersAfterTimerFn ($) {
2018-10-14 18:19:23 +02:00
my $ funcHash = shift ;
my $ hash = $ funcHash - > { hash } ;
my $ shuttersDev = $ funcHash - > { shuttersdevice } ;
2018-10-10 10:43:42 +02:00
$ shutters - > setShuttersDev ( $ shuttersDev ) ;
2019-05-17 14:20:57 +02:00
2019-05-10 11:39:07 +02:00
$ shutters - > setSunset ( 0 ) ;
$ shutters - > setSunrise ( 1 ) ;
2018-10-14 18:19:23 +02:00
2018-10-28 18:12:40 +01:00
my $ homemode = $ shutters - > getRoommatesStatus ;
$ homemode = $ ascDev - > getResidentsStatus if ( $ homemode eq 'none' ) ;
2019-06-10 14:03:03 +02:00
if (
$ ascDev - > getAutoShuttersControlMorning eq 'on'
and (
$ shutters - > getModeUp eq $ homemode
or ( $ shutters - > getModeUp eq 'absent'
and $ homemode eq 'gone' )
or $ shutters - > getModeUp eq 'always'
)
2018-11-19 09:06:50 +01:00
)
2018-10-14 18:19:23 +02:00
{
2019-06-10 14:03:03 +02:00
2018-10-30 19:10:50 +01:00
if (
2018-10-31 09:58:23 +01:00
(
$ shutters - > getRoommatesStatus eq 'home'
or $ shutters - > getRoommatesStatus eq 'awoken'
or $ shutters - > getRoommatesStatus eq 'absent'
or $ shutters - > getRoommatesStatus eq 'gone'
or $ shutters - > getRoommatesStatus eq 'none'
)
2019-01-17 09:47:53 +01:00
and (
$ ascDev - > getSelfDefense eq 'off'
or ( $ ascDev - > getSelfDefense eq 'on'
and CheckIfShuttersWindowRecOpen ( $ shuttersDev ) == 0 )
)
2019-05-24 19:58:26 +02:00
and $ shutters - > getShadingStatus ne 'in'
2018-10-30 19:10:50 +01:00
)
{
$ shutters - > setLastDrive ( 'day open' ) ;
ShuttersCommandSet ( $ hash , $ shuttersDev , $ shutters - > getOpenPos ) ;
}
2018-09-02 23:00:40 +02:00
}
2019-06-10 13:41:46 +02:00
2018-10-14 18:19:23 +02:00
CreateSunRiseSetShuttersTimer ( $ hash , $ shuttersDev ) ;
2018-08-28 19:49:01 +02:00
}
2018-10-08 03:59:51 +02:00
sub CreateNewNotifyDev ($) {
2018-10-14 18:19:23 +02:00
my $ hash = shift ;
my $ name = $ hash - > { NAME } ;
2018-10-08 03:59:51 +02:00
2018-10-14 18:19:23 +02:00
$ hash - > { NOTIFYDEV } = "global," . $ name ;
2018-10-08 03:59:51 +02:00
delete $ hash - > { monitoredDevs } ;
2018-10-14 18:38:44 +02:00
2018-10-14 18:19:23 +02:00
CommandDeleteReading ( undef , $ name . ' .monitoredDevs' ) ;
2018-10-17 15:58:05 +02:00
my $ shuttersList = '' ;
2018-10-14 18:19:23 +02:00
foreach ( @ { $ hash - > { helper } { shuttersList } } ) {
AddNotifyDev ( $ hash , AttrVal ( $ _ , 'ASC_Roommate_Device' , 'none' ) ,
$ _ , 'ASC_Roommate_Device' )
if ( AttrVal ( $ _ , 'ASC_Roommate_Device' , 'none' ) ne 'none' ) ;
AddNotifyDev ( $ hash , AttrVal ( $ _ , 'ASC_WindowRec' , 'none' ) ,
$ _ , 'ASC_WindowRec' )
if ( AttrVal ( $ _ , 'ASC_WindowRec' , 'none' ) ne 'none' ) ;
2019-03-07 17:58:30 +01:00
AddNotifyDev ( $ hash , AttrVal ( $ _ , 'ASC_BrightnessSensor' , 'none' ) ,
$ _ , 'ASC_BrightnessSensor' )
if ( AttrVal ( $ _ , 'ASC_BrightnessSensor' , 'none' ) ne 'none' ) ;
2019-03-04 14:02:54 +01:00
2019-04-09 12:13:46 +02:00
$ shuttersList = $ shuttersList . ',' . $ _ ;
2018-10-08 03:59:51 +02:00
}
2019-03-07 17:58:30 +01:00
2019-03-04 14:02:54 +01:00
AddNotifyDev ( $ hash , AttrVal ( $ name , 'ASC_residentsDev' , 'none' ) ,
$ name , 'ASC_residentsDev' )
if ( AttrVal ( $ name , 'ASC_residentsDev' , 'none' ) ne 'none' ) ;
AddNotifyDev ( $ hash , AttrVal ( $ name , 'ASC_rainSensor' , 'none' ) ,
$ name , 'ASC_rainSensor' )
if ( AttrVal ( $ name , 'ASC_rainSensor' , 'none' ) ne 'none' ) ;
2018-11-14 03:41:38 +01:00
AddNotifyDev ( $ hash , AttrVal ( $ name , 'ASC_twilightDevice' , 'none' ) ,
2018-11-14 15:26:32 +01:00
$ name , 'ASC_twilightDevice' )
if ( AttrVal ( $ name , 'ASC_twilightDevice' , 'none' ) ne 'none' ) ;
2019-03-04 10:57:39 +01:00
AddNotifyDev ( $ hash , AttrVal ( $ name , 'ASC_windSensor' , 'none' ) ,
$ name , 'ASC_windSensor' )
if ( AttrVal ( $ name , 'ASC_windSensor' , 'none' ) ne 'none' ) ;
2019-04-09 12:13:46 +02:00
2018-10-17 15:58:05 +02:00
$ hash - > { NOTIFYDEV } = $ hash - > { NOTIFYDEV } . $ shuttersList ;
2018-10-08 03:59:51 +02:00
}
2018-09-21 08:44:38 +02:00
sub GetShuttersInformation ($) {
2018-10-28 18:12:40 +01:00
my $ hash = shift ;
my $ ret = '<html><table><tr><td>' ;
2018-09-21 08:44:38 +02:00
$ ret . = '<table class="block wide">' ;
$ ret . = '<tr class="even">' ;
2018-10-09 18:05:55 +02:00
$ ret . = "<td><b>Shutters</b></td>" ;
2018-09-21 20:03:02 +02:00
$ ret . = "<td> </td>" ;
$ ret . = "<td><b>Next DriveUp</b></td>" ;
$ ret . = "<td> </td>" ;
$ ret . = "<td><b>Next DriveDown</b></td>" ;
$ ret . = "<td> </td>" ;
2018-10-28 18:12:40 +01:00
$ ret . = "<td><b>ASC Up</b></td>" ;
$ ret . = "<td> </td>" ;
$ ret . = "<td><b>ASC Down</b></td>" ;
$ ret . = "<td> </td>" ;
$ ret . = "<td><b>ASC Mode Up</b></td>" ;
$ ret . = "<td> </td>" ;
$ ret . = "<td><b>ASC Mode Down</b></td>" ;
$ ret . = "<td> </td>" ;
2018-09-21 20:03:02 +02:00
$ ret . = "<td><b>Partymode</b></td>" ;
$ ret . = "<td> </td>" ;
$ ret . = "<td><b>Lock-Out</b></td>" ;
2018-10-28 18:12:40 +01:00
$ ret . = "<td> </td>" ;
$ ret . = "<td><b>Last Drive</b></td>" ;
$ ret . = "<td> </td>" ;
$ ret . = "<td><b>Position</b></td>" ;
$ ret . = "<td> </td>" ;
$ ret . = "<td><b>Last Position</b></td>" ;
2019-03-23 21:57:19 +01:00
$ ret . = "<td> </td>" ;
$ ret . = "<td><b>Shading Info</b></td>" ;
2018-09-21 08:44:38 +02:00
$ ret . = '</tr>' ;
2018-09-21 22:12:24 +02:00
2018-10-28 18:12:40 +01:00
my $ linecount = 1 ;
foreach my $ shutter ( @ { $ hash - > { helper } { shuttersList } } ) {
$ shutters - > setShuttersDev ( $ shutter ) ;
if ( $ linecount % 2 == 0 ) { $ ret . = '<tr class="even">' ; }
else { $ ret . = '<tr class="odd">' ; }
$ ret . = "<td>$shutter</td>" ;
$ ret . = "<td> </td>" ;
$ ret . = "<td>"
. strftime ( "%e.%m.%Y - %H:%M:%S" ,
localtime ( $ shutters - > getSunriseUnixTime ) )
. "</td>" ;
$ ret . = "<td> </td>" ;
$ ret . = "<td>"
. strftime ( "%e.%m.%Y - %H:%M:%S" ,
localtime ( $ shutters - > getSunsetUnixTime ) )
. "</td>" ;
$ ret . = "<td> </td>" ;
2018-11-03 19:01:29 +01:00
$ ret . = "<td>" . $ shutters - > getUp . "</td>" ;
2018-10-28 18:12:40 +01:00
$ ret . = "<td> </td>" ;
2018-11-03 19:01:29 +01:00
$ ret . = "<td>" . $ shutters - > getDown . "</td>" ;
2018-10-28 18:12:40 +01:00
$ ret . = "<td> </td>" ;
$ ret . = "<td>" . $ shutters - > getModeUp . "</td>" ;
$ ret . = "<td> </td>" ;
$ ret . = "<td>" . $ shutters - > getModeDown . "</td>" ;
$ ret . = "<td> </td>" ;
$ ret . = "<td>" . $ shutters - > getPartyMode . "</td>" ;
$ ret . = "<td> </td>" ;
$ ret . = "<td>" . $ shutters - > getLockOut . "</td>" ;
$ ret . = "<td> </td>" ;
$ ret . = "<td>" . $ shutters - > getLastDrive . "</td>" ;
$ ret . = "<td> </td>" ;
$ ret . = "<td>" . $ shutters - > getStatus . "</td>" ;
$ ret . = "<td> </td>" ;
$ ret . = "<td>" . $ shutters - > getLastPos . "</td>" ;
2019-03-23 21:57:19 +01:00
$ ret . = "<td> </td>" ;
2019-04-09 12:13:46 +02:00
$ ret . = "<td>"
. $ shutters - > getShadingStatus . ' - '
. strftime ( "%H:%M:%S" ,
localtime ( $ shutters - > getShadingStatusTimestamp ) )
. "</td>" ;
2018-10-28 18:12:40 +01:00
$ ret . = '</tr>' ;
$ linecount + + ;
2018-09-21 08:44:38 +02:00
}
$ ret . = '</table></td></tr>' ;
$ ret . = '</table></html>' ;
return $ ret ;
}
2018-10-08 03:59:51 +02:00
sub GetMonitoredDevs ($) {
2018-10-14 18:19:23 +02:00
my $ hash = shift ;
my $ notifydevs = eval {
decode_json ( ReadingsVal ( $ hash - > { NAME } , '.monitoredDevs' , 'none' ) ) ;
} ;
2018-10-08 03:59:51 +02:00
my $ ret = '<html><table><tr><td>' ;
$ ret . = '<table class="block wide">' ;
$ ret . = '<tr class="even">' ;
2018-10-09 18:05:55 +02:00
$ ret . = "<td><b>Shutters/ASC-Device</b></td>" ;
2018-10-08 03:59:51 +02:00
$ ret . = "<td> </td>" ;
2018-10-09 18:05:55 +02:00
$ ret . = "<td><b>NOTIFYDEV</b></td>" ;
2018-10-08 03:59:51 +02:00
$ ret . = "<td> </td>" ;
$ ret . = "<td><b>Attribut</b></td>" ;
$ ret . = "<td> </td>" ;
$ ret . = '</tr>' ;
2018-10-14 18:19:23 +02:00
if ( ref ( $ notifydevs ) eq "HASH" ) {
2018-10-08 03:59:51 +02:00
my $ linecount = 1 ;
2018-10-14 18:19:23 +02:00
foreach my $ notifydev ( sort keys ( % { $ notifydevs } ) ) {
if ( ref ( $ notifydevs - > { $ notifydev } ) eq "HASH" ) {
foreach
my $ shutters ( sort keys ( % { $ notifydevs - > { $ notifydev } } ) )
{
if ( $ linecount % 2 == 0 ) { $ ret . = '<tr class="even">' ; }
else { $ ret . = '<tr class="odd">' ; }
2018-10-08 03:59:51 +02:00
$ ret . = "<td>$shutters</td>" ;
$ ret . = "<td> </td>" ;
2018-10-09 18:05:55 +02:00
$ ret . = "<td>$notifydev</td>" ;
$ ret . = "<td> </td>" ;
2018-10-08 03:59:51 +02:00
$ ret . = "<td>$notifydevs->{$notifydev}{$shutters}</td>" ;
$ ret . = "<td> </td>" ;
$ ret . = '</tr>' ;
$ linecount + + ;
}
}
}
}
$ ret . = '</table></td></tr>' ;
$ ret . = '</table></html>' ;
return $ ret ;
}
2018-08-27 11:08:08 +02:00
#################################
## my little helper
#################################
2018-11-15 00:44:41 +01:00
sub AutoSearchTwilightDev ($) {
my $ hash = shift ;
my $ name = $ hash - > { NAME } ;
2018-11-19 09:06:50 +01:00
2018-11-15 00:44:41 +01:00
if ( devspec2array ( 'TYPE=(Astro|Twilight)' ) > 0 ) {
CommandAttr ( undef ,
$ name
2018-11-19 09:06:50 +01:00
. ' ASC_twilightDevice '
. ( devspec2array ( 'TYPE=(Astro|Twilight)' ) ) [ 0 ] )
if ( AttrVal ( $ name , 'ASC_twilightDevice' , 'none' ) eq 'none' ) ;
2018-11-15 00:44:41 +01:00
}
}
2019-03-06 15:53:48 +01:00
sub GetAttrValues ($@) {
2019-04-25 17:15:56 +02:00
my ( $ dev , $ attribut , $ default ) = @ _ ;
2019-03-06 15:53:48 +01:00
2019-04-25 21:34:46 +02:00
my @ values = split ( ' ' ,
AttrVal ( $ dev , $ attribut , ( defined ( $ default ) ? $ default : 'none' ) ) ) ;
2019-04-09 12:13:46 +02:00
my ( $ value1 , $ value2 ) = split ( ':' , $ values [ 0 ] ) ;
my ( $ value3 , $ value4 ) = split ( ':' , $ values [ 1 ] )
if ( defined ( $ values [ 1 ] ) ) ;
my ( $ value5 , $ value6 ) = split ( ':' , $ values [ 2 ] )
if ( defined ( $ values [ 2 ] ) ) ;
my ( $ value7 , $ value8 ) = split ( ':' , $ values [ 2 ] )
if ( defined ( $ values [ 3 ] ) ) ;
2019-03-12 23:02:02 +01:00
2019-04-09 12:13:46 +02:00
return (
$ value1 ,
defined ( $ value2 ) ? $ value2 : 'none' ,
defined ( $ value3 ) ? $ value3 : 'none' ,
defined ( $ value4 ) ? $ value4 : 'none' ,
defined ( $ value5 ) ? $ value5 : 'none' ,
defined ( $ value6 ) ? $ value6 : 'none' ,
defined ( $ value7 ) ? $ value7 : 'none' ,
defined ( $ value8 ) ? $ value8 : 'none'
) ;
2019-03-06 15:53:48 +01:00
}
2018-08-29 14:58:10 +02:00
# Hilfsfunktion welche meinen ReadingString zum finden der getriggerten Devices und der Zurdnung was das Device überhaupt ist und zu welchen Rolladen es gehört aus liest und das Device extraiert
2018-09-30 21:05:30 +02:00
sub ExtractNotifyDevFromEvent ($$$) {
2018-10-14 18:19:23 +02:00
my ( $ hash , $ shuttersDev , $ shuttersAttr ) = @ _ ;
2018-09-30 21:05:30 +02:00
my % notifyDevs ;
2018-10-14 18:19:23 +02:00
while ( my $ notifyDev = each % { $ hash - > { monitoredDevs } } ) {
Log3 ( $ hash - > { NAME } , 4 ,
"AutoShuttersControl ($hash->{NAME}) - ExtractNotifyDevFromEvent - NotifyDev: "
. $ notifyDev ) ;
Log3 ( $ hash - > { NAME } , 5 ,
"AutoShuttersControl ($hash->{NAME}) - ExtractNotifyDevFromEvent - ShuttersDev: "
. $ shuttersDev ) ;
if ( defined ( $ hash - > { monitoredDevs } { $ notifyDev } { $ shuttersDev } )
and $ hash - > { monitoredDevs } { $ notifyDev } { $ shuttersDev } eq
$ shuttersAttr )
{
Log3 ( $ hash - > { NAME } , 4 ,
"AutoShuttersControl ($hash->{NAME}) - ExtractNotifyDevFromEvent - ShuttersDevHash: "
. $ hash - > { monitoredDevs } { $ notifyDev } { $ shuttersDev } ) ;
Log3 ( $ hash - > { NAME } , 5 ,
"AutoShuttersControl ($hash->{NAME}) - ExtractNotifyDevFromEvent - return ShuttersDev: "
. $ notifyDev ) ;
2018-09-30 21:05:30 +02:00
$ notifyDevs { $ notifyDev } = $ shuttersDev ;
2018-08-27 11:08:08 +02:00
}
}
2018-09-30 21:05:30 +02:00
return \ % notifyDevs ;
2018-08-16 10:37:09 +02:00
}
2018-08-31 09:32:16 +02:00
## Ist Tag oder Nacht für den entsprechende Rolladen
2019-04-20 21:53:05 +02:00
sub IsDay ($) {
my ( $ shuttersDev ) = @ _ ;
2019-02-22 10:02:48 +01:00
$ shutters - > setShuttersDev ( $ shuttersDev ) ;
2019-02-22 10:56:24 +01:00
2019-04-20 21:53:05 +02:00
my $ isday = ( ShuttersSunrise ( $ shuttersDev , 'unix' ) >
ShuttersSunset ( $ shuttersDev , 'unix' ) ? 1 : 0 ) ;
2019-02-22 10:56:24 +01:00
my $ respIsDay = $ isday ;
2019-02-22 10:02:48 +01:00
2019-04-23 14:53:39 +02:00
ASC_Debug ( 'FnIsDay: ' . $ shuttersDev . ' Allgemein: ' . $ respIsDay ) ;
if (
(
2019-05-07 05:58:59 +02:00
$ shutters - > getModeDown eq 'brightness'
or $ shutters - > getModeUp eq 'brightness'
2019-04-23 14:53:39 +02:00
)
2019-05-07 05:58:59 +02:00
or (
2019-04-23 14:53:39 +02:00
(
2019-05-07 05:58:59 +02:00
(
(
int ( gettimeofday ( ) / 86400 ) != int (
computeAlignTime ( '24:00' ,
$ shutters - > getTimeUpEarly ) / 86400
)
and not IsWe ( )
)
or (
int ( gettimeofday ( ) / 86400 ) != int (
computeAlignTime ( '24:00' ,
$ shutters - > getTimeUpWeHoliday ) / 86400
)
and IsWe ( )
and $ ascDev - > getSunriseTimeWeHoliday eq 'on'
)
2019-04-23 14:53:39 +02:00
)
and int ( gettimeofday ( ) / 86400 ) == int (
computeAlignTime ( '24:00' , $ shutters - > getTimeUpLate ) /
86400
)
)
or (
int ( gettimeofday ( ) / 86400 ) != int (
computeAlignTime ( '24:00' , $ shutters - > getTimeDownEarly ) /
86400
)
and int ( gettimeofday ( ) / 86400 ) == int (
computeAlignTime ( '24:00' , $ shutters - > getTimeDownLate ) /
86400
)
)
)
)
2019-04-23 12:33:01 +02:00
{
my $ brightnessMinVal ;
if ( $ shutters - > getBrightnessMinVal > - 1 ) {
$ brightnessMinVal = $ shutters - > getBrightnessMinVal ;
}
else {
$ brightnessMinVal = $ ascDev - > getBrightnessMinVal ;
}
2019-02-22 10:16:24 +01:00
2019-04-23 12:33:01 +02:00
my $ brightnessMaxVal ;
if ( $ shutters - > getBrightnessMaxVal > - 1 ) {
$ brightnessMaxVal = $ shutters - > getBrightnessMaxVal ;
}
else {
$ brightnessMaxVal = $ ascDev - > getBrightnessMaxVal ;
}
2019-04-23 14:53:39 +02:00
2019-05-07 11:34:53 +02:00
##### Nach Sonnenuntergang / Abends
2019-04-23 12:33:01 +02:00
$ respIsDay = (
2019-04-09 12:13:46 +02:00
(
2019-05-07 11:34:53 +02:00
(
$ shutters - > getBrightness > $ brightnessMinVal
and $ isday
and not $ shutters - > getSunset
)
2019-05-07 05:58:59 +02:00
or not $ shutters - > getSunset
2019-04-23 12:33:01 +02:00
) ? 1 : 0
) if ( $ shutters - > getDown eq 'brightness' ) ;
2019-04-23 14:53:39 +02:00
2019-04-23 12:33:01 +02:00
ASC_Debug ( 'FnIsDay: '
2019-04-23 14:53:39 +02:00
. $ shuttersDev
. ' getDownBrightness: '
. $ respIsDay
. ' Brightness: '
. $ shutters - > getBrightness
. ' BrightnessMin: '
. $ brightnessMinVal
. ' Sunset: '
. $ shutters - > getSunset ) ;
2019-04-23 12:33:01 +02:00
2019-05-07 11:34:53 +02:00
##### Nach Sonnenauf / Morgens
2019-04-23 12:33:01 +02:00
$ respIsDay = (
(
2019-05-07 11:34:53 +02:00
(
$ shutters - > getBrightness > $ brightnessMaxVal
and not $ isday
and not $ shutters - > getSunrise
)
2019-04-23 14:53:39 +02:00
or $ respIsDay
or $ shutters - > getSunrise
2019-04-23 12:33:01 +02:00
) ? 1 : 0
) if ( $ shutters - > getUp eq 'brightness' ) ;
2019-04-23 14:53:39 +02:00
2019-04-23 12:33:01 +02:00
ASC_Debug ( 'FnIsDay: '
2019-04-23 14:53:39 +02:00
. $ shuttersDev
. ' getUpBrightness: '
. $ respIsDay
. ' Brightness: '
. $ shutters - > getBrightness
. ' BrightnessMax: '
. $ brightnessMaxVal
2019-05-07 05:58:59 +02:00
. ' Sunrise: '
2019-04-23 14:53:39 +02:00
. $ shutters - > getSunrise ) ;
2019-04-23 12:33:01 +02:00
}
2019-02-22 10:02:48 +01:00
return $ respIsDay ;
2018-08-31 09:32:16 +02:00
}
2019-04-20 21:53:05 +02:00
sub ShuttersSunrise ($$) {
my ( $ shuttersDev , $ tm ) =
2018-10-14 18:19:23 +02:00
@ _ ; # Tm steht für Timemode und bedeutet Realzeit oder Unixzeit
2018-09-13 08:11:10 +02:00
my $ autoAstroMode ;
2018-10-10 10:43:42 +02:00
$ shutters - > setShuttersDev ( $ shuttersDev ) ;
2018-09-18 09:35:45 +02:00
2018-10-14 18:19:23 +02:00
if ( $ shutters - > getAutoAstroModeMorning ne 'none' ) {
$ autoAstroMode = $ shutters - > getAutoAstroModeMorning ;
$ autoAstroMode =
$ autoAstroMode . '=' . $ shutters - > getAutoAstroModeMorningHorizon
if ( $ autoAstroMode eq 'HORIZON' ) ;
}
else {
$ autoAstroMode = $ ascDev - > getAutoAstroModeMorning ;
$ autoAstroMode =
2018-11-03 19:01:29 +01:00
$ autoAstroMode . '=' . $ ascDev - > getAutoAstroModeMorningHorizon
2018-10-14 18:19:23 +02:00
if ( $ autoAstroMode eq 'HORIZON' ) ;
2018-09-13 15:21:29 +02:00
}
2018-10-14 18:19:23 +02:00
my $ oldFuncHash = $ shutters - > getInTimerFuncHash ;
2018-09-07 11:02:46 +02:00
my $ shuttersSunriseUnixtime ;
2018-08-28 19:49:01 +02:00
2018-10-14 18:19:23 +02:00
if ( $ tm eq 'unix' ) {
2018-11-03 19:01:29 +01:00
if ( $ shutters - > getUp eq 'astro' ) {
2018-10-14 18:19:23 +02:00
if ( ( IsWe ( ) or IsWeTomorrow ( ) )
2018-10-31 09:55:49 +01:00
and $ ascDev - > getSunriseTimeWeHoliday eq 'on' )
2018-10-14 18:19:23 +02:00
{
if ( not IsWeTomorrow ( ) ) {
2018-10-31 09:58:23 +01:00
if (
IsWe ( )
2018-10-31 09:55:49 +01:00
and int ( gettimeofday ( ) / 86400 ) == int (
(
computeAlignTime (
'24:00' ,
sunrise_abs (
2018-10-31 09:58:23 +01:00
$ autoAstroMode , 0 ,
2018-10-31 09:55:49 +01:00
$ shutters - > getTimeUpWeHoliday
)
) + 1
) / 86400
)
)
{
$ shuttersSunriseUnixtime = (
computeAlignTime (
'24:00' ,
sunrise_abs (
$ autoAstroMode , 0 ,
$ shutters - > getTimeUpWeHoliday
)
) + 1
) ;
}
elsif (
2018-10-14 18:19:23 +02:00
int ( gettimeofday ( ) / 86400 ) == int (
(
computeAlignTime (
'24:00' ,
sunrise_abs (
$ autoAstroMode ,
0 ,
$ shutters - > getTimeUpEarly ,
$ shutters - > getTimeUpLate
)
) + 1
) / 86400
)
)
{
$ shuttersSunriseUnixtime = (
computeAlignTime (
'24:00' ,
sunrise_abs (
$ autoAstroMode , 0 ,
$ shutters - > getTimeUpWeHoliday
)
) + 1
) ;
2018-09-24 15:29:39 +02:00
}
2018-10-14 18:19:23 +02:00
else {
$ shuttersSunriseUnixtime = (
computeAlignTime (
'24:00' ,
sunrise_abs (
$ autoAstroMode ,
0 ,
$ shutters - > getTimeUpEarly ,
$ shutters - > getTimeUpLate
)
) + 1
) ;
2018-09-24 15:29:39 +02:00
}
}
2018-10-14 18:19:23 +02:00
else {
2019-04-09 12:12:13 +02:00
if (
IsWe ( )
2019-04-09 12:13:46 +02:00
and (
int ( gettimeofday ( ) / 86400 ) == int (
(
computeAlignTime (
'24:00' ,
sunrise_abs (
$ autoAstroMode , 0 ,
$ shutters - > getTimeUpWeHoliday
)
) + 1
) / 86400
)
or int ( gettimeofday ( ) / 86400 ) != int (
(
computeAlignTime (
'24:00' ,
sunrise_abs (
$ autoAstroMode , 0 ,
$ shutters - > getTimeUpWeHoliday
)
) + 1
) / 86400
)
2019-04-09 12:12:13 +02:00
)
)
{
$ shuttersSunriseUnixtime = (
computeAlignTime (
'24:00' ,
sunrise_abs (
$ autoAstroMode , 0 ,
$ shutters - > getTimeUpWeHoliday
)
) + 1
) ;
}
elsif (
int ( gettimeofday ( ) / 86400 ) == int (
(
computeAlignTime (
'24:00' ,
sunrise_abs (
$ autoAstroMode ,
0 ,
$ shutters - > getTimeUpEarly ,
$ shutters - > getTimeUpLate
)
) + 1
) / 86400
)
)
{
$ shuttersSunriseUnixtime = (
computeAlignTime (
'24:00' ,
sunrise_abs (
2019-04-09 12:13:46 +02:00
$ autoAstroMode ,
0 ,
2019-04-09 12:12:13 +02:00
$ shutters - > getTimeUpEarly ,
$ shutters - > getTimeUpLate
)
) + 1
) ;
}
else {
if (
2019-04-09 12:13:46 +02:00
int ( gettimeofday ( ) / 86400 ) == int (
2019-04-09 12:12:13 +02:00
(
computeAlignTime (
'24:00' ,
sunrise_abs (
$ autoAstroMode , 0 ,
$ shutters - > getTimeUpWeHoliday
)
) + 1
) / 86400
2019-04-09 12:13:46 +02:00
)
2019-04-09 12:12:13 +02:00
)
{
$ shuttersSunriseUnixtime = (
computeAlignTime (
'24:00' ,
sunrise_abs (
$ autoAstroMode , 0 ,
$ shutters - > getTimeUpWeHoliday
)
) + 86401
) ;
}
else {
$ shuttersSunriseUnixtime = (
computeAlignTime (
'24:00' ,
sunrise_abs (
$ autoAstroMode , 0 ,
$ shutters - > getTimeUpWeHoliday
)
) + 1
) ;
}
}
2019-04-09 12:13:46 +02:00
}
2018-09-18 09:35:45 +02:00
}
2018-10-14 18:19:23 +02:00
else {
$ shuttersSunriseUnixtime = (
computeAlignTime (
'24:00' ,
sunrise_abs (
$ autoAstroMode ,
0 ,
$ shutters - > getTimeUpEarly ,
$ shutters - > getTimeUpLate
)
) + 1
) ;
}
if ( defined ( $ oldFuncHash )
and ref ( $ oldFuncHash ) eq 'HASH'
and ( IsWe ( ) or IsWeTomorrow ( ) )
2018-10-31 09:55:49 +01:00
and $ ascDev - > getSunriseTimeWeHoliday eq 'on' )
2018-10-14 18:19:23 +02:00
{
if ( not IsWeTomorrow ( ) ) {
if (
int ( gettimeofday ( ) / 86400 ) == int (
(
computeAlignTime (
'24:00' ,
sunrise_abs (
$ autoAstroMode ,
0 ,
$ shutters - > getTimeUpEarly ,
$ shutters - > getTimeUpLate
)
) + 1
) / 86400
)
)
{
2019-04-09 09:37:34 +02:00
$ shuttersSunriseUnixtime =
( $ shuttersSunriseUnixtime + 86400 )
2018-10-14 18:19:23 +02:00
if ( $ shuttersSunriseUnixtime <
( $ oldFuncHash - > { sunrisetime } + 180 )
and $ oldFuncHash - > { sunrisetime } < gettimeofday ( ) ) ;
2018-09-27 10:19:41 +02:00
}
}
2018-09-07 11:02:46 +02:00
}
2018-10-14 18:19:23 +02:00
elsif ( defined ( $ oldFuncHash ) and ref ( $ oldFuncHash ) eq 'HASH' ) {
2019-04-09 09:37:34 +02:00
$ shuttersSunriseUnixtime = ( $ shuttersSunriseUnixtime + 86400 )
2018-10-14 18:19:23 +02:00
if ( $ shuttersSunriseUnixtime <
( $ oldFuncHash - > { sunrisetime } + 180 )
and $ oldFuncHash - > { sunrisetime } < gettimeofday ( ) ) ;
}
}
2018-11-03 19:01:29 +01:00
elsif ( $ shutters - > getUp eq 'time' ) {
2018-11-17 17:10:45 +01:00
if ( ( IsWe ( ) or IsWeTomorrow ( ) )
and $ ascDev - > getSunriseTimeWeHoliday eq 'on' )
{
if ( not IsWeTomorrow ( ) ) {
if (
2019-05-28 08:39:52 +02:00
int ( gettimeofday ( ) / 86400 ) == int (
2018-11-19 12:16:54 +01:00
computeAlignTime ( '24:00' ,
$ shutters - > getTimeUpWeHoliday ) / 86400
)
2018-11-19 09:06:50 +01:00
)
2018-11-17 17:10:45 +01:00
{
$ shuttersSunriseUnixtime =
2018-11-19 09:06:50 +01:00
computeAlignTime ( '24:00' ,
$ shutters - > getTimeUpWeHoliday ) ;
2018-11-17 17:10:45 +01:00
}
elsif (
int ( gettimeofday ( ) / 86400 ) == int (
2018-11-19 12:16:54 +01:00
computeAlignTime ( '24:00' ,
$ shutters - > getTimeUpEarly ) / 86400
)
2019-05-28 08:39:52 +02:00
and $ shutters - > getSunrise
2018-11-19 09:06:50 +01:00
)
2018-11-17 17:10:45 +01:00
{
$ shuttersSunriseUnixtime =
2019-05-28 09:27:13 +02:00
computeAlignTime ( '24:00' , $ shutters - > getTimeUpEarly )
+ 86400 ;
2018-11-17 17:10:45 +01:00
}
else {
$ shuttersSunriseUnixtime =
2018-11-19 09:06:50 +01:00
computeAlignTime ( '24:00' ,
$ shutters - > getTimeUpEarly ) ;
2018-11-17 17:10:45 +01:00
}
}
else {
2019-05-03 11:03:28 +02:00
if (
IsWe ( )
2019-05-03 13:36:39 +02:00
and int ( gettimeofday ( ) / 86400 ) == int (
2019-05-03 11:03:28 +02:00
computeAlignTime ( '24:00' ,
$ shutters - > getTimeUpWeHoliday ) / 86400
)
)
{
$ shuttersSunriseUnixtime =
2019-05-03 13:36:39 +02:00
computeAlignTime ( '24:00' ,
2019-05-03 11:03:28 +02:00
$ shutters - > getTimeUpWeHoliday ) ;
}
elsif (
int ( gettimeofday ( ) / 86400 ) == int (
computeAlignTime ( '24:00' ,
$ shutters - > getTimeUpEarly ) / 86400
)
)
{
$ shuttersSunriseUnixtime =
2019-05-03 13:36:39 +02:00
computeAlignTime ( '24:00' ,
2019-05-03 11:03:28 +02:00
$ shutters - > getTimeUpEarly ) ;
}
2019-05-28 08:39:52 +02:00
elsif (
int ( gettimeofday ( ) / 86400 ) != int (
computeAlignTime ( '24:00' ,
$ shutters - > getTimeUpWeHoliday ) / 86400
)
)
{
$ shuttersSunriseUnixtime =
computeAlignTime ( '24:00' ,
$ shutters - > getTimeUpWeHoliday ) ;
}
2019-05-03 11:03:28 +02:00
else {
$ shuttersSunriseUnixtime =
2019-05-03 13:36:39 +02:00
computeAlignTime ( '24:00' ,
$ shutters - > getTimeUpWeHoliday ) + 86400 ;
2019-05-03 11:03:28 +02:00
}
2018-11-17 17:10:45 +01:00
}
}
else {
$ shuttersSunriseUnixtime =
2018-11-19 09:06:50 +01:00
computeAlignTime ( '24:00' , $ shutters - > getTimeUpEarly ) ;
2018-11-17 17:10:45 +01:00
}
2018-10-14 18:19:23 +02:00
}
2018-11-03 19:01:29 +01:00
elsif ( $ shutters - > getUp eq 'brightness' ) {
2018-10-14 18:19:23 +02:00
$ shuttersSunriseUnixtime =
2018-11-19 09:06:50 +01:00
computeAlignTime ( '24:00' , $ shutters - > getTimeUpLate ) ;
2018-09-07 11:02:46 +02:00
}
return $ shuttersSunriseUnixtime ;
2018-10-14 18:19:23 +02:00
}
elsif ( $ tm eq 'real' ) {
return sunrise_abs ( $ autoAstroMode , 0 , $ shutters - > getTimeUpEarly ,
$ shutters - > getTimeUpLate )
2018-11-03 19:01:29 +01:00
if ( $ shutters - > getUp eq 'astro' ) ;
return $ shutters - > getTimeUpEarly if ( $ shutters - > getUp eq 'time' ) ;
2018-08-31 09:32:16 +02:00
}
2018-08-28 19:49:01 +02:00
}
2019-04-20 21:53:05 +02:00
sub IsAfterShuttersTimeBlocking ($) {
my ( $ shuttersDev ) = @ _ ;
2018-12-07 12:57:45 +01:00
$ shutters - > setShuttersDev ( $ shuttersDev ) ;
if (
2018-12-07 13:04:41 +01:00
( int ( gettimeofday ( ) ) - $ shutters - > getLastManPosTimestamp ) <
$ shutters - > getBlockingTimeAfterManual
2019-04-20 21:53:05 +02:00
or ( not IsDay ( $ shuttersDev )
2018-12-07 13:04:41 +01:00
and $ shutters - > getSunriseUnixTime - ( int ( gettimeofday ( ) ) ) <
$ shutters - > getBlockingTimeBeforDayOpen )
2019-04-20 21:53:05 +02:00
or ( IsDay ( $ shuttersDev )
2018-12-07 13:04:41 +01:00
and $ shutters - > getSunsetUnixTime - ( int ( gettimeofday ( ) ) ) <
$ shutters - > getBlockingTimeBeforNightClose )
2019-01-02 09:38:00 +01:00
)
2019-01-01 18:54:08 +01:00
{
return 0 ;
}
else { return 1 }
}
sub IsAfterShuttersManualBlocking ($) {
my $ shuttersDev = shift ;
$ shutters - > setShuttersDev ( $ shuttersDev ) ;
2019-04-09 12:13:46 +02:00
if ( $ ascDev - > getblockAscDrivesAfterManual
and $ shutters - > getStatus != $ shutters - > getOpenPos
and $ shutters - > getStatus != $ shutters - > getClosedPos
and $ shutters - > getStatus != $ shutters - > getWindPos
and $ shutters - > getStatus != $ shutters - > getShadingPos
and $ shutters - > getStatus != $ shutters - > getComfortOpenPos
and $ shutters - > getStatus != $ shutters - > getVentilatePos
and $ shutters - > getStatus != $ shutters - > getAntiFreezePos
and $ shutters - > getLastDrive eq 'manual' )
2019-03-27 11:22:06 +01:00
{
return 0 ;
}
elsif ( ( int ( gettimeofday ( ) ) - $ shutters - > getLastManPosTimestamp ) <
2019-01-02 09:38:00 +01:00
$ shutters - > getBlockingTimeAfterManual )
2018-12-07 13:04:41 +01:00
{
return 0 ;
}
2018-12-07 12:57:45 +01:00
else { return 1 }
}
2019-04-20 21:53:05 +02:00
sub ShuttersSunset ($$) {
my ( $ shuttersDev , $ tm ) =
2018-10-14 18:19:23 +02:00
@ _ ; # Tm steht für Timemode und bedeutet Realzeit oder Unixzeit
2018-09-13 08:11:10 +02:00
my $ autoAstroMode ;
2018-10-10 10:43:42 +02:00
$ shutters - > setShuttersDev ( $ shuttersDev ) ;
2018-09-18 09:35:45 +02:00
2018-10-14 18:19:23 +02:00
if ( $ shutters - > getAutoAstroModeEvening ne 'none' ) {
$ autoAstroMode = $ shutters - > getAutoAstroModeEvening ;
$ autoAstroMode =
$ autoAstroMode . '=' . $ shutters - > getAutoAstroModeEveningHorizon
if ( $ autoAstroMode eq 'HORIZON' ) ;
2018-09-13 15:21:29 +02:00
}
2018-10-14 18:19:23 +02:00
else {
$ autoAstroMode = $ ascDev - > getAutoAstroModeEvening ;
$ autoAstroMode =
2018-11-03 19:01:29 +01:00
$ autoAstroMode . '=' . $ ascDev - > getAutoAstroModeEveningHorizon
2018-10-14 18:19:23 +02:00
if ( $ autoAstroMode eq 'HORIZON' ) ;
2018-09-13 15:21:29 +02:00
}
2018-10-14 18:19:23 +02:00
my $ oldFuncHash = $ shutters - > getInTimerFuncHash ;
2018-09-07 11:02:46 +02:00
my $ shuttersSunsetUnixtime ;
2018-08-31 09:32:16 +02:00
2018-10-14 18:19:23 +02:00
if ( $ tm eq 'unix' ) {
2018-11-03 19:01:29 +01:00
if ( $ shutters - > getDown eq 'astro' ) {
2018-10-14 18:19:23 +02:00
$ shuttersSunsetUnixtime = (
computeAlignTime (
'24:00' ,
sunset_abs (
$ autoAstroMode ,
0 ,
$ shutters - > getTimeDownEarly ,
$ shutters - > getTimeDownLate
)
) + 1
) ;
if ( defined ( $ oldFuncHash ) and ref ( $ oldFuncHash ) eq 'HASH' ) {
2019-03-31 17:17:56 +02:00
$ shuttersSunsetUnixtime += 86400
2018-10-14 18:19:23 +02:00
if ( $ shuttersSunsetUnixtime <
( $ oldFuncHash - > { sunsettime } + 180 )
and $ oldFuncHash - > { sunsettime } < gettimeofday ( ) ) ;
2018-09-07 11:02:46 +02:00
}
}
2018-11-03 19:01:29 +01:00
elsif ( $ shutters - > getDown eq 'time' ) {
2018-10-14 18:19:23 +02:00
$ shuttersSunsetUnixtime =
computeAlignTime ( '24:00' , $ shutters - > getTimeDownEarly ) ;
}
2018-11-03 19:01:29 +01:00
elsif ( $ shutters - > getDown eq 'brightness' ) {
2018-10-14 18:19:23 +02:00
$ shuttersSunsetUnixtime =
computeAlignTime ( '24:00' , $ shutters - > getTimeDownLate ) ;
}
2018-09-07 11:02:46 +02:00
return $ shuttersSunsetUnixtime ;
2018-10-14 18:19:23 +02:00
}
elsif ( $ tm eq 'real' ) {
return sunset_abs (
$ autoAstroMode , 0 ,
$ shutters - > getTimeDownEarly ,
$ shutters - > getTimeDownLate
2018-11-03 19:01:29 +01:00
) if ( $ shutters - > getDown eq 'astro' ) ;
2018-10-14 18:19:23 +02:00
return $ shutters - > getTimeDownEarly
2018-11-03 19:01:29 +01:00
if ( $ shutters - > getDown eq 'time' ) ;
2018-08-31 09:32:16 +02:00
}
}
2018-08-29 14:58:10 +02:00
## Kontrolliert ob das Fenster von einem bestimmten Rolladen offen ist
2018-08-28 19:49:01 +02:00
sub CheckIfShuttersWindowRecOpen ($) {
my $ shuttersDev = shift ;
2018-10-10 10:43:42 +02:00
$ shutters - > setShuttersDev ( $ shuttersDev ) ;
2018-08-28 19:49:01 +02:00
2019-06-10 16:06:17 +02:00
if ( $ shutters - > getWinStatus =~ /[Oo]pen/ ) # CK: covers: open|opened
2019-04-09 12:13:46 +02:00
{
return 2 ;
}
2019-05-24 11:36:06 +02:00
elsif ( $ shutters - > getWinStatus =~ /tilt/
and $ shutters - > getSubTyp eq 'threestate' ) # CK: covers: tilt|tilted
2018-10-14 18:19:23 +02:00
{
2018-08-28 19:49:01 +02:00
return 1 ;
}
2019-06-10 16:06:17 +02:00
elsif ( $ shutters - > getWinStatus =~ /[Cc]lose/ ) {
2019-05-24 11:36:06 +02:00
return 0 ;
} # CK: covers: close|closed
2018-08-28 19:49:01 +02:00
}
2018-09-07 14:10:46 +02:00
sub makeReadingName ($) {
2019-04-05 08:07:26 +02:00
my ( $ rname ) = @ _ ;
2018-10-14 18:19:23 +02:00
my % charHash = (
"ä" = > "ae" ,
"Ä" = > "Ae" ,
"ü" = > "ue" ,
"Ü" = > "Ue" ,
"ö" = > "oe" ,
"Ö" = > "Oe" ,
"ß" = > "ss"
) ;
my $ charHashkeys = join ( "|" , keys ( % charHash ) ) ;
2019-04-05 08:07:26 +02:00
return $ rname if ( $ rname =~ m/^\./ ) ;
$ rname =~ s/($charHashkeys)/$charHash{$1}/gi ;
$ rname =~ s/[^a-z0-9._\-\/]/_/gi ;
return $ rname ;
2018-09-07 14:10:46 +02:00
}
2018-09-14 20:46:55 +02:00
sub TimeMin2Sec ($) {
my $ min = shift ;
my $ sec ;
2018-10-14 18:19:23 +02:00
$ sec = $ min * 60 ;
2018-09-14 20:46:55 +02:00
return $ sec ;
}
2018-09-18 09:35:45 +02:00
sub IsWe () {
2019-03-25 11:23:49 +01:00
my $ we = main:: IsWe ( ) ;
2018-10-14 18:19:23 +02:00
return $ we ;
2018-09-18 09:35:45 +02:00
}
sub IsWeTomorrow () {
2019-03-25 11:23:49 +01:00
my $ we = main:: IsWe ( 'tomorrow' ) ;
2018-10-14 18:19:23 +02:00
return $ we ;
2018-09-18 09:35:45 +02:00
}
2018-10-30 08:18:09 +01:00
sub SetCmdFn ($) {
2018-10-30 19:10:50 +01:00
my $ h = shift ;
2018-10-30 08:18:09 +01:00
my $ shuttersDev = $ h - > { shuttersDev } ;
my $ posValue = $ h - > { posValue } ;
2018-10-30 19:10:50 +01:00
2018-10-30 08:18:09 +01:00
$ shutters - > setShuttersDev ( $ shuttersDev ) ;
2018-12-05 09:11:45 +01:00
$ shutters - > setLastDrive ( $ h - > { lastDrive } )
if ( defined ( $ h - > { lastDrive } ) ) ;
2018-11-28 13:11:32 +01:00
2018-11-20 10:35:10 +01:00
return
2019-05-17 14:20:57 +02:00
unless ( $ shutters - > getASCenable eq 'on'
and $ ascDev - > getASCenable eq 'on' ) ;
2018-11-20 10:35:10 +01:00
2018-11-04 12:27:46 +01:00
if ( $ shutters - > getStatus != $ posValue ) {
$ shutters - > setLastPos ( $ shutters - > getStatus ) ;
2018-11-04 21:31:05 +01:00
}
else {
2018-11-04 12:27:46 +01:00
$ shutters - > setLastDrive (
ReadingsVal ( $ shuttersDev , 'ASC_ShuttersLastDrive' , 'none' ) ) ;
2019-04-09 12:13:46 +02:00
ASC_Debug ( 'FnSetCmdFn: '
. $ shuttersDev
. ' - Abbruch aktuelle Position ist gleich der Zielposition '
. $ shutters - > getStatus . '='
. $ posValue ) ;
2019-04-02 19:28:54 +02:00
return ;
2018-11-04 12:27:46 +01:00
}
2019-04-09 12:13:46 +02:00
ASC_Debug ( 'FnSetCmdFn: '
. $ shuttersDev
. ' - Rolllo wird gefahren, aktuelle Position: '
. $ shutters - > getStatus
. ', Zielposition: '
. $ posValue
. '. Grund der Fahrt: '
. $ shutters - > getLastDrive ) ;
2018-10-30 08:18:09 +01:00
CommandSet ( undef ,
$ shuttersDev
. ':FILTER='
. $ shutters - > getPosCmd . '!='
. $ posValue . ' '
2018-11-07 08:22:11 +01:00
. $ shutters - > getPosSetCmd . ' '
2018-10-30 08:18:09 +01:00
. $ posValue ) ;
}
2019-04-02 19:28:54 +02:00
sub ASC_Debug ($) {
return
2019-04-09 12:13:46 +02:00
unless ( AttrVal ( $ ascDev - > getName , 'ASC_debug' , 0 ) ) ;
2019-04-02 19:28:54 +02:00
my $ debugMsg = shift ;
2019-04-09 12:13:46 +02:00
my $ debugTimestamp = strftime ( "%Y.%m.%e %T" , localtime ( time ) ) ;
print (
"\n" . 'ASC_DEBUG!!! ' . $ debugTimestamp . ' - ' . $ debugMsg . "\n" ) ;
2019-04-02 19:28:54 +02:00
}
######################################
######################################
2018-10-28 18:12:40 +01:00
########## Begin der Klassendeklarierungen für OOP (Objektorientierte Programmierung) #########################
2018-10-10 10:43:42 +02:00
## Klasse Rolläden (Shutters) und die Subklassen Attr und Readings ##
## desweiteren wird noch die Klasse ASC_Roommate mit eingebunden
2019-04-02 19:28:54 +02:00
2018-10-10 10:43:42 +02:00
package ASC_Shutters ;
2018-10-14 18:19:23 +02:00
our @ ISA =
qw( ASC_Shutters::Readings ASC_Shutters::Attr ASC_Roommate ASC_Window ) ;
2018-10-08 21:05:47 +02:00
use strict ;
use warnings ;
2018-11-07 08:22:11 +01:00
use GPUtils qw( GP_Import ) ;
2018-10-14 18:19:23 +02:00
## Import der FHEM Funktionen
BEGIN {
GP_Import (
qw(
defs
ReadingsVal
readingsSingleUpdate
2018-10-30 08:18:09 +01:00
gettimeofday
2018-11-21 08:38:32 +01:00
InternalTimer
2019-03-31 17:17:56 +02:00
CommandSet
Log3 )
2018-10-14 18:19:23 +02:00
) ;
}
2018-10-08 21:05:47 +02:00
sub new {
2018-10-14 18:19:23 +02:00
my $ class = shift ;
my $ self = {
shuttersDev = > undef ,
defaultarg = > undef ,
roommate = > undef ,
} ;
2018-10-08 21:05:47 +02:00
bless $ self , $ class ;
return $ self ;
}
2018-10-10 10:43:42 +02:00
sub setShuttersDev {
2018-10-14 18:19:23 +02:00
my ( $ self , $ shuttersDev ) = @ _ ;
2018-10-17 09:50:11 +02:00
2018-10-14 18:19:23 +02:00
$ self - > { shuttersDev } = $ shuttersDev if ( defined ( $ shuttersDev ) ) ;
2018-10-10 10:43:42 +02:00
return $ self - > { shuttersDev } ;
2018-10-08 21:05:47 +02:00
}
2018-10-27 13:36:11 +02:00
sub getShuttersDev {
my $ self = shift ;
return $ self - > { shuttersDev } ;
}
2018-11-21 08:38:32 +01:00
sub setHardLockOut {
my ( $ self , $ cmd ) = @ _ ;
2018-11-28 13:11:32 +01:00
if ( $ shutters - > getLockOut eq 'hard'
and $ shutters - > getLockOutCmd ne 'none' )
2018-11-21 08:38:32 +01:00
{
2018-11-21 09:52:02 +01:00
CommandSet ( undef , $ self - > { shuttersDev } . ' inhibit ' . $ cmd )
2018-11-28 13:11:32 +01:00
if ( $ shutters - > getLockOutCmd eq 'inhibit' ) ;
2018-11-21 08:38:32 +01:00
CommandSet ( undef ,
2018-11-28 13:11:32 +01:00
$ self - > { shuttersDev } . ' '
. ( $ cmd eq 'on' ? 'blocked' : 'unblocked' ) )
if ( $ shutters - > getLockOutCmd eq 'blocked' ) ;
2018-11-21 08:38:32 +01:00
CommandSet ( undef ,
2018-11-28 13:11:32 +01:00
$ self - > { shuttersDev } . ' '
. ( $ cmd eq 'on' ? 'protectionOn' : 'protectionOff' ) )
2019-06-03 07:44:35 +02:00
if ( $ shutters - > getLockOutCmd eq 'protected' ) ;
2018-11-21 08:38:32 +01:00
}
return 0 ;
}
2018-11-07 08:22:11 +01:00
sub setNoOffset {
my ( $ self , $ noOffset ) = @ _ ;
$ self - > { $ self - > { shuttersDev } } { noOffset } = $ noOffset ;
return 0 ;
}
2018-10-14 18:19:23 +02:00
sub setDriveCmd {
my ( $ self , $ posValue ) = @ _ ;
2019-03-31 17:17:56 +02:00
my $ offSet ;
my $ offSetStart ;
2018-11-19 09:06:50 +01:00
2018-11-15 15:01:34 +01:00
### antifreeze Routine
2018-11-16 10:44:54 +01:00
if ( $ shutters - > getFreezeStatus > 0 ) {
if ( $ shutters - > getFreezeStatus != 1 ) {
2019-03-31 17:17:56 +02:00
2018-11-15 21:51:02 +01:00
$ posValue = $ shutters - > getStatus ;
$ shutters - > setLastDrive ( 'no drive - antifreeze defense' ) ;
$ shutters - > setLastDriveReading ;
$ ascDev - > setStateReading ;
}
2018-11-16 10:44:54 +01:00
elsif ( $ posValue == $ shutters - > getClosedPos ) {
2018-11-15 21:51:02 +01:00
$ posValue = $ shutters - > getAntiFreezePos ;
2018-11-19 09:06:50 +01:00
$ shutters - > setLastDrive (
$ shutters - > getLastDrive . ' - antifreeze mode' ) ;
2018-11-15 21:51:02 +01:00
}
2018-11-15 15:01:34 +01:00
}
2018-11-19 09:06:50 +01:00
my % h = (
2018-10-30 19:10:50 +01:00
shuttersDev = > $ self - > { shuttersDev } ,
posValue = > $ posValue ,
) ;
2018-11-04 12:27:46 +01:00
2019-04-09 12:13:46 +02:00
$ offSet = $ shutters - > getOffset if ( $ shutters - > getOffset > - 1 ) ;
$ offSet = $ ascDev - > getShuttersOffset if ( $ shutters - > getOffset < 0 ) ;
2019-04-25 17:15:56 +02:00
$ offSetStart = $ shutters - > getOffsetStart ;
2018-10-27 13:36:11 +02:00
2019-03-31 17:17:56 +02:00
if ( $ offSetStart > 0 and not $ shutters - > getNoOffset ) {
InternalTimer (
gettimeofday ( ) + int ( rand ( $ offSet ) + $ shutters - > getOffsetStart ) ,
'FHEM::AutoShuttersControl::SetCmdFn' , \ % h ) ;
2019-04-09 12:13:46 +02:00
FHEM::AutoShuttersControl:: ASC_Debug ( 'FnSetDriveCmd: '
. $ shutters - > getShuttersDev
. ' - versetztes fahren' ) ;
2019-03-31 17:17:56 +02:00
}
elsif ( $ offSetStart < 1 or $ shutters - > getNoOffset ) {
FHEM::AutoShuttersControl:: SetCmdFn ( \ % h ) ;
2019-04-09 12:13:46 +02:00
FHEM::AutoShuttersControl:: ASC_Debug ( 'FnSetDriveCmd: '
. $ shutters - > getShuttersDev
. ' - NICHT versetztes fahren' ) ;
2019-03-31 17:17:56 +02:00
}
2018-10-30 19:10:50 +01:00
2019-04-09 12:13:46 +02:00
FHEM::AutoShuttersControl:: ASC_Debug ( 'FnSetDriveCmd: '
. $ shutters - > getShuttersDev
. ' - NoOffset: '
. ( $ shutters - > getNoOffset ? 'JA' : 'NEIN' ) ) ;
2019-03-31 17:17:56 +02:00
$ shutters - > setNoOffset ( 0 ) ;
2018-10-30 19:10:50 +01:00
return 0 ;
2018-10-14 18:19:23 +02:00
}
2018-10-08 21:05:47 +02:00
2018-10-28 18:12:40 +01:00
sub setSunsetUnixTime {
my ( $ self , $ unixtime ) = @ _ ;
$ self - > { $ self - > { shuttersDev } } { sunsettime } = $ unixtime ;
return 0 ;
}
2019-03-27 11:22:06 +01:00
sub setSunset {
my ( $ self , $ value ) = @ _ ;
$ self - > { $ self - > { shuttersDev } } { sunset } = $ value ;
return 0 ;
}
2018-10-28 18:12:40 +01:00
sub setSunriseUnixTime {
my ( $ self , $ unixtime ) = @ _ ;
$ self - > { $ self - > { shuttersDev } } { sunrisetime } = $ unixtime ;
return 0 ;
}
2019-03-27 11:22:06 +01:00
sub setSunrise {
my ( $ self , $ value ) = @ _ ;
$ self - > { $ self - > { shuttersDev } } { sunrise } = $ value ;
return 0 ;
}
2018-10-27 13:36:11 +02:00
sub setDelayCmd {
2018-10-14 18:19:23 +02:00
my ( $ self , $ posValue ) = @ _ ;
2018-10-27 13:36:11 +02:00
$ self - > { $ self - > { shuttersDev } } { delayCmd } = $ posValue ;
return 0 ;
}
sub setLastDrive {
my ( $ self , $ lastDrive ) = @ _ ;
$ self - > { $ self - > { shuttersDev } } { lastDrive } = $ lastDrive ;
return 0 ;
}
2018-11-07 08:22:11 +01:00
sub setPosSetCmd {
my ( $ self , $ posSetCmd ) = @ _ ;
2018-11-08 08:32:47 +01:00
2018-11-07 08:22:11 +01:00
$ self - > { $ self - > { shuttersDev } } { posSetCmd } = $ posSetCmd ;
return 0 ;
}
2018-10-27 13:36:11 +02:00
sub setLastDriveReading {
my $ self = shift ;
2018-10-14 18:19:23 +02:00
my $ shuttersDevHash = $ defs { $ self - > { shuttersDev } } ;
2018-10-27 13:36:11 +02:00
readingsSingleUpdate ( $ shuttersDevHash , 'ASC_ShuttersLastDrive' ,
2018-11-07 08:22:11 +01:00
$ shutters - > getLastDrive , 1 ) ;
2018-10-14 18:19:23 +02:00
return 0 ;
}
2018-10-19 20:13:01 +02:00
sub setLastPos
{ # letzte ermittelte Position bevor die Position des Rolladen über ASC geändert wurde
2018-10-14 18:19:23 +02:00
my ( $ self , $ position ) = @ _ ;
2018-10-17 09:50:11 +02:00
2018-10-17 15:58:05 +02:00
$ self - > { $ self - > { shuttersDev } } { lastPos } { VAL } = $ position
2018-10-17 09:50:11 +02:00
if ( defined ( $ position ) ) ;
2018-10-17 15:58:05 +02:00
$ self - > { $ self - > { shuttersDev } } { lastPos } { TIME } = int ( gettimeofday ( ) )
if ( defined ( $ self - > { $ self - > { shuttersDev } } { lastPos } ) ) ;
2018-10-14 18:19:23 +02:00
return 0 ;
}
2018-10-08 21:05:47 +02:00
2018-11-19 09:06:50 +01:00
sub setLastManPos {
2018-10-19 20:13:01 +02:00
my ( $ self , $ position ) = @ _ ;
$ self - > { $ self - > { shuttersDev } } { lastManPos } { VAL } = $ position
if ( defined ( $ position ) ) ;
$ self - > { $ self - > { shuttersDev } } { lastManPos } { TIME } = int ( gettimeofday ( ) )
2018-12-07 12:57:45 +01:00
if ( defined ( $ self - > { $ self - > { shuttersDev } } { lastManPos } )
2018-12-07 13:04:41 +01:00
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 } ) ) ;
2018-10-19 20:13:01 +02:00
return 0 ;
}
2018-10-14 18:19:23 +02:00
sub setDefault {
my ( $ self , $ defaultarg ) = @ _ ;
2018-10-17 09:50:11 +02:00
2018-10-14 18:19:23 +02:00
$ self - > { defaultarg } = $ defaultarg if ( defined ( $ defaultarg ) ) ;
2018-10-10 10:43:42 +02:00
return $ self - > { defaultarg } ;
2018-10-08 21:05:47 +02:00
}
2018-10-10 10:43:42 +02:00
sub setRoommate {
2018-10-14 18:19:23 +02:00
my ( $ self , $ roommate ) = @ _ ;
2018-10-17 09:50:11 +02:00
2018-10-14 18:19:23 +02:00
$ self - > { roommate } = $ roommate if ( defined ( $ roommate ) ) ;
2018-10-10 10:43:42 +02:00
return $ self - > { roommate } ;
2018-10-08 21:05:47 +02:00
}
2018-10-17 09:50:11 +02:00
sub setInTimerFuncHash {
my ( $ self , $ inTimerFuncHash ) = @ _ ;
$ self - > { $ self - > { shuttersDev } } { inTimerFuncHash } = $ inTimerFuncHash
if ( defined ( $ inTimerFuncHash ) ) ;
return 0 ;
}
2019-06-04 10:53:28 +02:00
sub getIsDay {
my $ self = shift ;
return FHEM::AutoShuttersControl:: IsDay ( $ self - > { shuttersDev } ) ;
}
2018-11-15 21:51:02 +01:00
sub getFreezeStatus {
2018-11-16 09:28:18 +01:00
use POSIX qw( strftime ) ;
2018-11-15 21:51:02 +01:00
my $ self = shift ;
2018-11-19 09:06:50 +01:00
my $ daytime = strftime ( "%P" , localtime ( ) ) ;
if ( $ shutters - > getAntiFreeze ne 'off'
and $ ascDev - > getOutTemp <= $ ascDev - > getFreezeTemp )
{
2018-11-15 21:51:02 +01:00
2018-11-19 09:06:50 +01:00
if ( $ shutters - > getAntiFreeze eq 'soft' ) {
2018-11-16 10:44:54 +01:00
return 1 ;
}
2019-04-09 12:13:46 +02:00
elsif ( $ shutters - > getAntiFreeze eq $ daytime ) {
2018-11-16 10:44:54 +01:00
return 2 ;
}
elsif ( $ shutters - > getAntiFreeze eq 'hard' ) {
return 3 ;
}
2018-11-15 21:51:02 +01:00
}
else { return 0 ; }
}
2018-11-07 08:22:11 +01:00
sub getShuttersPosCmdValueNegate {
my $ self = shift ;
2018-11-08 08:32:47 +01:00
2018-11-07 08:22:11 +01:00
return ( $ shutters - > getOpenPos < $ shutters - > getClosedPos ? 1 : 0 ) ;
}
2019-06-04 06:37:38 +02:00
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
) ;
}
2018-11-07 08:22:11 +01:00
sub getPosSetCmd {
my $ self = shift ;
2018-11-08 08:32:47 +01:00
return (
defined ( $ self - > { $ self - > { shuttersDev } } { posSetCmd } )
? $ self - > { $ self - > { shuttersDev } } { posSetCmd }
2018-11-12 09:09:30 +01:00
: $ shutters - > getPosCmd
) ;
2018-11-07 08:22:11 +01:00
}
sub getNoOffset {
my $ self = shift ;
return $ self - > { $ self - > { shuttersDev } } { noOffset } ;
}
2018-10-27 13:36:11 +02:00
sub getLastDrive {
my $ self = shift ;
2018-10-28 18:12:40 +01:00
$ self - > { $ self - > { shuttersDev } } { lastDrive } =
ReadingsVal ( $ self - > { shuttersDev } , 'ASC_ShuttersLastDrive' , 'none' )
if ( not defined ( $ self - > { $ self - > { shuttersDev } } { lastDrive } ) ) ;
2018-10-27 13:36:11 +02:00
return $ self - > { $ self - > { shuttersDev } } { lastDrive } ;
}
2018-10-19 20:13:01 +02:00
sub getLastPos
{ # letzte ermittelte Position bevor die Position des Rolladen über ASC geändert wurde
2018-10-27 13:36:11 +02:00
my $ self = shift ;
2018-10-17 09:50:11 +02:00
return $ self - > { $ self - > { shuttersDev } } { lastPos } { VAL }
if ( defined ( $ self - > { $ self - > { shuttersDev } } { lastPos } )
and defined ( $ self - > { $ self - > { shuttersDev } } { lastPos } { VAL } ) ) ;
}
sub getLastPosTimestamp {
2018-10-27 13:36:11 +02:00
my $ self = shift ;
2018-10-17 09:50:11 +02:00
return $ self - > { $ self - > { shuttersDev } } { lastPos } { TIME }
if ( defined ( $ self - > { $ self - > { shuttersDev } } )
and defined ( $ self - > { $ self - > { shuttersDev } } { lastPos } )
and defined ( $ self - > { $ self - > { shuttersDev } } { lastPos } { TIME } ) ) ;
}
2018-10-19 20:13:01 +02:00
sub getLastManPos
{ # letzte ermittelte Position bevor die Position des Rolladen manuell (nicht über ASC) geändert wurde
2018-10-27 13:36:11 +02:00
my $ self = shift ;
2018-10-19 20:13:01 +02:00
return $ self - > { $ self - > { shuttersDev } } { lastManPos } { VAL }
if ( defined ( $ self - > { $ self - > { shuttersDev } } { lastManPos } )
and defined ( $ self - > { $ self - > { shuttersDev } } { lastManPos } { VAL } ) ) ;
}
sub getLastManPosTimestamp {
2018-10-27 13:36:11 +02:00
my $ self = shift ;
2018-10-19 20:13:01 +02:00
return $ self - > { $ self - > { shuttersDev } } { lastManPos } { TIME }
if ( defined ( $ self - > { $ self - > { shuttersDev } } )
and defined ( $ self - > { $ self - > { shuttersDev } } { lastManPos } )
and defined ( $ self - > { $ self - > { shuttersDev } } { lastManPos } { TIME } ) ) ;
}
2018-10-17 09:50:11 +02:00
sub getInTimerFuncHash {
2018-10-27 13:36:11 +02:00
my $ self = shift ;
2018-10-17 09:50:11 +02:00
return $ self - > { $ self - > { shuttersDev } } { inTimerFuncHash } ;
2018-10-14 18:19:23 +02:00
}
2018-10-08 21:05:47 +02:00
2018-10-28 18:12:40 +01:00
sub getSunsetUnixTime {
my $ self = shift ;
return $ self - > { $ self - > { shuttersDev } } { sunsettime } ;
}
2019-03-27 11:22:06 +01:00
sub getSunset {
my $ self = shift ;
2019-04-09 12:13:46 +02:00
return (
defined ( $ self - > { $ self - > { shuttersDev } } { sunset } )
? $ self - > { $ self - > { shuttersDev } } { sunset }
2019-04-20 18:18:50 +02:00
: 0
) ;
2019-03-27 11:22:06 +01:00
}
2018-10-28 18:12:40 +01:00
sub getSunriseUnixTime {
my $ self = shift ;
return $ self - > { $ self - > { shuttersDev } } { sunrisetime } ;
}
2019-03-27 11:22:06 +01:00
sub getSunrise {
my $ self = shift ;
2019-04-09 12:13:46 +02:00
return (
defined ( $ self - > { $ self - > { shuttersDev } } { sunrise } )
? $ self - > { $ self - > { shuttersDev } } { sunrise }
2019-04-20 18:18:50 +02:00
: 0
) ;
2019-03-27 11:22:06 +01:00
}
2018-10-14 18:19:23 +02:00
sub getRoommatesStatus {
2018-10-27 13:36:11 +02:00
my $ self = shift ;
my $ loop = 0 ;
2018-10-01 08:43:59 +02:00
my @ roState ;
2018-10-14 18:19:23 +02:00
my % statePrio = (
'asleep' = > 1 ,
'gotosleep' = > 2 ,
'awoken' = > 3 ,
'home' = > 4 ,
'absent' = > 5 ,
'gone' = > 6 ,
'none' = > 7
) ;
my $ minPrio = 10 ;
foreach my $ ro ( split ( "," , $ shutters - > getRoommates ) ) {
2018-10-10 10:43:42 +02:00
$ shutters - > setRoommate ( $ ro ) ;
2018-11-03 19:01:29 +01:00
my $ currentPrio = $ statePrio { $ shutters - > _getRoommateStatus } ;
2018-10-14 18:19:23 +02:00
$ minPrio = $ currentPrio if ( $ minPrio > $ currentPrio ) ;
2018-10-01 08:43:59 +02:00
}
2018-10-17 09:50:11 +02:00
2018-10-14 18:19:23 +02:00
my % revStatePrio = reverse % statePrio ;
2018-10-10 10:43:42 +02:00
return $ revStatePrio { $ minPrio } ;
2018-10-01 08:43:59 +02:00
}
2018-10-10 10:43:42 +02:00
sub getRoommatesLastStatus {
2018-10-27 13:36:11 +02:00
my $ self = shift ;
my $ loop = 0 ;
2018-10-01 08:43:59 +02:00
my @ roState ;
2018-10-14 18:19:23 +02:00
my % statePrio = (
'asleep' = > 1 ,
'gotosleep' = > 2 ,
'awoken' = > 3 ,
'home' = > 4 ,
'absent' = > 5 ,
'gone' = > 6 ,
'none' = > 7
) ;
my $ minPrio = 10 ;
foreach my $ ro ( split ( "," , $ shutters - > getRoommates ) ) {
2018-10-10 10:43:42 +02:00
$ shutters - > setRoommate ( $ ro ) ;
2018-11-03 19:01:29 +01:00
my $ currentPrio = $ statePrio { $ shutters - > _getRoommateLastStatus } ;
2018-10-14 18:19:23 +02:00
$ minPrio = $ currentPrio if ( $ minPrio > $ currentPrio ) ;
2018-10-01 08:43:59 +02:00
}
2018-10-14 18:19:23 +02:00
my % revStatePrio = reverse % statePrio ;
2018-10-10 10:43:42 +02:00
return $ revStatePrio { $ minPrio } ;
2018-10-08 21:05:47 +02:00
}
2018-12-05 15:39:11 +01:00
### Begin Beschattung Objekt mit Daten befüllen
2019-03-31 17:17:56 +02:00
sub setShadingStatus {
2018-12-05 15:39:11 +01:00
my ( $ self , $ value ) = @ _ ;
### Werte für value = in, out, in reserved, out reserved
2019-03-31 17:17:56 +02:00
$ self - > { $ self - > { shuttersDev } } { ShadingStatus } { VAL } = $ value
2018-12-05 15:39:11 +01:00
if ( defined ( $ value ) ) ;
2019-03-31 17:17:56 +02:00
$ self - > { $ self - > { shuttersDev } } { ShadingStatus } { TIME } = int ( gettimeofday ( ) )
if ( defined ( $ self - > { $ self - > { shuttersDev } } { ShadingStatus } ) ) ;
2018-12-05 15:39:11 +01:00
return 0 ;
}
2019-06-03 07:44:35 +02:00
sub setWindProtectionStatus { # Werte protected, unprotected
2019-03-23 12:06:21 +01:00
my ( $ self , $ value ) = @ _ ;
$ self - > { $ self - > { shuttersDev } } - > { ASC_WindParameters } - > { VAL } = $ value
if ( defined ( $ value ) ) ;
return 0 ;
}
2019-06-03 07:44:35 +02:00
sub setRainProtectionStatus { # Werte protected, unprotected
2019-05-02 11:49:22 +02:00
my ( $ self , $ value ) = @ _ ;
$ self - > { $ self - > { shuttersDev } } - > { RainProtection } - > { VAL } = $ value
if ( defined ( $ value ) ) ;
return 0 ;
}
2019-04-09 12:13:46 +02:00
sub getShadingStatus { # Werte für value = in, out, in reserved, out reserved
2019-03-31 17:17:56 +02:00
my $ self = shift ;
return $ self - > { $ self - > { shuttersDev } } { ShadingStatus } { VAL }
if ( defined ( $ self - > { $ self - > { shuttersDev } } { ShadingStatus } )
and defined ( $ self - > { $ self - > { shuttersDev } } { ShadingStatus } { VAL } ) ) ;
}
sub getIfInShading {
2018-12-05 15:39:11 +01:00
my $ self = shift ;
2019-04-09 12:13:46 +02:00
return (
(
$ shutters - > getShadingMode eq 'always'
or $ shutters - > getShadingMode eq 'home'
)
and $ shutters - > getShadingStatus eq 'in' ? 1 : 0
) ;
2018-12-05 15:39:11 +01:00
}
2019-06-03 07:44:35 +02:00
sub getWindProtectionStatus { # Werte protected, unprotected
2019-03-23 12:06:21 +01:00
my $ self = shift ;
2019-04-09 12:13:46 +02:00
2019-05-03 08:57:35 +02:00
return (
2019-05-04 18:46:09 +02:00
(
defined ( $ self - > { $ self - > { shuttersDev } } - > { ASC_WindParameters } )
and defined (
$ self - > { $ self - > { shuttersDev } } - > { ASC_WindParameters } - > { VAL }
)
)
2019-05-03 08:57:35 +02:00
? $ self - > { $ self - > { shuttersDev } } - > { ASC_WindParameters } - > { VAL }
2019-06-03 07:44:35 +02:00
: 'unprotected'
2019-05-03 08:57:35 +02:00
) ;
2019-05-02 11:49:22 +02:00
}
2019-06-03 07:44:35 +02:00
sub getRainProtectionStatus { # Werte protected, unprotected
2019-05-02 11:49:22 +02:00
my $ self = shift ;
2019-05-03 13:36:39 +02:00
return (
2019-05-04 18:46:09 +02:00
(
defined ( $ self - > { $ self - > { shuttersDev } } - > { RainProtection } )
and defined (
$ self - > { $ self - > { shuttersDev } } - > { RainProtection } - > { VAL }
)
)
2019-05-03 08:57:35 +02:00
? $ self - > { $ self - > { shuttersDev } } - > { RainProtection } - > { VAL }
2019-06-03 07:44:35 +02:00
: 'unprotected'
2019-05-03 13:36:39 +02:00
) ;
2019-03-23 12:06:21 +01:00
}
2019-03-31 17:17:56 +02:00
sub getShadingStatusTimestamp {
2018-12-05 15:39:11 +01:00
my $ self = shift ;
2019-03-31 17:17:56 +02:00
return $ self - > { $ self - > { shuttersDev } } { ShadingStatus } { TIME }
2018-12-05 15:39:11 +01:00
if ( defined ( $ self - > { $ self - > { shuttersDev } } )
2019-03-31 17:17:56 +02:00
and defined ( $ self - > { $ self - > { shuttersDev } } { ShadingStatus } )
and defined ( $ self - > { $ self - > { shuttersDev } } { ShadingStatus } { TIME } ) ) ;
2018-12-05 15:39:11 +01:00
}
### Ende Beschattung
2018-10-09 18:05:55 +02:00
## Subklasse Attr von ASC_Shutters##
package ASC_Shutters::Attr ;
2018-10-08 21:05:47 +02:00
use strict ;
use warnings ;
2018-11-07 08:22:11 +01:00
use GPUtils qw( GP_Import ) ;
2018-10-08 21:05:47 +02:00
## Import der FHEM Funktionen
BEGIN {
2018-10-14 18:19:23 +02:00
GP_Import (
qw(
2019-03-07 10:52:23 +01:00
AttrVal
gettimeofday )
2018-10-14 18:19:23 +02:00
) ;
}
2018-10-08 21:05:47 +02:00
2018-11-15 15:01:34 +01:00
sub getAntiFreezePos {
my $ self = shift ;
2019-04-25 21:34:46 +02:00
return AttrVal ( $ self - > { shuttersDev } , 'ASC_Antifreeze_Pos' ,
$ userAttrList { ASC_Antifreeze_Pos }
[ AttrVal ( $ self - > { shuttersDev } , 'ASC' , 2 ) ] ) ;
2018-11-15 15:01:34 +01:00
}
2018-10-22 08:05:19 +02:00
sub getShuttersPlace {
2018-10-27 13:36:11 +02:00
my $ self = shift ;
2018-10-22 08:05:19 +02:00
2018-10-27 13:36:11 +02:00
return AttrVal ( $ self - > { shuttersDev } , 'ASC_ShuttersPlace' , 'window' ) ;
2018-10-22 08:05:19 +02:00
}
2019-01-23 19:01:54 +01:00
sub getPrivacyDownTime {
my $ self = shift ;
2019-01-23 19:04:28 +01:00
return AttrVal ( $ self - > { shuttersDev } ,
'ASC_PrivacyDownTime_beforNightClose' , - 1 ) ;
2019-01-23 19:01:54 +01:00
}
sub getPrivacyDownPos {
my $ self = shift ;
2019-01-23 19:04:28 +01:00
return AttrVal ( $ self - > { shuttersDev } , 'ASC_PrivacyDown_Pos' , 50 ) ;
2019-01-23 19:01:54 +01:00
}
2018-10-14 18:19:23 +02:00
sub getSelfDefenseExclude {
2018-10-27 13:36:11 +02:00
my $ self = shift ;
2018-10-08 21:05:47 +02:00
2018-10-27 13:36:11 +02:00
return AttrVal ( $ self - > { shuttersDev } , 'ASC_Self_Defense_Exclude' , 'off' ) ;
2018-10-14 18:19:23 +02:00
}
2018-10-08 21:05:47 +02:00
2018-11-12 12:56:18 +01:00
sub getWiggleValue {
my $ self = shift ;
return AttrVal ( $ self - > { shuttersDev } , 'ASC_WiggleValue' , 5 ) ;
}
2018-12-05 15:39:11 +01:00
### Begin Beschattung
2018-11-14 03:41:38 +01:00
sub getShadingPos {
2019-04-25 21:34:46 +02:00
my $ self = shift ;
2018-11-14 03:41:38 +01:00
2019-04-25 21:34:46 +02:00
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 ) ] ) ;
2018-11-14 03:41:38 +01:00
}
sub getShadingMode {
2019-04-25 21:34:46 +02:00
my $ self = shift ;
2018-11-14 03:41:38 +01:00
2019-04-25 17:15:56 +02:00
return AttrVal ( $ self - > { shuttersDev } , 'ASC_Shading_Mode' , 'off' ) ;
2018-11-14 03:41:38 +01:00
}
2018-12-07 12:57:45 +01:00
sub _getBrightnessSensor {
2019-04-09 12:13:46 +02:00
my $ self = shift ;
return $ self - > { $ self - > { shuttersDev } } - > { ASC_BrightnessSensor } - > { device }
if (
exists (
$ self - > { $ self - > { shuttersDev } } - > { ASC_BrightnessSensor }
- > { LASTGETTIME }
)
and ( gettimeofday ( ) -
$ self - > { $ self - > { shuttersDev } } - > { ASC_BrightnessSensor }
- > { LASTGETTIME } ) < 2
) ;
$ self - > { $ self - > { shuttersDev } } - > { ASC_BrightnessSensor } - > { LASTGETTIME } =
int ( gettimeofday ( ) ) ;
2019-04-17 16:25:05 +02:00
my ( $ device , $ reading , $ max , $ min ) =
2019-04-09 12:13:46 +02:00
FHEM::AutoShuttersControl:: GetAttrValues ( $ self - > { shuttersDev } ,
'ASC_BrightnessSensor' , 'none' ) ;
2018-10-08 21:05:47 +02:00
2019-03-12 23:02:02 +01:00
### erwartetes Ergebnis
2019-04-17 16:25:05 +02:00
# DEVICE:READING MAX:MIN
2019-03-12 23:02:02 +01:00
$ self - > { $ self - > { shuttersDev } } - > { ASC_BrightnessSensor } - > { device } = $ device ;
2019-04-09 12:13:46 +02:00
$ self - > { $ self - > { shuttersDev } } - > { ASC_BrightnessSensor } - > { reading } =
( $ reading ne 'none' ? $ reading : 'brightness' ) ;
$ self - > { $ self - > { shuttersDev } } - > { ASC_BrightnessSensor } - > { triggermin } =
2019-06-10 18:42:31 +02:00
( $ min ne 'none' ? $ min : - 1 ) ;
2019-04-09 12:13:46 +02:00
$ self - > { $ self - > { shuttersDev } } - > { ASC_BrightnessSensor } - > { triggermax } =
2019-06-10 18:42:31 +02:00
( $ max ne 'none' ? $ max : - 1 ) ;
2019-03-07 17:58:30 +01:00
return $ self - > { $ self - > { shuttersDev } } - > { ASC_BrightnessSensor } - > { device } ;
2018-10-08 21:05:47 +02:00
}
2018-12-07 12:57:45 +01:00
sub getBrightnessReading {
2019-04-09 12:13:46 +02:00
my $ self = shift ;
2018-10-12 06:32:01 +02:00
2019-04-09 12:13:46 +02:00
return $ self - > { $ self - > { shuttersDev } } - > { ASC_BrightnessSensor } - > { reading }
if (
exists (
$ self - > { $ self - > { shuttersDev } } - > { ASC_BrightnessSensor }
- > { LASTGETTIME }
)
and ( gettimeofday ( ) -
$ self - > { $ self - > { shuttersDev } } - > { ASC_BrightnessSensor }
- > { LASTGETTIME } ) < 2
) ;
2019-03-07 17:58:30 +01:00
$ shutters - > _getBrightnessSensor ;
2019-04-09 12:13:46 +02:00
return (
defined (
$ self - > { $ self - > { shuttersDev } } - > { ASC_BrightnessSensor } - > { reading }
)
? $ self - > { $ self - > { shuttersDev } } - > { ASC_BrightnessSensor } - > { reading }
: 'brightness'
) ;
2018-10-12 06:32:01 +02:00
}
2018-10-08 21:05:47 +02:00
2018-11-12 12:56:18 +01:00
sub getDirection {
2018-11-19 09:06:50 +01:00
my $ self = shift ;
2018-11-12 12:56:18 +01:00
2019-04-25 17:15:56 +02:00
return AttrVal ( $ self - > { shuttersDev } , 'ASC_Shading_Direction' , 180 ) ;
2018-11-12 12:56:18 +01:00
}
sub getShadingAngleLeft {
2018-11-19 09:06:50 +01:00
my $ self = shift ;
2019-04-25 17:15:56 +02:00
return AttrVal ( $ self - > { shuttersDev } , 'ASC_Shading_Angle_Left' , 75 ) ;
2018-11-12 12:56:18 +01:00
}
sub getShadingAngleRight {
2018-11-19 09:06:50 +01:00
my $ self = shift ;
2019-04-25 17:15:56 +02:00
return AttrVal ( $ self - > { shuttersDev } , 'ASC_Shading_Angle_Right' , 75 ) ;
2018-11-12 12:56:18 +01:00
}
2018-12-05 15:39:11 +01:00
sub getShadingMinOutsideTemperature {
my $ self = shift ;
2018-12-07 13:04:41 +01:00
return AttrVal ( $ self - > { shuttersDev } , 'ASC_Shading_Min_OutsideTemperature' ,
2019-04-25 17:15:56 +02:00
18 ) ;
2018-12-05 15:39:11 +01:00
}
sub getShadingMinElevation {
my $ self = shift ;
2019-06-10 14:03:03 +02:00
return $ self - > { $ self - > { shuttersDev } } - > { ASC_Shading_MinMax_Elevation }
- > { minVal }
2019-06-10 13:41:46 +02:00
if (
exists (
$ self - > { $ self - > { shuttersDev } } - > { ASC_Shading_MinMax_Elevation }
- > { LASTGETTIME }
)
and ( gettimeofday ( ) -
$ self - > { $ self - > { shuttersDev } } - > { ASC_Shading_MinMax_Elevation }
- > { LASTGETTIME } ) < 2
) ;
2019-06-10 14:03:03 +02:00
$ self - > { $ self - > { shuttersDev } } - > { ASC_Shading_MinMax_Elevation }
- > { LASTGETTIME } = int ( gettimeofday ( ) ) ;
2019-06-10 13:41:46 +02:00
my ( $ min , $ max ) =
FHEM::AutoShuttersControl:: GetAttrValues ( $ self - > { shuttersDev } ,
'ASC_Shading_MinMax_Elevation' , '25.0:100.0' ) ;
### erwartetes Ergebnis
# MIN:MAX
2019-06-10 14:03:03 +02:00
$ self - > { $ self - > { shuttersDev } } - > { ASC_Shading_MinMax_Elevation } - > { minVal } =
$ min ;
$ self - > { $ self - > { shuttersDev } } - > { ASC_Shading_MinMax_Elevation } - > { maxVal } =
2019-06-10 15:36:02 +02:00
( $ max ne 'none' ? $ max : 100 ) ;
2019-06-10 13:41:46 +02:00
2019-06-10 14:03:03 +02:00
return $ self - > { $ self - > { shuttersDev } } - > { ASC_Shading_MinMax_Elevation }
- > { minVal } ;
2019-06-10 13:41:46 +02:00
}
sub getShadingMaxElevation {
2019-06-10 14:03:03 +02:00
my $ self = shift ;
2019-06-10 13:41:46 +02:00
2019-06-10 14:03:03 +02:00
return $ self - > { $ self - > { shuttersDev } } - > { ASC_Shading_MinMax_Elevation }
- > { maxVal }
2019-06-10 13:41:46 +02:00
if (
exists (
$ self - > { $ self - > { shuttersDev } } - > { ASC_Shading_MinMax_Elevation }
- > { LASTGETTIME }
)
and ( gettimeofday ( ) -
$ self - > { $ self - > { shuttersDev } } - > { ASC_Shading_MinMax_Elevation }
- > { LASTGETTIME } ) < 2
) ;
$ shutters - > getShadingMinElevation ;
2019-06-10 14:03:03 +02:00
return $ self - > { $ self - > { shuttersDev } } - > { ASC_Shading_MinMax_Elevation }
- > { maxVal } ;
2018-12-05 15:39:11 +01:00
}
sub getShadingStateChangeSunny {
my $ self = shift ;
2018-12-07 13:04:41 +01:00
return AttrVal ( $ self - > { shuttersDev } , 'ASC_Shading_StateChange_Sunny' ,
2019-04-25 17:15:56 +02:00
35000 ) ;
2018-12-05 15:39:11 +01:00
}
sub getShadingStateChangeCloudy {
my $ self = shift ;
2018-12-07 13:04:41 +01:00
return AttrVal ( $ self - > { shuttersDev } , 'ASC_Shading_StateChange_Cloudy' ,
2019-04-25 17:15:56 +02:00
20000 ) ;
2018-12-05 15:39:11 +01:00
}
sub getShadingWaitingPeriod {
my $ self = shift ;
return AttrVal ( $ self - > { shuttersDev } , 'ASC_Shading_WaitingPeriod' , 1200 ) ;
}
### Ende Beschattung
2018-10-30 08:18:09 +01:00
sub getOffset {
my $ self = shift ;
2019-06-03 07:44:35 +02:00
my $ val = AttrVal ( $ self - > { shuttersDev } , 'ASC_Drive_Offset' , - 1 ) ;
return ( $ val =~ /^\d+$/ ? $ val : - 1 ) ;
2018-10-30 08:18:09 +01:00
}
2019-01-21 12:27:22 +01:00
sub getOffsetStart {
my $ self = shift ;
2019-01-23 10:00:47 +01:00
2019-06-03 07:44:35 +02:00
my $ val = AttrVal ( $ self - > { shuttersDev } , 'ASC_Drive_OffsetStart' , - 1 ) ;
return ( ( $ val > 0 and $ val =~ /^\d+$/ ) ? $ val : - 1 ) ;
2019-01-21 12:27:22 +01:00
}
2018-12-06 15:24:16 +01:00
sub getBlockingTimeAfterManual {
my $ self = shift ;
2018-12-07 13:04:41 +01:00
return AttrVal ( $ self - > { shuttersDev } , 'ASC_BlockingTime_afterManual' ,
1200 ) ;
2018-12-06 15:24:16 +01:00
}
2018-12-05 15:39:11 +01:00
sub getBlockingTimeBeforNightClose {
my $ self = shift ;
2018-12-07 13:04:41 +01:00
return AttrVal ( $ self - > { shuttersDev } , 'ASC_BlockingTime_beforNightClose' ,
3600 ) ;
2018-12-05 15:39:11 +01:00
}
sub getBlockingTimeBeforDayOpen {
my $ self = shift ;
2018-12-07 13:04:41 +01:00
return AttrVal ( $ self - > { shuttersDev } , 'ASC_BlockingTime_beforDayOpen' ,
3600 ) ;
2018-12-05 15:39:11 +01:00
}
2018-10-10 10:43:42 +02:00
sub getPosCmd {
2018-10-27 13:36:11 +02:00
my $ self = shift ;
2018-10-08 21:05:47 +02:00
2018-11-07 08:22:11 +01:00
return AttrVal ( $ self - > { shuttersDev } , 'ASC_Pos_Reading' , 'pct' ) ;
2018-10-08 21:05:47 +02:00
}
2018-10-10 10:43:42 +02:00
sub getOpenPos {
2018-10-27 13:36:11 +02:00
my $ self = shift ;
2018-10-08 21:05:47 +02:00
2019-04-25 21:34:46 +02:00
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 ) ] ) ;
2018-10-08 21:05:47 +02:00
}
2018-10-10 10:43:42 +02:00
sub getVentilatePos {
2018-10-27 13:36:11 +02:00
my $ self = shift ;
2018-10-08 21:05:47 +02:00
2019-04-25 21:34:46 +02:00
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 ) ] ) ;
2018-10-08 21:05:47 +02:00
}
2018-10-10 10:43:42 +02:00
sub getClosedPos {
2018-10-27 13:36:11 +02:00
my $ self = shift ;
2018-10-08 21:05:47 +02:00
2019-04-25 21:34:46 +02:00
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 ) ] ) ;
2018-10-08 21:05:47 +02:00
}
2018-10-10 10:43:42 +02:00
sub getVentilateOpen {
2018-10-27 13:36:11 +02:00
my $ self = shift ;
2018-10-08 21:05:47 +02:00
2019-04-25 17:15:56 +02:00
return AttrVal ( $ self - > { shuttersDev } , 'ASC_Ventilate_Window_Open' , 'on' ) ;
2018-10-08 21:05:47 +02:00
}
2018-11-15 15:01:34 +01:00
sub getComfortOpenPos {
2018-10-27 13:36:11 +02:00
my $ self = shift ;
2018-10-14 18:19:23 +02:00
2019-04-25 21:34:46 +02:00
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 ) ] ) ;
2018-10-08 21:05:47 +02:00
}
2018-10-10 10:43:42 +02:00
sub getPartyMode {
2018-10-27 13:36:11 +02:00
my $ self = shift ;
2019-04-28 07:32:48 +02:00
2018-10-27 13:36:11 +02:00
return AttrVal ( $ self - > { shuttersDev } , 'ASC_Partymode' , 'off' ) ;
2018-10-08 21:05:47 +02:00
}
2018-10-10 10:43:42 +02:00
sub getRoommates {
2019-04-25 21:34:46 +02:00
my $ self = shift ;
2018-10-08 21:05:47 +02:00
2019-04-25 17:15:56 +02:00
return AttrVal ( $ self - > { shuttersDev } , 'ASC_Roommate_Device' , 'none' ) ;
2018-10-08 21:05:47 +02:00
}
2018-10-10 10:43:42 +02:00
sub getRoommatesReading {
2019-04-25 21:34:46 +02:00
my $ self = shift ;
2018-10-08 21:05:47 +02:00
2019-04-25 17:15:56 +02:00
return AttrVal ( $ self - > { shuttersDev } , 'ASC_Roommate_Reading' , 'state' ) ;
2018-10-08 21:05:47 +02:00
}
2019-02-28 09:05:23 +01:00
sub getWindPos {
my $ self = shift ;
my $ name = $ self - > { name } ;
2019-04-09 12:13:46 +02:00
return $ self - > { $ self - > { shuttersDev } } - > { ASC_WindParameters } - > { closedPos }
if (
exists (
$ self - > { $ self - > { shuttersDev } } - > { ASC_WindParameters } - > { LASTGETTIME }
)
and ( gettimeofday ( ) -
$ self - > { $ self - > { shuttersDev } } - > { ASC_WindParameters } - > { LASTGETTIME }
) < 2
) ;
2019-03-07 10:52:23 +01:00
$ shutters - > getWindMax ;
return $ self - > { $ self - > { shuttersDev } } - > { ASC_WindParameters } - > { closedPos } ;
2019-02-28 09:05:23 +01:00
}
sub getWindMax {
my $ self = shift ;
my $ name = $ self - > { name } ;
2019-03-07 17:58:30 +01:00
2019-04-09 12:13:46 +02:00
return $ self - > { $ self - > { shuttersDev } } - > { ASC_WindParameters } - > { triggermax }
if (
exists (
$ self - > { $ self - > { shuttersDev } } - > { ASC_WindParameters } - > { LASTGETTIME }
)
and ( gettimeofday ( ) -
$ self - > { $ self - > { shuttersDev } } - > { ASC_WindParameters } - > { LASTGETTIME }
) < 2
) ;
$ self - > { $ self - > { shuttersDev } } - > { ASC_WindParameters } - > { LASTGETTIME } =
int ( gettimeofday ( ) ) ;
my ( $ max , $ hyst , $ pos ) =
FHEM::AutoShuttersControl:: GetAttrValues ( $ self - > { shuttersDev } ,
2019-04-25 17:15:56 +02:00
'ASC_WindParameters' , '50:20' ) ;
2019-04-09 12:13:46 +02:00
2019-03-12 23:02:02 +01:00
## Erwartetes Ergebnis
# max:hyst pos
2019-04-09 12:13:46 +02:00
2019-04-29 13:24:01 +02:00
$ self - > { $ self - > { shuttersDev } } - > { ASC_WindParameters } - > { triggermax } = $ max ;
2019-04-25 21:34:46 +02:00
$ self - > { $ self - > { shuttersDev } } - > { ASC_WindParameters } - > { triggerhyst } =
2019-04-29 11:04:27 +02:00
( $ hyst ne 'none' ? $ max - $ hyst : $ max - 20 ) ;
2019-04-09 12:13:46 +02:00
$ self - > { $ self - > { shuttersDev } } - > { ASC_WindParameters } - > { closedPos } =
( $ pos ne 'none' ? $ pos : $ shutters - > getOpenPos ) ;
2019-02-28 09:05:23 +01:00
2019-03-07 10:52:23 +01:00
return $ self - > { $ self - > { shuttersDev } } - > { ASC_WindParameters } - > { triggermax } ;
2019-02-28 09:05:23 +01:00
}
sub getWindMin {
my $ self = shift ;
my $ name = $ self - > { name } ;
2019-04-09 12:13:46 +02:00
return $ self - > { $ self - > { shuttersDev } } - > { ASC_WindParameters } - > { triggerhyst }
if (
exists (
$ self - > { $ self - > { shuttersDev } } - > { ASC_WindParameters } - > { LASTGETTIME }
)
and ( gettimeofday ( ) -
$ self - > { $ self - > { shuttersDev } } - > { ASC_WindParameters } - > { LASTGETTIME }
) < 2
) ;
2019-03-07 10:52:23 +01:00
$ shutters - > getWindMax ;
2019-03-12 23:02:02 +01:00
return $ self - > { $ self - > { shuttersDev } } - > { ASC_WindParameters } - > { triggerhyst } ;
2019-02-28 09:05:23 +01:00
}
2019-04-28 22:13:27 +02:00
sub getWindProtection {
my $ self = shift ;
return AttrVal ( $ self - > { shuttersDev } , 'ASC_WindProtection' , 'on' ) ;
}
2019-04-29 13:22:37 +02:00
sub getRainProtection {
my $ self = shift ;
return AttrVal ( $ self - > { shuttersDev } , 'ASC_RainProtection' , 'on' ) ;
}
2018-10-10 10:43:42 +02:00
sub getModeUp {
2018-10-27 13:36:11 +02:00
my $ self = shift ;
2018-10-08 21:05:47 +02:00
2019-04-25 17:15:56 +02:00
return AttrVal ( $ self - > { shuttersDev } , 'ASC_Mode_Up' , 'always' ) ;
2018-10-08 21:05:47 +02:00
}
2018-10-10 10:43:42 +02:00
sub getModeDown {
2018-10-27 13:36:11 +02:00
my $ self = shift ;
2018-10-08 21:05:47 +02:00
2019-04-25 17:15:56 +02:00
return AttrVal ( $ self - > { shuttersDev } , 'ASC_Mode_Down' , 'always' ) ;
2018-10-01 08:43:59 +02:00
}
2018-10-10 10:43:42 +02:00
sub getLockOut {
2018-10-27 13:36:11 +02:00
my $ self = shift ;
2018-10-08 21:05:47 +02:00
2018-11-14 15:26:32 +01:00
return AttrVal ( $ self - > { shuttersDev } , 'ASC_LockOut' , 'off' ) ;
}
sub getLockOutCmd {
my $ self = shift ;
return AttrVal ( $ self - > { shuttersDev } , 'ASC_LockOut_Cmd' , 'none' ) ;
2018-10-08 21:05:47 +02:00
}
2018-10-10 10:43:42 +02:00
sub getAntiFreeze {
2018-10-27 13:36:11 +02:00
my $ self = shift ;
2018-10-08 21:05:47 +02:00
2018-10-27 13:36:11 +02:00
return AttrVal ( $ self - > { shuttersDev } , 'ASC_Antifreeze' , 'off' ) ;
2018-10-08 21:05:47 +02:00
}
2018-10-10 10:43:42 +02:00
sub getAutoAstroModeMorning {
2019-04-25 21:34:46 +02:00
my $ self = shift ;
2018-10-08 21:05:47 +02:00
2019-04-25 21:34:46 +02:00
return AttrVal ( $ self - > { shuttersDev } , 'ASC_AutoAstroModeMorning' , 'none' ) ;
2018-10-08 21:05:47 +02:00
}
2018-10-10 10:43:42 +02:00
sub getAutoAstroModeEvening {
2019-04-25 21:34:46 +02:00
my $ self = shift ;
2018-10-08 21:05:47 +02:00
2019-04-25 21:34:46 +02:00
return AttrVal ( $ self - > { shuttersDev } , 'ASC_AutoAstroModeEvening' , 'none' ) ;
2018-10-08 21:05:47 +02:00
}
2018-10-10 10:43:42 +02:00
sub getAutoAstroModeMorningHorizon {
2018-10-27 13:36:11 +02:00
my $ self = shift ;
2018-10-08 21:05:47 +02:00
2018-10-27 13:36:11 +02:00
return AttrVal ( $ self - > { shuttersDev } , 'ASC_AutoAstroModeMorningHorizon' ,
2019-04-25 17:15:56 +02:00
'none' ) ;
2018-10-08 21:05:47 +02:00
}
2018-10-10 10:43:42 +02:00
sub getAutoAstroModeEveningHorizon {
2018-10-27 13:36:11 +02:00
my $ self = shift ;
2018-10-08 21:05:47 +02:00
2018-10-27 13:36:11 +02:00
return AttrVal ( $ self - > { shuttersDev } , 'ASC_AutoAstroModeEveningHorizon' ,
2019-04-25 17:15:56 +02:00
'none' ) ;
2018-10-08 21:05:47 +02:00
}
2018-11-03 19:01:29 +01:00
sub getUp {
2018-10-27 13:36:11 +02:00
my $ self = shift ;
2018-10-08 21:05:47 +02:00
2018-10-27 13:36:11 +02:00
return AttrVal ( $ self - > { shuttersDev } , 'ASC_Up' , 'astro' ) ;
2018-10-08 21:05:47 +02:00
}
2018-11-03 19:01:29 +01:00
sub getDown {
2018-10-27 13:36:11 +02:00
my $ self = shift ;
2018-10-08 21:05:47 +02:00
2018-10-27 13:36:11 +02:00
return AttrVal ( $ self - > { shuttersDev } , 'ASC_Down' , 'astro' ) ;
2018-10-08 21:05:47 +02:00
}
2018-10-10 10:43:42 +02:00
sub getTimeUpEarly {
2018-10-27 13:36:11 +02:00
my $ self = shift ;
2018-10-08 21:05:47 +02:00
2019-04-25 17:15:56 +02:00
return AttrVal ( $ self - > { shuttersDev } , 'ASC_Time_Up_Early' , '05:00' ) ;
2018-10-08 21:05:47 +02:00
}
2018-10-10 10:43:42 +02:00
sub getTimeUpLate {
2018-10-27 13:36:11 +02:00
my $ self = shift ;
2018-10-08 21:05:47 +02:00
2019-04-25 17:15:56 +02:00
return AttrVal ( $ self - > { shuttersDev } , 'ASC_Time_Up_Late' , '08:30' ) ;
2018-10-08 21:05:47 +02:00
}
2018-10-10 10:43:42 +02:00
sub getTimeDownEarly {
2018-10-27 13:36:11 +02:00
my $ self = shift ;
2018-10-08 21:05:47 +02:00
2019-04-25 17:15:56 +02:00
return AttrVal ( $ self - > { shuttersDev } , 'ASC_Time_Down_Early' , '16:00' ) ;
2018-10-08 21:05:47 +02:00
}
2018-10-10 10:43:42 +02:00
sub getTimeDownLate {
2018-10-27 13:36:11 +02:00
my $ self = shift ;
2018-10-08 21:05:47 +02:00
2019-04-25 17:15:56 +02:00
return AttrVal ( $ self - > { shuttersDev } , 'ASC_Time_Down_Late' , '22:00' ) ;
2018-10-08 21:05:47 +02:00
}
2018-10-10 10:43:42 +02:00
sub getTimeUpWeHoliday {
2018-10-27 13:36:11 +02:00
my $ self = shift ;
2018-10-08 21:05:47 +02:00
2019-04-25 21:34:46 +02:00
return AttrVal ( $ self - > { shuttersDev } , 'ASC_Time_Up_WE_Holiday' , '08:00' ) ;
2018-10-08 21:05:47 +02:00
}
2018-10-16 10:30:10 +02:00
sub getBrightnessMinVal {
2018-10-27 13:36:11 +02:00
my $ self = shift ;
2018-10-16 10:30:10 +02:00
2019-04-09 12:13:46 +02:00
return $ self - > { $ self - > { shuttersDev } } - > { ASC_BrightnessSensor } - > { triggermin }
if (
exists (
$ self - > { $ self - > { shuttersDev } } - > { ASC_BrightnessSensor }
- > { LASTGETTIME }
)
and ( gettimeofday ( ) -
$ self - > { $ self - > { shuttersDev } } - > { ASC_BrightnessSensor }
- > { LASTGETTIME } ) < 2
) ;
2019-03-07 17:58:30 +01:00
$ shutters - > _getBrightnessSensor ;
2019-04-09 12:13:46 +02:00
return $ self - > { $ self - > { shuttersDev } } - > { ASC_BrightnessSensor }
- > { triggermin } ;
2018-10-16 10:30:10 +02:00
}
sub getBrightnessMaxVal {
2018-10-27 13:36:11 +02:00
my $ self = shift ;
2018-10-16 10:30:10 +02:00
2019-04-09 12:13:46 +02:00
return $ self - > { $ self - > { shuttersDev } } - > { ASC_BrightnessSensor } - > { triggermax }
if (
exists (
$ self - > { $ self - > { shuttersDev } } - > { ASC_BrightnessSensor }
- > { LASTGETTIME }
)
and ( gettimeofday ( ) -
$ self - > { $ self - > { shuttersDev } } - > { ASC_BrightnessSensor }
- > { LASTGETTIME } ) < 2
) ;
2019-03-07 17:58:30 +01:00
$ shutters - > _getBrightnessSensor ;
2019-04-09 12:13:46 +02:00
return $ self - > { $ self - > { shuttersDev } } - > { ASC_BrightnessSensor }
- > { triggermax } ;
2018-10-16 10:30:10 +02:00
}
2019-04-25 17:15:56 +02:00
sub getDriveUpMaxDuration {
my $ self = shift ;
2019-04-25 21:34:46 +02:00
return AttrVal ( $ self - > { shuttersDev } , 'ASC_DriveUpMaxDuration' , 60 ) ;
2019-04-25 17:15:56 +02:00
}
2018-10-09 18:05:55 +02:00
## Subklasse Readings von ASC_Shutters ##
package ASC_Shutters::Readings ;
2018-10-08 21:05:47 +02:00
use strict ;
use warnings ;
2018-11-07 08:22:11 +01:00
use GPUtils qw( GP_Import ) ;
2018-10-08 21:05:47 +02:00
## Import der FHEM Funktionen
BEGIN {
2018-10-14 18:19:23 +02:00
GP_Import (
qw(
2018-11-29 21:33:08 +01:00
ReadingsVal
ReadingsNum )
2018-10-14 18:19:23 +02:00
) ;
}
2018-10-08 21:05:47 +02:00
2018-10-12 06:32:01 +02:00
sub getBrightness {
2018-10-27 13:36:11 +02:00
my $ self = shift ;
2018-10-10 10:43:42 +02:00
2019-02-28 09:05:23 +01:00
return ReadingsNum ( $ shutters - > _getBrightnessSensor ,
2018-12-07 12:57:45 +01:00
$ shutters - > getBrightnessReading , - 1 ) ;
2018-10-12 06:32:01 +02:00
}
2018-10-10 10:43:42 +02:00
2019-02-28 09:05:23 +01:00
sub getWindStatus {
my $ self = shift ;
2019-03-04 08:40:58 +01:00
return ReadingsVal ( $ ascDev - > _getWindSensor ,
$ ascDev - > getWindSensorReading , - 1 ) ;
2019-02-28 09:05:23 +01:00
}
2018-10-10 10:43:42 +02:00
sub getStatus {
2018-10-27 13:36:11 +02:00
my $ self = shift ;
2018-10-10 10:43:42 +02:00
2018-11-29 21:33:08 +01:00
return ReadingsNum ( $ self - > { shuttersDev } , $ shutters - > getPosCmd , 0 ) ;
2018-10-08 21:05:47 +02:00
}
2018-10-10 10:43:42 +02:00
sub getDelayCmd {
2019-04-25 21:34:46 +02:00
my $ self = shift ;
2018-10-08 21:05:47 +02:00
2018-10-27 13:36:11 +02:00
return $ self - > { $ self - > { shuttersDev } } { delayCmd } ;
2018-10-08 21:05:47 +02:00
}
2019-05-17 14:20:57 +02:00
sub getASCenable {
my $ self = shift ;
return ReadingsVal ( $ self - > { shuttersDev } , 'ASC_Enable' , 'on' ) ;
}
2018-10-10 10:43:42 +02:00
## Klasse Fenster (Window) und die Subklassen Attr und Readings ##
package ASC_Window ;
2018-10-14 18:19:23 +02:00
our @ ISA = qw( ASC_Window::Attr ASC_Window::Readings ) ;
2018-10-10 10:43:42 +02:00
## Subklasse Attr von Klasse ASC_Window ##
package ASC_Window::Attr ;
2018-10-08 21:05:47 +02:00
2018-10-10 10:43:42 +02:00
use strict ;
use warnings ;
2018-11-07 08:22:11 +01:00
use GPUtils qw( GP_Import ) ;
2018-10-10 10:43:42 +02:00
## Import der FHEM Funktionen
BEGIN {
2018-10-14 18:19:23 +02:00
GP_Import (
qw(
AttrVal )
) ;
}
2018-10-10 10:43:42 +02:00
sub getSubTyp {
2019-04-25 21:34:46 +02:00
my $ self = shift ;
2018-10-10 10:43:42 +02:00
2019-04-25 17:15:56 +02:00
return AttrVal ( $ self - > { shuttersDev } , 'ASC_WindowRec_subType' , 'twostate' ) ;
2018-10-10 10:43:42 +02:00
}
2018-11-03 19:01:29 +01:00
sub _getWinDev {
2019-04-25 21:34:46 +02:00
my $ self = shift ;
2018-10-10 10:43:42 +02:00
2019-04-25 17:15:56 +02:00
return AttrVal ( $ self - > { shuttersDev } , 'ASC_WindowRec' , 'none' ) ;
2018-10-10 10:43:42 +02:00
}
## Subklasse Readings von Klasse ASC_Window ##
package ASC_Window::Readings ;
use strict ;
use warnings ;
2018-11-07 08:22:11 +01:00
use GPUtils qw( GP_Import ) ;
2018-10-10 10:43:42 +02:00
## Import der FHEM Funktionen
BEGIN {
2018-10-14 18:19:23 +02:00
GP_Import (
qw(
ReadingsVal )
) ;
}
2018-10-10 10:43:42 +02:00
sub getWinStatus {
2019-04-25 21:34:46 +02:00
my $ self = shift ;
2018-10-10 10:43:42 +02:00
2019-04-25 17:15:56 +02:00
return ReadingsVal ( $ shutters - > _getWinDev , 'state' , 'closed' ) ;
2018-10-08 21:05:47 +02:00
}
## Klasse ASC_Roommate ##
package ASC_Roommate ;
use strict ;
use warnings ;
2018-11-07 08:22:11 +01:00
use GPUtils qw( GP_Import ) ;
2018-10-08 21:05:47 +02:00
## Import der FHEM Funktionen
BEGIN {
2018-10-14 18:19:23 +02:00
GP_Import (
qw(
ReadingsVal )
) ;
}
2018-10-08 21:05:47 +02:00
2018-11-03 19:01:29 +01:00
sub _getRoommateStatus {
2018-10-14 18:19:23 +02:00
my $ self = shift ;
my $ roommate = $ self - > { roommate } ;
2018-10-08 21:05:47 +02:00
2019-04-25 23:07:18 +02:00
return ReadingsVal ( $ roommate , $ shutters - > getRoommatesReading , 'none' ) ;
2018-10-08 21:05:47 +02:00
}
2018-11-03 19:01:29 +01:00
sub _getRoommateLastStatus {
2018-10-14 18:19:23 +02:00
my $ self = shift ;
my $ roommate = $ self - > { roommate } ;
my $ default = $ self - > { defaultarg } ;
2018-10-08 21:05:47 +02:00
2018-10-28 18:12:40 +01:00
$ default = 'none' if ( not defined ( $ default ) ) ;
2018-10-14 18:19:23 +02:00
return ReadingsVal ( $ roommate , 'lastState' , $ default ) ;
2018-10-08 21:05:47 +02:00
}
## Klasse ASC_Dev plus Subklassen ASC_Attr_Dev und ASC_Readings_Dev##
package ASC_Dev ;
2018-10-14 18:19:23 +02:00
our @ ISA = qw( ASC_Dev::Readings ASC_Dev::Attr ) ;
2018-10-08 21:05:47 +02:00
use strict ;
use warnings ;
sub new {
2018-10-14 18:19:23 +02:00
my $ class = shift ;
my $ self = { name = > undef , } ;
2018-10-08 21:05:47 +02:00
bless $ self , $ class ;
return $ self ;
}
2018-10-10 10:43:42 +02:00
sub setName {
2018-10-14 18:19:23 +02:00
my ( $ self , $ name ) = @ _ ;
2018-10-17 09:50:11 +02:00
2018-10-14 18:19:23 +02:00
$ self - > { name } = $ name if ( defined ( $ name ) ) ;
2018-10-10 10:43:42 +02:00
return $ self - > { name } ;
}
sub setDefault {
2018-10-14 18:19:23 +02:00
my ( $ self , $ defaultarg ) = @ _ ;
2018-10-17 09:50:11 +02:00
2018-10-14 18:19:23 +02:00
$ self - > { defaultarg } = $ defaultarg if ( defined ( $ defaultarg ) ) ;
2018-10-10 10:43:42 +02:00
return $ self - > { defaultarg } ;
}
2019-04-02 19:28:54 +02:00
sub getName {
2019-04-09 12:13:46 +02:00
my $ self = shift ;
2019-04-02 19:28:54 +02:00
return $ self - > { name } ;
}
2018-10-09 18:05:55 +02:00
## Subklasse Readings ##
package ASC_Dev::Readings ;
2018-10-08 21:05:47 +02:00
use strict ;
use warnings ;
2018-11-07 08:22:11 +01:00
use GPUtils qw( GP_Import ) ;
2018-10-08 21:05:47 +02:00
## Import der FHEM Funktionen
BEGIN {
2018-10-14 18:19:23 +02:00
GP_Import (
qw(
2018-10-27 13:36:11 +02:00
readingsSingleUpdate
ReadingsVal
defs )
2018-10-14 18:19:23 +02:00
) ;
}
2018-10-08 21:05:47 +02:00
2018-10-27 13:36:11 +02:00
sub setDelayCmdReading {
my $ self = shift ;
my $ name = $ self - > { name } ;
my $ hash = $ defs { $ name } ;
readingsSingleUpdate ( $ hash ,
$ shutters - > getShuttersDev . '_lastDelayPosValue' ,
$ shutters - > getDelayCmd , 1 ) ;
return 0 ;
}
2018-11-07 08:22:11 +01:00
sub setStateReading {
2018-11-08 08:32:47 +01:00
my $ self = shift ;
my $ value = shift ;
my $ name = $ self - > { name } ;
my $ hash = $ defs { $ name } ;
2018-11-07 08:22:11 +01:00
2018-11-08 08:32:47 +01:00
readingsSingleUpdate ( $ hash , 'state' ,
( defined ( $ value ) ? $ value : $ shutters - > getLastDrive ) , 1 ) ;
2018-11-07 08:22:11 +01:00
return 0 ;
}
2018-11-04 19:17:11 +01:00
sub setPosReading {
my $ self = shift ;
my $ name = $ self - > { name } ;
my $ hash = $ defs { $ name } ;
readingsSingleUpdate ( $ hash , $ shutters - > getShuttersDev . '_PosValue' ,
$ shutters - > getStatus , 1 ) ;
return 0 ;
}
2018-10-27 13:36:11 +02:00
sub setLastPosReading {
my $ self = shift ;
my $ name = $ self - > { name } ;
my $ hash = $ defs { $ name } ;
readingsSingleUpdate ( $ hash , $ shutters - > getShuttersDev . '_lastPosValue' ,
$ shutters - > getLastPos , 1 ) ;
return 0 ;
}
2018-11-03 19:01:29 +01:00
sub getPartyMode {
2019-04-25 21:34:46 +02:00
my $ self = shift ;
my $ name = $ self - > { name } ;
2018-10-08 21:05:47 +02:00
2019-04-27 20:58:17 +02:00
return ReadingsVal ( $ name , 'partyMode' , 'off' ) ;
2018-10-08 21:05:47 +02:00
}
2018-12-06 15:24:16 +01:00
sub getHardLockOut {
2019-04-25 21:34:46 +02:00
my $ self = shift ;
my $ name = $ self - > { name } ;
2018-10-08 21:05:47 +02:00
2019-04-25 17:15:56 +02:00
return ReadingsVal ( $ name , 'hardLockOut' , 'none' ) ;
2018-10-08 21:05:47 +02:00
}
2018-10-10 10:43:42 +02:00
sub getSunriseTimeWeHoliday {
2019-04-25 21:34:46 +02:00
my $ self = shift ;
my $ name = $ self - > { name } ;
2018-10-08 21:05:47 +02:00
2019-04-25 17:15:56 +02:00
return ReadingsVal ( $ name , 'sunriseTimeWeHoliday' , 'none' ) ;
2018-10-08 21:05:47 +02:00
}
2018-10-10 10:43:42 +02:00
sub getMonitoredDevs {
2018-10-14 18:19:23 +02:00
my $ self = shift ;
my $ name = $ self - > { name } ;
2018-10-08 21:05:47 +02:00
2018-10-14 18:19:23 +02:00
$ self - > { monitoredDevs } = ReadingsVal ( $ name , '.monitoredDevs' , 'none' ) ;
2018-10-08 21:05:47 +02:00
return $ self - > { monitoredDevs } ;
}
2018-10-10 10:43:42 +02:00
sub getOutTemp {
2018-10-14 18:19:23 +02:00
my $ self = shift ;
2018-10-08 21:05:47 +02:00
2018-11-19 09:06:50 +01:00
return ReadingsVal ( $ ascDev - > _getTempSensor , $ ascDev - > getTempReading ,
- 100 ) ;
2018-10-08 21:05:47 +02:00
}
2018-10-10 10:43:42 +02:00
sub getResidentsStatus {
2018-10-14 18:19:23 +02:00
my $ self = shift ;
2019-05-24 11:31:07 +02:00
my $ val =
ReadingsVal ( $ ascDev - > _getResidentsDev , $ ascDev - > getResidentsReading ,
2018-10-28 18:12:40 +01:00
'none' ) ;
2019-05-24 11:31:07 +02:00
if ( $ val =~ m/^(?:(.+)_)?(.+)$/ ) {
return ( $ 1 , $ 2 ) if ( wantarray ) ;
return $ 1 && $ 1 eq 'pet' ? 'absent' : $ 2 ;
}
elsif (
2019-05-24 11:36:06 +02:00
ReadingsVal ( $ ascDev - > _getResidentsDev , 'homealoneType' , '-' ) eq
'PET' )
2019-05-24 11:31:07 +02:00
{
return ( 'pet' , 'absent' ) if ( wantarray ) ;
return 'absent' ;
}
else {
return ( undef , $ val ) if ( wantarray ) ;
return $ val ;
}
2018-10-09 18:05:55 +02:00
}
2018-10-14 18:19:23 +02:00
sub getResidentsLastStatus {
my $ self = shift ;
2019-05-24 11:31:07 +02:00
my $ val = ReadingsVal ( $ ascDev - > _getResidentsDev , 'lastState' , 'none' ) ;
2018-10-09 18:05:55 +02:00
2019-05-24 11:31:07 +02:00
if ( $ val =~ m/^(?:(.+)_)?(.+)$/ ) {
return ( $ 1 , $ 2 ) if ( wantarray ) ;
return $ 1 && $ 1 eq 'pet' ? 'absent' : $ 2 ;
}
elsif (
2019-05-24 11:36:06 +02:00
ReadingsVal ( $ ascDev - > _getResidentsDev , 'lastHomealoneType' , '-' ) eq
'PET' )
2019-05-24 11:31:07 +02:00
{
return ( 'pet' , 'absent' ) if ( wantarray ) ;
return 'absent' ;
}
else {
return ( undef , $ val ) if ( wantarray ) ;
return $ val ;
}
2018-10-09 18:05:55 +02:00
}
2019-05-04 23:01:57 +02:00
sub getAutoShuttersControlShading {
my $ self = shift ;
my $ name = $ self - > { name } ;
return ReadingsVal ( $ name , 'controlShading' , 'none' ) ;
}
2018-10-14 18:19:23 +02:00
sub getSelfDefense {
my $ self = shift ;
my $ name = $ self - > { name } ;
return ReadingsVal ( $ name , 'selfDefense' , 'none' ) ;
}
2018-10-08 21:05:47 +02:00
2018-11-14 03:41:38 +01:00
sub getAzimuth {
my $ self = shift ;
2018-11-14 15:26:32 +01:00
my $ azimuth ;
2018-11-19 09:06:50 +01:00
$ azimuth = ReadingsVal ( $ ascDev - > _getTwilightDevice , 'azimuth' , - 1 )
if ( $ defs { $ ascDev - > _getTwilightDevice } - > { TYPE } eq 'Twilight' ) ;
$ azimuth = ReadingsVal ( $ ascDev - > _getTwilightDevice , 'SunAz' , - 1 )
if ( $ defs { $ ascDev - > _getTwilightDevice } - > { TYPE } eq 'Astro' ) ;
2018-11-14 15:26:32 +01:00
return $ azimuth ;
2018-11-14 03:41:38 +01:00
}
sub getElevation {
my $ self = shift ;
2018-11-14 15:26:32 +01:00
my $ elevation ;
2018-11-19 09:06:50 +01:00
$ elevation = ReadingsVal ( $ ascDev - > _getTwilightDevice , 'elevation' , - 1 )
if ( $ defs { $ ascDev - > _getTwilightDevice } - > { TYPE } eq 'Twilight' ) ;
$ elevation = ReadingsVal ( $ ascDev - > _getTwilightDevice , 'SunAlt' , - 1 )
if ( $ defs { $ ascDev - > _getTwilightDevice } - > { TYPE } eq 'Astro' ) ;
2018-11-14 15:26:32 +01:00
return $ elevation ;
2018-11-14 03:41:38 +01:00
}
2019-05-17 14:20:57 +02:00
sub getASCenable {
my $ self = shift ;
my $ name = $ self - > { name } ;
return ReadingsVal ( $ name , 'ascEnable' , 'none' ) ;
}
2018-10-09 18:05:55 +02:00
## Subklasse Attr ##
package ASC_Dev::Attr ;
2018-10-08 21:05:47 +02:00
use strict ;
use warnings ;
2018-11-07 08:22:11 +01:00
use GPUtils qw( GP_Import ) ;
2018-10-08 21:05:47 +02:00
## Import der FHEM Funktionen
BEGIN {
2018-10-14 18:19:23 +02:00
GP_Import (
qw(
2019-03-06 15:53:48 +01:00
AttrVal
gettimeofday )
2018-10-14 18:19:23 +02:00
) ;
}
2018-10-08 21:05:47 +02:00
2018-10-30 08:18:09 +01:00
sub getShuttersOffset {
2018-10-30 19:10:50 +01:00
my $ self = shift ;
my $ name = $ self - > { name } ;
2019-03-31 17:17:56 +02:00
return AttrVal ( $ name , 'ASC_shuttersDriveOffset' , - 1 ) ;
2018-10-30 08:18:09 +01:00
}
2018-10-12 06:32:01 +02:00
sub getBrightnessMinVal {
2019-04-09 12:13:46 +02:00
my $ self = shift ;
my $ name = $ self - > { name } ;
2018-10-12 06:32:01 +02:00
2019-04-09 12:13:46 +02:00
return $ self - > { ASC_brightness } - > { triggermin }
if ( exists ( $ self - > { ASC_brightness } - > { LASTGETTIME } )
and ( gettimeofday ( ) - $ self - > { ASC_brightness } - > { LASTGETTIME } ) < 2 ) ;
2019-03-12 23:02:02 +01:00
$ ascDev - > getBrightnessMaxVal ;
2019-04-09 12:13:46 +02:00
2019-03-12 23:02:02 +01:00
return $ self - > { ASC_brightness } - > { triggermin } ;
2018-10-12 06:32:01 +02:00
}
sub getBrightnessMaxVal {
2019-04-09 12:13:46 +02:00
my $ self = shift ;
my $ name = $ self - > { name } ;
return $ self - > { ASC_brightness } - > { triggermax }
if ( exists ( $ self - > { ASC_brightness } - > { LASTGETTIME } )
and ( gettimeofday ( ) - $ self - > { ASC_brightness } - > { LASTGETTIME } ) < 2 ) ;
$ self - > { ASC_brightness } - > { LASTGETTIME } = int ( gettimeofday ( ) ) ;
2019-04-20 18:18:50 +02:00
2019-04-17 16:25:05 +02:00
my ( $ triggermax , $ triggermin ) =
2019-04-09 12:13:46 +02:00
FHEM::AutoShuttersControl:: GetAttrValues ( $ name ,
2019-04-25 17:15:56 +02:00
'ASC_brightnessDriveUpDown' , '800:500' ) ;
2018-10-08 21:05:47 +02:00
2019-03-12 23:02:02 +01:00
## erwartetes Ergebnis
# max:min
2019-04-25 17:15:56 +02:00
$ self - > { ASC_brightness } - > { triggermin } = $ triggermin ;
$ self - > { ASC_brightness } - > { triggermax } = $ triggermax ;
2019-03-12 23:02:02 +01:00
return $ self - > { ASC_brightness } - > { triggermax } ;
2018-10-12 06:32:01 +02:00
}
2018-10-08 21:05:47 +02:00
2018-11-14 03:41:38 +01:00
sub _getTwilightDevice {
2018-11-19 09:06:50 +01:00
my $ self = shift ;
my $ name = $ self - > { name } ;
2018-11-14 03:41:38 +01:00
return AttrVal ( $ name , 'ASC_twilightDevice' , 'none' ) ;
}
2018-10-10 10:43:42 +02:00
sub getAutoAstroModeEvening {
2019-04-25 21:34:46 +02:00
my $ self = shift ;
my $ name = $ self - > { name } ;
2018-10-08 21:05:47 +02:00
2019-05-04 23:01:57 +02:00
return AttrVal ( $ name , 'ASC_autoAstroModeEvening' , 'REAL' ) ;
2018-10-08 21:05:47 +02:00
}
2018-10-10 10:43:42 +02:00
sub getAutoAstroModeEveningHorizon {
2018-10-14 18:19:23 +02:00
my $ self = shift ;
my $ name = $ self - > { name } ;
2018-10-08 21:05:47 +02:00
2018-10-14 18:19:23 +02:00
return AttrVal ( $ name , 'ASC_autoAstroModeEveningHorizon' , 0 ) ;
2018-10-08 21:05:47 +02:00
}
2018-10-10 10:43:42 +02:00
sub getAutoAstroModeMorning {
2019-04-25 21:34:46 +02:00
my $ self = shift ;
my $ name = $ self - > { name } ;
2018-10-08 21:05:47 +02:00
2019-05-04 23:01:57 +02:00
return AttrVal ( $ name , 'ASC_autoAstroModeMorning' , 'REAL' ) ;
2018-10-08 21:05:47 +02:00
}
2018-10-10 10:43:42 +02:00
sub getAutoAstroModeMorningHorizon {
2018-10-14 18:19:23 +02:00
my $ self = shift ;
my $ name = $ self - > { name } ;
2018-10-08 21:05:47 +02:00
2018-10-14 18:19:23 +02:00
return AttrVal ( $ name , 'ASC_autoAstroModeMorningHorizon' , 0 ) ;
2018-10-08 21:05:47 +02:00
}
2018-10-10 10:43:42 +02:00
sub getAutoShuttersControlMorning {
2019-04-25 21:34:46 +02:00
my $ self = shift ;
my $ name = $ self - > { name } ;
2018-10-08 21:05:47 +02:00
2019-05-04 23:01:57 +02:00
return AttrVal ( $ name , 'ASC_autoShuttersControlMorning' , 'on' ) ;
2018-10-08 21:05:47 +02:00
}
2018-10-10 10:43:42 +02:00
sub getAutoShuttersControlEvening {
2019-04-25 21:34:46 +02:00
my $ self = shift ;
my $ name = $ self - > { name } ;
2018-10-08 21:05:47 +02:00
2019-05-04 23:01:57 +02:00
return AttrVal ( $ name , 'ASC_autoShuttersControlEvening' , 'on' ) ;
2018-10-08 21:05:47 +02:00
}
2018-10-10 10:43:42 +02:00
sub getAutoShuttersControlComfort {
2018-10-14 18:19:23 +02:00
my $ self = shift ;
my $ name = $ self - > { name } ;
2018-10-08 21:05:47 +02:00
2018-10-14 18:19:23 +02:00
return AttrVal ( $ name , 'ASC_autoShuttersControlComfort' , 'off' ) ;
2018-10-08 21:05:47 +02:00
}
2018-11-12 12:56:18 +01:00
sub getFreezeTemp {
2019-04-25 21:34:46 +02:00
my $ self = shift ;
my $ name = $ self - > { name } ;
2018-10-08 21:05:47 +02:00
2019-04-25 17:15:56 +02:00
return AttrVal ( $ name , 'ASC_freezeTemp' , 3 ) ;
2018-10-08 21:05:47 +02:00
}
2018-11-12 12:56:18 +01:00
sub _getTempSensor {
2019-04-09 12:13:46 +02:00
my $ self = shift ;
my $ name = $ self - > { name } ;
return $ self - > { ASC_tempSensor } - > { device }
if ( exists ( $ self - > { ASC_tempSensor } - > { LASTGETTIME } )
and ( gettimeofday ( ) - $ self - > { ASC_tempSensor } - > { LASTGETTIME } ) < 2 ) ;
$ self - > { ASC_tempSensor } - > { LASTGETTIME } = int ( gettimeofday ( ) ) ;
my ( $ device , $ reading ) =
FHEM::AutoShuttersControl:: GetAttrValues ( $ name , 'ASC_tempSensor' ,
'none' ) ;
2018-10-08 21:05:47 +02:00
2019-03-12 23:02:02 +01:00
## erwartetes Ergebnis
# DEVICE:READING
2019-03-06 15:53:48 +01:00
2019-04-09 12:13:46 +02:00
return $ device if ( $ device eq 'none' ) ;
2019-03-12 23:02:02 +01:00
$ self - > { ASC_tempSensor } - > { device } = $ device ;
2019-04-09 12:13:46 +02:00
$ self - > { ASC_tempSensor } - > { reading } =
( $ reading ne 'none' ? $ reading : 'temperature' ) ;
2019-03-06 15:53:48 +01:00
return $ self - > { ASC_tempSensor } - > { device } ;
2018-10-08 21:05:47 +02:00
}
2018-10-10 10:43:42 +02:00
sub getTempReading {
2019-04-09 12:13:46 +02:00
my $ self = shift ;
my $ name = $ self - > { name } ;
return $ self - > { ASC_tempSensor } - > { reading }
if ( exists ( $ self - > { ASC_tempSensor } - > { LASTGETTIME } )
and ( gettimeofday ( ) - $ self - > { ASC_tempSensor } - > { LASTGETTIME } ) < 2 ) ;
2019-03-06 15:53:48 +01:00
$ ascDev - > _getTempSensor ;
2019-03-12 23:02:02 +01:00
return $ self - > { ASC_tempSensor } - > { reading } ;
2018-10-08 21:05:47 +02:00
}
2018-08-15 10:27:53 +02:00
2018-11-03 19:01:29 +01:00
sub _getResidentsDev {
2019-04-09 12:13:46 +02:00
my $ self = shift ;
my $ name = $ self - > { name } ;
2018-10-09 18:05:55 +02:00
2019-04-09 12:13:46 +02:00
return $ self - > { ASC_residentsDev } - > { device }
if ( exists ( $ self - > { ASC_residentsDev } - > { LASTGETTIME } )
and ( gettimeofday ( ) - $ self - > { ASC_residentsDev } - > { LASTGETTIME } ) < 2 ) ;
$ self - > { ASC_residentsDev } - > { LASTGETTIME } = int ( gettimeofday ( ) ) ;
my ( $ device , $ reading ) =
FHEM::AutoShuttersControl:: GetAttrValues ( $ name , 'ASC_residentsDev' ,
'none' ) ;
2019-03-12 23:02:02 +01:00
$ self - > { ASC_residentsDev } - > { device } = $ device ;
2019-04-09 12:13:46 +02:00
$ self - > { ASC_residentsDev } - > { reading } =
( $ reading ne 'none' ? $ reading : 'state' ) ;
2019-03-06 15:53:48 +01:00
return $ self - > { ASC_residentsDev } - > { device } ;
2018-10-09 18:05:55 +02:00
}
2018-10-10 10:43:42 +02:00
sub getResidentsReading {
2019-04-09 12:13:46 +02:00
my $ self = shift ;
my $ name = $ self - > { name } ;
return $ self - > { ASC_residentsDev } - > { reading }
if ( exists ( $ self - > { ASC_residentsDev } - > { LASTGETTIME } )
and ( gettimeofday ( ) - $ self - > { ASC_residentsDev } - > { LASTGETTIME } ) < 2 ) ;
2019-03-06 15:53:48 +01:00
$ ascDev - > _getResidentsDev ;
2019-03-12 23:02:02 +01:00
return $ self - > { ASC_residentsDev } - > { reading } ;
2018-10-09 18:05:55 +02:00
}
2018-10-27 13:36:11 +02:00
2019-03-06 15:53:48 +01:00
sub _getRainSensor {
2019-04-09 12:13:46 +02:00
my $ self = shift ;
my $ name = $ self - > { name } ;
return $ self - > { ASC_rainSensor } - > { device }
if ( exists ( $ self - > { ASC_rainSensor } - > { LASTGETTIME } )
and ( gettimeofday ( ) - $ self - > { ASC_rainSensor } - > { LASTGETTIME } ) < 2 ) ;
$ self - > { ASC_rainSensor } - > { LASTGETTIME } = int ( gettimeofday ( ) ) ;
my ( $ device , $ reading , $ max , $ hyst , $ pos ) =
FHEM::AutoShuttersControl:: GetAttrValues ( $ name , 'ASC_rainSensor' ,
'none' ) ;
2018-10-27 13:36:11 +02:00
2019-03-12 23:02:02 +01:00
## erwartetes Ergebnis
# DEVICE:READING MAX:HYST
2019-04-09 12:13:46 +02:00
return $ device if ( $ device eq 'none' ) ;
2019-03-12 23:02:02 +01:00
$ self - > { ASC_rainSensor } - > { device } = $ device ;
2019-04-09 12:13:46 +02:00
$ self - > { ASC_rainSensor } - > { reading } =
( $ reading ne 'none' ? $ reading : 'state' ) ;
2019-03-12 23:02:02 +01:00
$ self - > { ASC_rainSensor } - > { triggermax } = ( $ max ne 'none' ? $ max : 1000 ) ;
2019-04-30 09:56:19 +02:00
$ self - > { ASC_rainSensor } - > { triggerhyst } = (
$ hyst ne 'none'
2019-04-29 13:24:01 +02:00
? $ max - $ hyst
2019-04-30 09:56:19 +02:00
: ( $ self - > { ASC_rainSensor } - > { triggermax } * 0 )
) ;
2019-04-09 12:13:46 +02:00
$ self - > { ASC_rainSensor } - > { shuttersClosedPos } =
2019-04-29 11:04:27 +02:00
( $ pos ne 'none' ? $ pos : $ shutters - > getClosedPos ) ;
2019-04-09 12:13:46 +02:00
2019-03-06 15:53:48 +01:00
return $ self - > { ASC_rainSensor } - > { device } ;
2018-10-27 13:36:11 +02:00
}
sub getRainSensorReading {
2019-04-09 12:13:46 +02:00
my $ self = shift ;
my $ name = $ self - > { name } ;
return $ self - > { ASC_rainSensor } - > { reading }
if ( exists ( $ self - > { ASC_rainSensor } - > { LASTGETTIME } )
and ( gettimeofday ( ) - $ self - > { ASC_rainSensor } - > { LASTGETTIME } ) < 2 ) ;
2019-03-06 15:53:48 +01:00
$ ascDev - > _getRainSensor ;
2019-03-12 23:02:02 +01:00
return $ self - > { ASC_rainSensor } - > { reading } ;
2019-03-06 15:53:48 +01:00
}
2018-10-27 13:36:11 +02:00
2019-03-06 15:53:48 +01:00
sub getRainTriggerMax {
my $ self = shift ;
my $ name = $ self - > { name } ;
2019-04-09 12:13:46 +02:00
return $ self - > { ASC_rainSensor } - > { triggermax }
if ( exists ( $ self - > { ASC_rainSensor } - > { LASTGETTIME } )
and ( gettimeofday ( ) - $ self - > { ASC_rainSensor } - > { LASTGETTIME } ) < 2 ) ;
2019-03-06 15:53:48 +01:00
$ ascDev - > _getRainSensor ;
2019-03-12 23:02:02 +01:00
return $ self - > { ASC_rainSensor } - > { triggermax } ;
2019-03-06 15:53:48 +01:00
}
sub getRainTriggerMin {
my $ self = shift ;
my $ name = $ self - > { name } ;
2019-04-09 12:13:46 +02:00
return $ self - > { ASC_rainSensor } - > { triggerhyst }
if ( exists ( $ self - > { ASC_rainSensor } - > { LASTGETTIME } )
and ( gettimeofday ( ) - $ self - > { ASC_rainSensor } - > { LASTGETTIME } ) < 2 ) ;
2019-03-06 15:53:48 +01:00
$ ascDev - > _getRainSensor ;
2019-03-12 23:02:02 +01:00
return $ self - > { ASC_rainSensor } - > { triggerhyst } ;
2018-10-27 13:36:11 +02:00
}
sub getRainSensorShuttersClosedPos {
my $ self = shift ;
my $ name = $ self - > { name } ;
2019-04-09 12:13:46 +02:00
return $ self - > { ASC_rainSensor } - > { shuttersClosedPos }
if ( exists ( $ self - > { ASC_rainSensor } - > { LASTGETTIME } )
and ( gettimeofday ( ) - $ self - > { ASC_rainSensor } - > { LASTGETTIME } ) < 2 ) ;
2019-03-06 15:53:48 +01:00
$ ascDev - > _getRainSensor ;
2019-03-12 23:02:02 +01:00
return $ self - > { ASC_rainSensor } - > { shuttersClosedPos } ;
2018-10-27 13:36:11 +02:00
}
2019-02-26 12:04:10 +01:00
2019-03-04 08:40:58 +01:00
sub _getWindSensor {
2019-04-09 12:13:46 +02:00
my $ self = shift ;
my $ name = $ self - > { name } ;
2019-03-07 10:52:23 +01:00
2019-04-09 12:13:46 +02:00
return $ self - > { ASC_windSensor } - > { device }
if ( exists ( $ self - > { ASC_windSensor } - > { LASTGETTIME } )
and ( gettimeofday ( ) - $ self - > { ASC_windSensor } - > { LASTGETTIME } ) < 2 ) ;
$ self - > { ASC_windSensor } - > { LASTGETTIME } = int ( gettimeofday ( ) ) ;
my ( $ device , $ reading ) =
FHEM::AutoShuttersControl:: GetAttrValues ( $ name , 'ASC_windSensor' ,
'none' ) ;
return $ device if ( $ device eq 'none' ) ;
2019-03-12 23:02:02 +01:00
$ self - > { ASC_windSensor } - > { device } = $ device ;
2019-04-09 12:13:46 +02:00
$ self - > { ASC_windSensor } - > { reading } =
( $ reading ne 'none' ? $ reading : 'wind' ) ;
2019-03-04 08:40:58 +01:00
2019-03-06 15:53:48 +01:00
return $ self - > { ASC_windSensor } - > { device } ;
2019-03-04 08:40:58 +01:00
}
sub getWindSensorReading {
2019-04-09 12:13:46 +02:00
my $ self = shift ;
my $ name = $ self - > { name } ;
2019-03-04 08:40:58 +01:00
2019-04-09 12:13:46 +02:00
return $ self - > { ASC_windSensor } - > { reading }
if ( exists ( $ self - > { ASC_windSensor } - > { LASTGETTIME } )
and ( gettimeofday ( ) - $ self - > { ASC_windSensor } - > { LASTGETTIME } ) < 2 ) ;
2019-03-06 15:53:48 +01:00
$ ascDev - > _getWindSensor ;
2019-04-09 12:13:46 +02:00
return (
defined ( $ self - > { ASC_windSensor } - > { reading } )
? $ self - > { ASC_windSensor } - > { reading }
2019-04-20 18:18:50 +02:00
: 'wind'
) ;
2019-03-04 08:40:58 +01:00
}
2019-03-27 11:22:06 +01:00
sub getblockAscDrivesAfterManual {
2019-04-09 12:13:46 +02:00
my $ self = shift ;
my $ name = $ self - > { name } ;
2019-03-27 11:22:06 +01:00
return AttrVal ( $ name , 'ASC_blockAscDrivesAfterManual' , 0 ) ;
}
2018-08-15 10:27:53 +02:00
1 ;
= pod
= item device
2019-03-27 08:41:15 +01:00
= item summary Module for controlling shutters depending on various conditions
2019-06-10 15:16:38 +02:00
= item summary_DE Modul zur automatischen Rolladensteuerung auf Basis bestimmter Ereignisse
2018-08-15 10:27:53 +02:00
= begin html
< a name = "AutoShuttersControl" > </a>
2019-05-09 18:45:30 +02:00
<h3> AutoShuttersControl </h3>
2019-06-03 11:54:27 +02:00
<ul>
<p>
AutoShuttersControl ( <abbr> ASC </abbr> ) provides a complete automation for shutters with comprehensive
configuration options , <abbr> e . g . </abbr> open or close shutters depending on the sunrise or sunset ,
by outdoor brightness or randomly for simulate presence .
</p>
<p>
After telling <abbr> ASC </abbr> which shutters should be controlled , several in - depth configuration options
are provided . With these and in combination with a resident presence state , complex scenarios are possible:
For example , shutters could be opened if a resident awakes from sleep and the sun is already rosen . Or if a
closed window with shutters down is tilted , the shutters could be half opened for ventilation .
Many more is possible .
</p>
< a name = "AutoShuttersControlDefine" > </a>
<strong> Define </strong>
<ul>
2019-06-06 08:03:29 +02:00
<p>
<code> define & lt ; name & gt ; AutoShuttersControl </code>
</p>
2019-06-03 11:54:27 +02:00
Usage:
2019-06-06 08:03:29 +02:00
<p>
<ul>
<code> define myASControl AutoShuttersControl </code> <br/>
</ul>
</p>
<p>
This creates an new AutoShuttersControl device , called <em> myASControl </em> . <br/>
Now was the new global attribute <var> ASC </var> added to the <abbr> FHEM </abbr> 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 ) .
</p>
<p>
After setting the attributes to all devices who should be controlled , the automatic scan at the main device
can be started for example with <br/>
<code> set myASControl scanForShutters </code>
</p>
2019-06-03 11:54:27 +02:00
</ul>
<br/>
< a name = "AutoShuttersControlReadings" > </a>
<strong> Readings </strong>
<ul>
2019-06-06 08:03:29 +02:00
<p> Within the ASC device: </p>
2019-06-03 11:54:27 +02:00
<ul>
<li> <strong> ... _nextAstroTimeEvent </strong> - Next astro event: sunrise , sunset or fixed time </li>
<li> <strong> ... _PosValue </strong> - current position </li>
<li> <strong> ... _lastPosValue </strong> - shutters last position </li>
<li> <strong> ... _lastDelayPosValue </strong> - last specified order , will be executed with the next matching
event
</li>
2019-06-06 08:03:29 +02:00
<li> <strong> partyMode on | off </strong> - is working mode set to part ? y </li>
<li> <strong> ascEnable on | off </strong> - are the associated shutters control by ASC completely ? </li>
<li> <strong> controlShading on | off </strong> - are the associated shutters controlled for shading by ASC ?
2019-06-03 11:54:27 +02:00
</li>
2019-06-06 08:03:29 +02:00
<li> <strong> hardLockOut on | off </strong> - switch for preventing a global hard lock out </li>
2019-06-03 11:54:27 +02:00
<li> <strong> room_ ... </strong> - list of every found shutter for every room: room_Sleeping: Patio </li>
<li> <strong> selfDefense </strong> - state of the self defense mode </li>
<li> <strong> state </strong> - state of the ASC device: active , enabled , disabled or other state information
</li>
2019-06-06 08:03:29 +02:00
<li> <strong> sunriseTimeWeHoliday on | off </strong> - state of the weekend and holiday support </li>
2019-06-03 11:54:27 +02:00
<li> <strong> userAttrList </strong> - ASC sets some user defined attributes ( <abbr> <em> userattr </em> </abbr> )
for the shutter devices . This readings shows the current state of the given user attributes to the
shutter devices .
</li>
</ul>
2019-06-06 08:03:29 +02:00
<p> Within the shutter devices: </p>
2019-06-03 11:54:27 +02:00
<ul>
2019-06-06 08:03:29 +02:00
<li> <strong> ASC_Enable on | off </strong> - shutter is controlled by ASC or not </li>
2019-06-03 11:54:27 +02:00
<li> <strong> ASC_Time_DriveUp </strong> - if the astro mode is used , the next sunrise is shown .
If the brightness or time mode is used , the value from <em> ASC_Time_Up_Late </em> is shown .
</li>
<li> <strong> ASC_Time_DriveDown </strong> - if the astro mode is used , the next sunset is shown .
If the brightness or time mode is used , the value from <em> ASC_TASC_Time_Down_Lateime_Up_Late </em> is
shown .
</li>
<li> <strong> ASC_ShuttersLastDrive </strong> - initiator for the last action </li>
</ul>
</ul>
<br/> <br/>
< a name = "AutoShuttersControlSet" > </a>
<strong> Set </strong>
<ul>
2019-06-06 08:03:29 +02:00
<li> <strong> ascEnable on | off </strong> - enable or disable the global control by ASC </li>
<li> <strong> controlShading on | off </strong> - enable or disable the global shading control by ASC </li>
2019-06-03 11:54:27 +02:00
<li> <strong> createNewNotifyDev </strong> - re - creates the internal structure for NOTIFYDEV . Is only present if
the
<em> ASC_Expert </em> attribute is set to 1 .
</li>
2019-06-06 08:03:29 +02:00
<li> <strong> hardLockOut on | off </strong> - controls the global hard lock out protection for shutters , whose
2019-06-03 11:54:27 +02:00
<em> ASC_LockOut </em>
attribute is set accordingly . See the attributes section below .
</li>
2019-06-06 08:03:29 +02:00
<li> <strong> partyMode on | off </strong> - controls the global party mode for shutters . Every shutters whose
2019-06-03 11:54:27 +02:00
<em> ASC_Partymode </em> attribute is set to <em> on </em> , 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 .
</li>
<li> <strong> renewSetSunriseSunsetTimer </strong> - resets the sunrise and sunset timers for every associated
shutter device and creates new internal FHEM timers .
</li>
<li> <strong> scanForShutters </strong> - scans the whole FHEM installation for ( new ) devices whose <em> ASC </em>
attribute is set ( to 1 or 2 , see above ) .
</li>
2019-06-06 08:03:29 +02:00
<li> <strong> selfDefense on | off </strong> - controls the self defense function . This function listens for
2019-06-03 11:54:27 +02:00
example on a residents device . If this device is set to <em> absent </em> and a window is still open , ASC will close
the shutter for a rudimentary burglary protection .
</li>
2019-06-06 08:03:29 +02:00
<li> <strong> shutterASCenableToggle on | off </strong> - controls if the ASC controls are shown at a associated
2019-06-03 11:54:27 +02:00
shutter device .
</li>
2019-06-06 08:03:29 +02:00
<li> <strong> sunriseTimeWeHoliday on | off </strong> - controls the weekend and holiday support . If enabled , the
2019-06-03 11:54:27 +02:00
<em> ASC_Time_Up_WE_Holiday </em> attribute is considered .
</li>
<li> <strong> wiggle </strong> - wiggles a device for a given value ( default 5 % , controlled by
<em> ASC_WiggleValue </em> ) up or down and back after a minute . Useful as a deterrence in combination with
alarm system .
</li>
</ul>
<br/> <br/>
< a name = "AutoShuttersControlGet" > </a>
<strong> Get </strong>
<ul>
<li> <strong> showShuttersInformations </strong> - shows an information for all associated shutter devices with
next activation time , mode and several other state informations .
</li>
<li> <strong> showNotifyDevsInformations </strong> - shows the generated <em> NOTIFYDEV </em> structure . Useful for
debugging and only shown if the <em> ASC_expert </em> attribute is set to 1 .
</li>
</ul>
<br/> <br/>
< a name = "AutoShuttersControlAttributes" > </a>
<strong> Attributes </strong>
<ul>
2019-06-06 08:03:29 +02:00
<p> At the global <abbr> ASC </abbr> device: </p>
2019-06-03 11:54:27 +02:00
<ul>
< a name = "ASC_autoAstroModeEvening" > </a>
<li> <strong> ASC_autoAstroModeEvening </strong> - REAL , CIVIL , NAUTIC , ASTRONOMIC or HORIZON </li>
< a name = "ASC_autoAstroModeEveningHorizon" > </a>
<li> <strong> ASC_autoAstroModeEveningHorizon </strong> - Height above the horizon . Is only considered
if the <em> ASC_autoAstroModeEvening </em> attribute is set to <em> HORIZON </em> . Defaults to <em> 0 </em> .
</li>
< a name = "ASC_autoAstroModeMorning" > </a>
<li> <strong> ASC_autoAstroModeMorning </strong> - REAL , CIVIL , NAUTIC , ASTRONOMIC or HORIZON </li>
< a name = "ASC_autoAstroModeMorningHorizon" > </a>
<li> <strong> ASC_autoAstroModeMorningHorizon </strong> - Height above the horizon . Is only considered
if the <em> ASC_autoAstroModeMorning </em> attribute is set to <em> HORIZON </em> . Defaults to <em> 0 </em> .
</li>
< a name = "ASC_autoShuttersControlComfort" > </a>
2019-06-10 15:31:39 +02:00
<li> <strong> ASC_autoShuttersControlComfort - on | off </strong> -
2019-06-03 11:54:27 +02:00
Controls the comfort functions: If a three state sensor , like the <abbr> HmIP - SRH </abbr> window handle
sensor , is installed , <abbr> ASC </abbr> will open the window if the sensor signals open position . The
<em> ASC_ComfortOpen_Pos </em> attribute has to be set for the shutter to <em> on </em> , defaults to <em> off </em> .
</li>
< a name = "ASC_autoShuttersControlEvening" > </a>
2019-06-10 15:31:39 +02:00
<li> <strong> ASC_autoShuttersControlEvening - on | off </strong> - Enables the automatic control by <abbr> ASC </abbr>
2019-06-03 11:54:27 +02:00
at the evenings .
</li>
< a name = "ASC_autoShuttersControlMorning" > </a>
2019-06-10 15:31:39 +02:00
<li> <strong> ASC_autoShuttersControlMorning - on | off </strong> - Enables the automatic control by <abbr> ASC </abbr>
2019-06-03 11:54:27 +02:00
at the mornings .
</li>
< a name = "ASC_blockAscDrivesAfterManual" > </a>
2019-06-10 15:31:39 +02:00
<li> <strong> ASC_blockAscDrivesAfterManual 0 | 1 </strong> - If set to <em> 1 </em> , <abbr> ASC </abbr> will not
2019-06-03 11:54:27 +02:00
automatically control a shutter if there was an manual control to the shutter . To be considered , the
<em> ASC_ShuttersLastDrive </em> reading has to contain the value <em> manual </em> and the shutter is in
an unknown ( i . e . not otherwise configured in <abbr> ASC </abbr> ) position .
</li>
< a name = "ASC_brightnessDriveUpDown" > </a>
<li> <strong> ASC_brightnessDriveUpDown - VALUE - MORNING:VALUE - EVENING </strong> - Drive the shutters by
brightness . <em> VALUE - MORNING </em> sets the brightness threshold for the morning . If the value is
reached in the morning , the shutter will go up . Vice versa in the evening . This is a global setting
and can be overwritte per device with the <em> ASC_BrightnessSensor </em> attribute ( see below ) .
</li>
< a name = "ASC_debug" > </a>
<li> <strong> ASC_debug </strong> -
Extendend logging for debugging purposes
</li>
< a name = "ASC_expert" > </a>
<li> <strong> ASC_expert </strong> - Switches the export mode on . Currently , if set to <em> 1 </em> , <em> get </em>
and <em> set </em> will contain additional functions regarding the NOTIFYDEFs .
</li>
< a name = "ASC_freezeTemp" > </a>
<li> <strong> ASC_freezeTemp </strong> - Temperature threshold for the freeze protection . The freeze protection
prevents the shutter to be operated by <abbr> ASC </abbr> . Last operating order will be kept .
</li>
< a name = "ASC_rainSensor" > </a>
2019-06-06 08:03:29 +02:00
<li> <strong> ASC_rainSensor DEVICENAME [ : READINGNAME ] MAXTRIGGER [ : HYSTERESE ] [ CLOSEDPOS ] </strong> - Contains
2019-06-03 11:54:27 +02:00
settings for the rain protection . <em> DEVICNAME </em> specifies a rain sensor , the optional
<em> READINGNAME </em> the name of the reading at the <em> DEVICENAME </em> . The <em> READINGNAME </em>
should contain the values <em> rain </em> and <em> dry </em> or a numeral rain amount . <em> MAXTRIGGER </em>
sets the threshold for the amount of rain for when the shutter is driven to <em> CLOSEDPOS </em> as soon
the threshold is reached . <em> HYSTERESE </em> sets a hysteresis for <em> MAXTRIGGER </em> .
</li>
< a name = "ASC_residentsDev" > </a>
2019-06-06 08:03:29 +02:00
<li> <strong> ASC_residentsDev DEVICENAME [ : READINGNAME ] </strong> - <em> DEVICENAME </em> points to a device
2019-06-03 11:54:27 +02:00
for presence , e . g . of type <em> RESIDENTS </em> . <em> READINGNAME </em> points to a reading at
<em> DEVICENAME </em> which contains a presence state , e . g . <em> rgr_Residents:presence </em> . The target
should contain values alike the <em> RESIDENTS </em> family .
</li>
< a name = "ASC_shuttersDriveOffset" > </a>
<li> <strong> ASC_shuttersDriveOffset </strong> - Maximum random drive delay in seconds for calculating
the operating time . <em> 0 </em> equals to no delay .
</li>
< a name = "ASC_tempSensor" > </a>
2019-06-06 08:03:29 +02:00
<li> <strong> ASC_tempSensor DEVICENAME [ : READINGNAME ] </strong> - <em> DEVICENAME </em> points to a device
2019-06-03 11:54:27 +02:00
with a temperature , <em> READINGNAME </em> to a reading located at the <em> DEVICENAME </em> , for example
<em> OUTDOOR_TEMP:measured - temp </em> . <em> READINGNAME </em> defaults to <em> temperature </em> .
</li>
< a name = "ASC_twilightDevice" > </a>
<li> <strong> ASC_twilightDevice </strong> - points to a <em> DEVICENAME </em> containing values regarding
the sun position . Supports currently devices of type <em> Twilight </em> or <em> Astro </em> .
</li>
< a name = "ASC_windSensor" > </a>
2019-06-06 08:03:29 +02:00
<li> <strong> ASC_windSensor DEVICENAME [ : READINGNAME ] </strong> - <em> DEVICENAME </em> points to a device
2019-06-03 11:54:27 +02:00
containing a wind speed . Reads from the <em> wind </em> reading , if not otherwise specified by
<em> READINGNAME </em> .
</li>
</ul>
<br/>
<ul>
<u> <strong> The following attributes are deprecated and should not used in the future: </strong> </u>
< br /><br / >
< a name = "ASC_temperatureSensor" > </a>
<li> <del> ASC_temperatureSensor </del> - <em> Warning ! Deprecated ! Don ' t use anymore ! </em> </li>
< a name = "ASC_temperatureReading" > </a>
<li> <del> ASC_temperatureReading </del> - <em> Warning ! Deprecated ! Don ' t use anymore ! </em> </li>
< a name = "ASC_residentsDevice" > </a>
<li> <del> ASC_residentsDevice </del> - <em> Warning ! Deprecated ! Don ' t use anymore ! </em> </li>
< a name = "ASC_residentsDeviceReading" > </a>
<li> <del> ASC_residentsDeviceReading </del> - <em> Warning ! Deprecated ! Don ' t use anymore ! </em> </li>
< a name = "ASC_rainSensorDevice" > </a>
<li> <del> ASC_rainSensorDevice </del> - <em> Warning ! Deprecated ! Don ' t use anymore ! </em> </li>
< a name = "ASC_rainSensorReading" > </a>
<li> <del> ASC_rainSensorReading </del> - <em> Warning ! Deprecated ! Don ' t use anymore ! </em> </li>
< a name = "ASC_rainSensorShuttersClosedPos" > </a>
<li> <del> ASC_rainSensorShuttersClosedPos </del> - <em> Warning ! Deprecated ! Don ' t use anymore ! </em> </li>
< a name = "ASC_brightnessMinVal" > </a>
<li> <del> ASC_brightnessMinVal </del> - <em> Warning ! Deprecated ! Don ' t use anymore ! </em> </li>
< a name = "ASC_brightnessMaxVal" > </a>
<li> <del> ASC_brightnessMaxVal </del> - <em> Warning ! Deprecated ! Don ' t use anymore ! </em> </li>
</ul>
2019-06-06 08:03:29 +02:00
<p> At shutter devices , controlled by <abbr> ASC </abbr> : </p>
2019-06-03 11:54:27 +02:00
<ul>
2019-06-10 15:31:39 +02:00
<li> <strong> ASC - 0 | 1 | 2 </strong>
2019-06-03 11:54:27 +02:00
<ul>
<li> 0 - don 't create attributes for <abbr>ASC</abbr> at the first scan and don' t be controlled
by <abbr> ASC </abbr> </li>
<li> 1 - inverse or venetian type blind mode . Shutter is open equals to 0 , shutter is closed equals
to 100 , is controlled by <em> position </em> values . </li>
<li> 2 - <q> HomeMatic </q> mode . Shutter is open equals to 100 , shutter is closed equals to 0 , is
controlled by <em> <abbr> pct </abbr> </em> values . </li>
</ul>
</li>
2019-06-10 15:31:39 +02:00
<li> <strong> ASC_Antifreeze - soft | am | pm | hard | off </strong> - Freeze protection .
2019-06-03 11:54:27 +02:00
<ul>
<li> soft - see <em> ASC_Antifreeze_Pos </em> . </li>
<li> hard / <abbr>am</ abbr > / <abbr>pm</ abbr > - freeze protection will be active ( everytime ,
ante meridiem or post meridiem ) . </li>
<li> off - freeze protection is disabled , default value </li>
</ul>
</li>
<li> <strong> ASC_Antifreeze_Pos </strong> - Position to be operated if the shutter should be closed ,
but <em> ASC_Antifreeze </em> is not set to <em> off </em> . Defaults to 50 .
</li>
<li> <strong> ASC_AutoAstroModeEvening </strong> - Can be set to <em> REAL </em> , <em> CIVIL </em> ,
<em> NAUTIC </em> , <em> ASTRONOMIC </em> or <em> HORIZON </em> . Defaults to none of those . </li>
<li> <strong> ASC_AutoAstroModeEveningHorizon </strong> - If this value is reached by the sun , a sunset is
presumed . Is used if <em> ASC_autoAstroModeEvening </em> is set to <em> HORIZON </em> . Defaults to none .
</li>
<li> <strong> ASC_AutoAstroModeMorning </strong> - Can be set to <em> REAL </em> , <em> CIVIL </em> ,
<em> NAUTIC </em> , <em> ASTRONOMIC </em> or <em> HORIZON </em> . Defaults to none of those . </li>
<li> <strong> ASC_AutoAstroModeMorningHorizon </strong> - If this value is reached by the sun , a sunrise is
presumed . Is used if <em> ASC_AutoAstroModeMorning </em> is set to <em> HORIZON </em> . Defaults to none .
</li>
<li> <strong> ASC_BlockingTime_afterManual </strong> - Time in which operations by <abbr> ASC </abbr> are blocked
after the last manual operation in seconds . Defaults to 1200 ( 20 minutes ) .
</li>
<li> <strong> ASC_BlockingTime_beforDayOpen </strong> - Time in which no closing operation is made by
<abbr> ASC </abbr> after opening at the morning in seconds . Defaults to 3600 ( one hour ) .
</li>
<li> <strong> ASC_BlockingTime_beforNightClose </strong> - Time in which no closing operation is made by
<abbr> ASC </abbr> before closing at the evening in seconds . Defaults to 3600 ( one hour ) .
</li>
<li> <strong> ASC_BrightnessSensor - DEVICE [ : READING ] MORNING - VALUE:EVENING - VALUE </strong> -
Drive this shutter by brightness . <em> MORNING - VALUE </em> sets the brightness threshold for the morning .
If the value is reached in the morning , the shutter will go up . Vice versa in the evening , specified by
<em> EVENING - VALUE </em> . Gets the brightness from <em> DEVICE </em> , reads by default from the
<em> brightness </em> reading , unless <em> READING </em> is specified . Defaults to <em> none </em> .
</li>
2019-06-06 08:03:29 +02:00
<li> <strong> ASC_Closed_Pos </strong> - The closed position value from 0 to 100 percent in increments of 10 .
Depends on the <em> ASC </em> attribute .
2019-06-03 11:54:27 +02:00
</li>
2019-06-06 08:03:29 +02:00
<li> <strong> ASC_ComfortOpen_Pos </strong> - The comfort opening position , ranging
from 0 to 100 percent in increments of 10 . Default: depends on the <em> ASC </em> attribute .
2019-06-03 11:54:27 +02:00
</li>
2019-06-06 08:03:29 +02:00
<li> <strong> ASC_Down - astro | time | brightness </strong> - Drive the shutter depending on this setting:
2019-06-03 11:54:27 +02:00
<ul>
<li> astro - drive down at sunset </li>
<li> time - drive at <em> ASC_Time_Down_Early </em> </li>
<li> brightness - drive between <em> ASC_Time_Down_Early </em> and <em> ASC_Time_Down_Late </em> ,
depending on the settings of <em> ASC_BrightnessSensor </em> ( see above ) . </li>
</ul>
Defaults to <em> astro </em> .
</li>
<li> <strong> ASC_DriveUpMaxDuration </strong> - Drive up duration of the shutter plus 5 seconds . Defaults
to 60 seconds if not set .
</li>
<li> <strong> ASC_Drive_Offset </strong> - Maximum <strong> random </strong> drive delay in seconds for calculating the
driving time . 0 equals to no delay , - 1 <em> ASC_shuttersDriveOffset </em> is used . Defaults to - 1 .
</li>
<li> <strong> ASC_Drive_OffsetStart </strong> - <strong> Fixed </strong> drive delay in seconds for calculating the
driving time . - 1 or 0 equals to no delay . Defaults to - 1 ( no offset ) .
</li>
2019-06-06 08:03:29 +02:00
<li> <strong> ASC_LockOut soft | hard | off </strong> - Configures the lock out protection for the current
2019-06-03 11:54:27 +02:00
shutter . Values are:
<ul>
<li> soft - works if the global lock out protection <em> lockOut soft </em> is set and a sensor
specified by <em> ASC_WindowRec </em> is set . If the sensor is set to open , the shutter will not
be closed . Affects only commands issued by <abbr> ASC </abbr> .
</li>
<li>
hard - see soft , but <abbr> ASC </abbr> tries also to block manual issued commands by a switch .
</li>
<li>
off - lock out protection is disabled . Default .
</li>
</ul>
</li>
2019-06-06 08:03:29 +02:00
<li> <strong> ASC_LockOut_Cmd inhibit | blocked | protection </strong> - Configures the lock out command for
<em> ASC_LockOut </em> if hard is chosen as a value . Defaults to none .
2019-06-03 11:54:27 +02:00
</li>
2019-06-06 08:03:29 +02:00
<li> <strong> ASC_Mode_Down always | home | absent | off </strong> - When will a shutter be driven down:
<ul>
<li> always - <abbr> ASC </abbr> will drive always . Default value . </li>
<li> off - don ' t drive </li>
<li> home / absent - considers a residents status set by <em>ASC_residentsDev</ em > . If no
resident is configured and this attribute is set to absent , <abbr> ASC </abbr> will not
operate the shutter . </li>
</ul>
2019-06-03 11:54:27 +02:00
</li>
2019-06-06 08:03:29 +02:00
<li> <strong> ASC_Mode_Up always | home | absent | off </strong> - When will a shutter be driven up:
<ul>
<li> always - <abbr> ASC </abbr> will drive always . Default value . </li>
<li> off - don ' t drive </li>
<li> home / absent - considers a residents status set by <em>ASC_residentsDev</ em > . If no
resident is configured and this attribute is set to absent , <abbr> ASC </abbr> will not
operate the shutter . </li>
</ul>
2019-06-03 11:54:27 +02:00
</li>
2019-06-06 08:03:29 +02:00
<li> <strong> ASC_Open_Pos </strong> - The opening position value from 0 to 100 percent in increments of 10 .
Depends on the <em> ASC </em> attribute .
2019-06-03 11:54:27 +02:00
</li>
2019-06-06 08:03:29 +02:00
<li> <strong> ASC_Partymode on | off </strong> - Party mode . If configured to on , driving orders for the
shutter by <abbr> ASC </abbr> will be queued if <em> partyMode </em> is set to <em> on </em> at the
global <abbr> ASC </abbr> device . Will execute the driving orders after <em> partyMode </em> is disabled .
Defaults to off .
2019-06-03 11:54:27 +02:00
</li>
2019-06-06 08:03:29 +02:00
<li> <strong> ASC_Pos_Reading </strong> - Points to the reading name , which contains the current
position for the shutter in percent . Will be used for <em> set </em> at devices of unknown kind .
2019-06-03 11:54:27 +02:00
</li>
2019-06-06 08:03:29 +02:00
<li> <strong> ASC_PrivacyDownTime_beforNightClose </strong> - How many seconds is the privacy mode activated
before the shutter is closed in the evening . A value of <em> - 1 </em> disables this . - 1 is the default
value .
2019-06-03 11:54:27 +02:00
</li>
2019-06-06 08:03:29 +02:00
<li> <strong> ASC_PrivacyDown_Pos </strong> -
Position in percent for privacy mode , defaults to 50 .
2019-06-03 11:54:27 +02:00
</li>
2019-06-06 08:03:29 +02:00
<li> <strong> ASC_WindProtection on | off </strong> - Shutter is protected by the wind protection . Defaults
to off .
2019-06-03 11:54:27 +02:00
</li>
2019-06-06 08:03:29 +02:00
<li> <strong> ASC_Roommate_Device </strong> - Comma separated list of <em> ROOMMATE </em> devices , representing
the inhabitants of the room to which the shutter belongs . Especially useful for bedrooms . Defaults
to none .
2019-06-03 11:54:27 +02:00
</li>
2019-06-06 08:03:29 +02:00
<li> <strong> ASC_Roommate_Reading </strong> - Specifies a reading name to <em> ASC_Roommate_Device </em> .
Defaults to <em> state </em> .
2019-06-03 11:54:27 +02:00
</li>
2019-06-06 08:03:29 +02:00
<li> <strong> ASC_Self_Defense_Exclude on | off </strong> - If set to on , the shutter will not be closed
if the self defense mode is activated and residents are absent . Defaults to off .
2019-06-03 11:54:27 +02:00
</li>
2019-06-06 08:03:29 +02:00
<li> <strong> ASC_ShuttersPlace window | terrace </strong> - If set to <em> terrace </em> , and the
residents device is set to <em> gone </em> , and <em> selfDefense </em> is activated , the shutter will
be closed . If set to window , will not . Defaults to window .
2019-06-03 11:54:27 +02:00
</li>
2019-06-06 08:03:29 +02:00
<li> <strong> ASC_Time_Down_Early </strong> - Will not drive before time is <em> ASC_Time_Down_Early </em>
or later , even the sunset occurs earlier . To be set in military time . Defaults to 16 : 00 .
2019-06-03 11:54:27 +02:00
</li>
2019-06-06 08:03:29 +02:00
<li> <strong> ASC_Time_Down_Late </strong> - Will not drive after time is <em> ASC_Time_Down_Late </em>
or earlier , even the sunset occurs later . To be set in military time . Defaults to 22 : 00 .
2019-06-03 11:54:27 +02:00
</li>
2019-06-06 08:03:29 +02:00
<li> <strong> ASC_Time_Up_Early </strong> - Will not drive before time is <em> ASC_Time_Up_Early </em>
or earlier , even the sunrise occurs earlier . To be set in military time . Defaults to 05 : 00 .
2019-06-03 11:54:27 +02:00
</li>
2019-06-06 08:03:29 +02:00
<li> <strong> ASC_Time_Up_Late </strong> - Will not drive after time is <em> ASC_Time_Up_Late </em>
or earlier , even the sunrise occurs later . To be set in military time . Defaults to 08 : 30 .
2019-06-03 11:54:27 +02:00
</li>
2019-06-06 08:03:29 +02:00
<li> <strong> ASC_Time_Up_WE_Holiday </strong> - Will not drive before time is <em> ASC_Time_Up_WE_Holiday </em>
on weekends and holidays ( <em> holiday2we </em> is considered ) . Defaults to 08 : 00 . <strong> Warning ! </strong>
If <em> ASC_Up </em> set to <em> brightness </em> , the time for <em> ASC_Time_Up_WE_Holiday </em>
must be earlier then <em> ASC_Time_Up_Late </em> .
2019-06-03 11:54:27 +02:00
</li>
2019-06-06 08:03:29 +02:00
<li> <strong> ASC_Up astro | time | brightness </strong> - Drive the shutter depending on this setting:
<ul>
<li> astro - drive up at sunrise </li>
<li> time - drive at <em> ASC_Time_Up_Early </em> </li>
<li> brightness - drive between <em> ASC_Time_Up_Early </em> and <em> ASC_Time_Up_Late </em> ,
depending on the settings of <em> ASC_BrightnessSensor </em> ( see above ) . </li>
</ul>
Defaults to <em> astro </em> .
2019-06-03 11:54:27 +02:00
</li>
2019-06-06 08:03:29 +02:00
<li> <strong> ASC_Ventilate_Pos </strong> - The opening position value for ventilation
from 0 to 100 percent in increments of 10 . Default depending on the <em> ASC </em> attribute .
2019-06-03 11:54:27 +02:00
</li>
2019-06-06 08:03:29 +02:00
<li> <strong> ASC_Ventilate_Window_Open on | off </strong> - Drive to ventilation position as window is opened
or tilted , even when the current shutter position is lower than the <em> ASC_Ventilate_Pos </em> .
Defaults to on .
2019-06-03 11:54:27 +02:00
</li>
2019-06-06 08:03:29 +02:00
<li> <strong> ASC_WiggleValue </strong> - How many percent should the shutter be driven if a wiggle drive
is operated . Defaults to 5 .
2019-06-03 11:54:27 +02:00
</li>
2019-06-06 08:03:29 +02:00
<li> <strong> ASC_WindParameters THRESHOLD - ON [ : THRESHOLD - OFF ] [ DRIVEPOSITION ] </strong> -
Threshold for when the shutter is driven to the wind protection position . Optional
<em> THRESHOLD - OFF </em> sets the complementary value when the wind protection is disabled . Disabled
if <em> THRESHOLD - ON </em> is set to - 1 . Defaults to <q> 50 : 20 <em> ASC_Closed_Pos </em> </q> .
2019-06-03 11:54:27 +02:00
</li>
2019-06-06 08:03:29 +02:00
<li> <strong> ASC_WindowRec </strong> - Points to the window contact device , associated with the shutter .
Defaults to none .
2019-06-03 11:54:27 +02:00
</li>
2019-06-06 08:03:29 +02:00
<li> <strong> ASC_WindowRec_subType </strong> - Model type of the used <em> ASC_WindowRec </em> :
<ul>
<li> <strong> twostate </strong> - optical or magnetical sensors with two states: opened or closed </li> #
<li> <strong> threestate </strong> - sensors with three states: opened , tilted , closed </li>
</ul>
Defaults to twostate .
</li>
<blockquote>
<p>
<strong> <u> Shading </u> </strong>
</p>
<p>
Shading is only available if the following prerequests are met:
<ul>
<li>
The <em> ASC_autoShuttersControlShading </em> attribute is set to on , and there is a device
of type Astro or Twilight configured to <em> ASC_twilightDevice </em> , and <em> ASC_tempSensor </em>
is set .
</li>
<li>
<em> ASC_BrightnessSensor </em> is configured to any shutter device .
</li>
<li>
All other attributes are optional and the default value for them is used , if they are not
otherwise configured . Please review the settings carefully , especially the values for
<em> StateChange_Cloudy </em> and <em> StateChange_Sunny </em> .
</li>
</ul>
</p>
<p>
The following attributes are available:
</p>
<ul>
<li> <strong> ASC_Shading_Angle_Left </strong> - Minimal shading angle in relation to the window ,
from when shade is applied . For example: Window is 180 & deg ; ( perpendicular ) & minus ; 85 & deg ; set
for <em> ASC_Shading_Angle_Left </em> & rarr ; shading starts if sun position is 95 & deg ; .
Defaults to 75 .
</li>
<li> <strong> ASC_Shading_Angle_Right </strong> - Complements <em> ASC_Shading_Angle_Left </em> and
sets the maximum shading angle in relation to the window . For example: Window is 180 & deg ;
( perpendicular ) & plus ; 85 & deg ; set from <em> ASC_Shading_Angle_Right </em> & rarr ; shading until
sun position of 265 & deg ; is reached . Defaults to 75 .
</li>
<li> <strong> ASC_Shading_Direction </strong> - Compass point degrees for which the window resp . shutter
points . East is 90 & deg ; , South 180 & deg ; , West is 270 & deg ; and North is 0 & deg ; .
Defaults to South ( 180 ) .
</li>
2019-06-10 13:41:46 +02:00
<li> <strong> ASC_Shading_MinMax_Elevation </strong> - Shading starts as min point of sun elevation is
reached and end as max point of sun elevation is reached , depending also on other sensor values . Defaults to 25.0 : 100.0 .
2019-06-06 08:03:29 +02:00
</li>
<li> <strong> ASC_Shading_Min_OutsideTemperature </strong> - Shading starts at this outdoor temperature ,
depending also on other sensor values . Defaults to 18.0 .
</li>
<li> <strong> ASC_Shading_Mode absent | always | off | home </strong> - see <em> ASC_Mode_Down </em> above ,
but for shading . Defaults to off .
</li>
<li> <strong> ASC_Shading_Pos </strong> - Shading position in percent . </li>
<li> <strong> ASC_Shading_StateChange_Cloudy </strong> - Shading <strong> ends </strong> at this
outdoor brightness , depending also on other sensor values . Defaults to 20000 .
</li>
<li> <strong> ASC_Shading_StateChange_Sunny </strong> - Shading <strong> starts </strong> at this
outdoor brightness , depending also on other sensor values . Defaults to 35000 .
</li>
<li> <strong> ASC_Shading_WaitingPeriod </strong> - Waiting time in seconds before additional sensor values
to <em> ASC_Shading_StateChange_Sunny </em> or <em> ASC_Shading_StateChange_Cloudy </em>
are used for shading . Defaults to 120 .
</li>
</ul>
</blockquote>
2019-06-03 11:54:27 +02:00
</ul>
</ul>
<p>
<strong> <u> AutoShuttersControl <abbr> API </abbr> description </u> </strong>
</p>
<p>
2019-06-06 08:03:29 +02:00
It ' s possible to access internal data of the <abbr> ASC </abbr> module by calling the <abbr> API </abbr> function .
2019-06-03 11:54:27 +02:00
</p>
<u> Data points of a shutter device , controlled by <abbr> ASC </abbr> </u>
<p>
<pre> <code> { ascAPIget ( 'Getter' , 'SHUTTERS_DEVICENAME' ) } </code> </pre>
</p>
< table border = "1" >
<tr>
<th> Getter </th>
<th> Description </th>
</tr>
<tr>
<td> FreezeStatus </td>
<td> 1 = soft , 2 = daytime , 3 = hard </td>
</tr>
<tr>
<td> NoOffset </td>
<td> Was the offset handling deactivated ( e . g . by operations triggered by a window event ) </td>
</tr>
<tr>
<td> LastDrive </td>
<td> Reason for the last action caused by <abbr> ASC </abbr> </td>
</tr>
<tr>
<td> LastPos </td>
<td> Last position of the shutter </td>
</tr>
<tr>
<td> LastPosTimestamp </td>
<td> Timestamp of the last position </td>
</tr>
<tr>
<td> LastManPos </td>
<td> Last position manually set of the shutter </td>
</tr>
<tr>
<td> LastManPosTimestamp </td>
<td> Timestamp of the last position manually set </td>
</tr>
<tr>
<td> SunsetUnixTime </td>
<td> Calculated sunset time in seconds since the <abbr> UNIX </abbr> epoche </td>
</tr>
<tr>
<td> Sunset </td>
<td> 1 = operation in the evening was made , 0 = operation in the evening was not yet made </td>
</tr>
<tr>
<td> SunriseUnixTime </td>
<td> Calculated sunrise time in seconds since the <abbr> UNIX </abbr> epoche </td>
</tr>
<tr>
<td> Sunrise </td>
<td> 1 = operation in the morning was made , 0 = operation in the morning was not yet made </td>
</tr>
<tr>
<td> RoommatesStatus </td>
<td> Current state of the room mate set for this shutter </td>
</tr>
<tr>
<td> RoommatesLastStatus </td>
<td> Last state of the room mate set for this shutter </td>
</tr>
<tr>
<td> ShadingStatus </td>
<td> Value of the current shading state . Can hold <em> in </em> , <em> out </em> , <em> in reserved </em> or
<em> out reserved </em> </td>
</tr>
<tr>
<td> ShadingStatusTimestamp </td>
<td> Timestamp of the last shading state </td>
</tr>
<tr>
<td> IfInShading </td>
<td> Is the shutter currently in shading ( depends on the shading mode ) </td>
</tr>
<tr>
<td> WindProtectionStatus </td>
<td> Current state of the wind protection . Can hold <em> protection </em> or <em> unprotection </em> </td>
</tr>
<tr>
<td> RainProtectionStatus </td>
<td> Current state of the rain protection . Can hold <em> protection </em> or <em> unprotection </em> </td>
</tr>
<tr>
<td> DelayCmd </td>
<td> Last operation order in the waiting queue . Set for example by the party mode </td>
</tr>
<tr>
<td> Status </td>
<td> Position of the shutter </td>
</tr>
<tr>
<td> ASCenable </td>
<td> Does <abbr> ASC </abbr> control the shutter ? </td>
</tr>
2019-06-08 14:52:53 +02:00
<table/>
2019-06-03 11:54:27 +02:00
</p>
<u> Data points of the <abbr> ASC </abbr> device </u>
<p>
<code> { ascAPIget ( 'Getter' ) } </code> <br>
</p>
< table border = "1" >
<tr>
<th> Getter </th>
<th> Description </th>
</tr>
<tr>
<td> outTemp </td>
<td> Current temperature of a configured temperature device </td>
</tr>
<tr>
<td> ResidentsStatus </td>
<td> Current state of a configured resident device </td>
</tr>
<tr>
<td> ResidentsLastStatus </td>
<td> Last state of a configured resident device </td>
</tr>
<tr>
<td> Azimuth </td>
<td> Current azimuth of the sun </td>
</tr>
<tr>
<td> Elevation </td>
<td> Current elevation of the sun </td>
</tr>
<tr>
<td> ASCenable </td>
<td> Is <abbr> ASC </abbr> globally activated ? </td>
</tr>
2019-06-08 14:52:53 +02:00
<table/>
2019-06-03 11:54:27 +02:00
</ul>
2018-08-15 10:27:53 +02:00
= end html
= begin html_DE
2019-05-24 19:56:38 +02:00
< a name = "AutoShuttersControl" > </a>
<h3> AutoShuttersControl </h3>
<ul>
<p> AutoShuttersControl ( ASC ) erm & ouml ; glicht eine vollst & auml ; ndige Automatisierung der vorhandenen Rolll & auml ; den . Das Modul bietet umfangreiche Konfigurationsm & ouml ; glichkeiten , um Rolll & auml ; den bspw . nach Sonnenauf - und untergangszeiten , nach Helligkeitswerten oder rein zeitgesteuert zu steuern . </p>
<p>
Man kann festlegen , welche Rolll & auml ; den von ASC in die Automatisierung mit aufgenommen werden sollen . Daraufhin stehen diverse Attribute zur Feinkonfiguration zur Verf & uuml ; gung . So sind unter anderem komplexe L & ouml ; sungen wie Fahrten in Abh & auml ; ngigkeit des Bewohnerstatus einfach umsetzbar . Beispiel: Hochfahren von Rolll & auml ; den , wenn der Bewohner erwacht ist und drau & szlig ; en bereits die Sonne aufgegangen ist . Weiterhin ist es m & ouml ; glich , dass der geschlossene Rollladen z . B . nach dem Ankippen eines Fensters in eine L & uuml ; ftungsposition f & auml ; hrt . Und vieles mehr .
</p>
< a name = "AutoShuttersControlDefine" > </a>
<strong> Define </strong>
<ul>
<code> define & lt ; name & gt ; AutoShuttersControl </code>
< br /><br / >
Beispiel:
<ul>
< br / >
<code> define myASControl AutoShuttersControl </code> < br / >
</ul>
< br / >
Der Befehl erstellt ein AutoShuttersControl Device mit Namen <em> myASControl </em> . < br / >
Nachdem das Device angelegt wurde , muss in allen Rolll & auml ; den Devices , welche gesteuert werden sollen , das Attribut ASC mit Wert 1 oder 2 gesetzt werden .
Dabei bedeutet 1 = "Prozent geschlossen" ( z . B . ROLLO oder Siro Modul ) - Rollo Oben 0 , Rollo Unten 100 , 2 = "Prozent geöffnet" ( z . B . Homematic ) - Rollo Oben 100 , Rollo Unten 0 .
Die Voreinstellung f & uuml ; r den Befehl zum prozentualen Fahren ist in beiden F & auml ; llen unterschiedlich . 1 = "position" und 2 = "pct" . Dies kann , soweit erforderlich , zu sp & auml ; terer Zeit noch angepasst werden .
Habt Ihr das Attribut gesetzt , k & ouml ; nnt Ihr den automatischen Scan nach den Devices ansto & szlig ; en .
</ul>
< br / >
< a name = "AutoShuttersControlReadings" > </a>
<strong> Readings </strong>
<ul>
<u> Im ASC - Device </u>
<ul>
<li> <strong> ... _nextAstroTimeEvent </strong> - Uhrzeit des n & auml ; chsten Astro - Events: Sonnenauf - oder Sonnenuntergang oder feste Zeit </li>
<li> <strong> ... _PosValue </strong> - aktuelle Position des Rollladens </li>
<li> <strong> ... _lastPosValue </strong> - letzte Position des Rollladens </li>
<li> <strong> ... _lastDelayPosValue </strong> - letzter abgesetzter Fahrbefehl , welcher beim n & auml ; chsten zul & auml ; ssigen Event ausgef & uuml ; hrt wird . </li>
<li> <strong> partyMode - on /off</s trong > - Partymodus - Status </li>
<li> <strong> ascEnable - on /off</s trong > - globale ASC Steuerung bei den Rollläden aktiv oder inaktiv </li>
<li> <strong> controlShading - on /off</s trong > - globale Beschattungsfunktion aktiv oder inaktiv </li>
<li> <strong> hardLockOut - on /off</s trong > - Aussperrschutz - Status </li>
<li> <strong> room_ ... </strong> - Auflistung aller Rolll & auml ; den , die in den jeweiligen R & auml ; men gefunden wurde . Beispiel: room_Schlafzimmer: Terrasse </li>
<li> <strong> selfDefense </strong> - Selbstschutz - Status </li>
<li> <strong> state </strong> - Status des ASC - Devices: active , enabled , disabled oder weitere Statusinformationen </li>
<li> <strong> sunriseTimeWeHoliday - on /off</s trong > - Status der Wochenendunterst & uuml ; tzung </li>
<li> <strong> userAttrList </strong> - Das ASC - Modul verteilt an die gesteuerten Rollladen - Geräte diverse Benutzerattribute <em> ( userattr ) </em> . In diesem Reading kann der Status dieser Verteilung gepr & uuml ; ft werden . </li>
</ul> < br / >
<u> In den Rolll & auml ; den - Ger & auml ; ten </u>
<ul>
<li> <strong> ASC_Enable - on /off</s trong > - wird der Rollladen & uuml ; ber ASC gesteuert oder nicht </li>
<li> <strong> ASC_Time_DriveUp </strong> - Im Astro - Modus ist hier die Sonnenaufgangszeit f & uuml ; r das Rollo gespeichert . Im Brightness - und Zeit - Modus ist hier der Zeitpunkt aus dem Attribut <em> ASC_Time_Up_Late </em> gespeichert . </li>
<li> <strong> ASC_Time_DriveDown </strong> - Im Astro - Modus ist hier die Sonnenuntergangszeit f & uuml ; r das Rollo gespeichert . Im Brightness - und Zeit - Modus ist hier der Zeitpunkt aus dem Attribut <em> ASC_Time_Down_Late </em> gespeichert . </li>
<li> <strong> ASC_ShuttersLastDrive </strong> - Grund der letzten Fahrt vom Rollladen </li>
</ul>
</ul>
< br /><br / >
< a name = "AutoShuttersControlSet" > </a>
<strong> Set </strong>
<ul>
<li> <strong> ascEnable - on /off</s trong > - Aktivieren oder deaktivieren der globalen ASC Steuerung </li>
<li> <strong> controlShading - on /off</s trong > - Aktiviert oder deaktiviert die globale Beschattungssteuerung </li>
<li> <strong> createNewNotifyDev </strong> - Legt die interne Struktur f & uuml ; r NOTIFYDEV neu an . Diese Funktion steht nur zur Verf & uuml ; gung , wenn Attribut ASC_expert auf 1 gesetzt ist . </li>
<li> <strong> hardLockOut - on /off</s trong > - Aktiviert den globalen Aussperrschutz f & uuml ; r die Rolll & auml ; den , bei denen das Attributs <em> ASC_LockOut </em> entsprechend gesetzt ist . Mehr Informationen in der Beschreibung bei den Attributen f & uuml ; r die Rollladenger & auml ; ten . </li>
<li> <strong> partyMode - on /off</s trong > - Aktiviert den globalen Partymodus . Alle Rollladen - Ger & auml ; ten , in welchen das Attribut <em> ASC_Partymode </em> auf <em> on </em> gesetzt ist , werden durch ASC nicht mehr gesteuert . Der letzte Schaltbefehl , der bspw . durch ein Fensterevent oder Wechsel des Bewohnerstatus an die Rolll & auml ; den gesendet wurde , wird beim Deaktivieren des Partymodus ausgef & uuml ; hrt </li>
<li> <strong> renewSetSunriseSunsetTimer </strong> - erneuert bei allen Rolll & auml ; den die Zeiten f & uuml ; r Sonnenauf - und - untergang und setzt die internen Timer neu . </li>
<li> <strong> scanForShutters </strong> - Durchsucht das System nach Ger & auml ; tenRo mit dem Attribut <em> ASC = 1 </em> oder <em> ASC = 2 </em> </li>
<li> <strong> selfDefense - on /off</s trong > - Aktiviert bzw . deaktiviert die Selbstschutzfunktion . Beispiel: Wenn das Residents - Ger & auml ; t <em> absent </em> meldet , die Selbstschutzfunktion aktiviert wurde und ein Fenster im Haus noch ge & ouml ; ffnet ist , so wird an diesem Fenster der Rollladen deaktivieren dann heruntergefahren . </li>
<li> <strong> shutterASCenableToggle - on /off</s trong > - Aktivieren oder deaktivieren der ASC Kontrolle beim einzelnen Rollladens </li>
<li> <strong> sunriseTimeWeHoliday - on /off</s trong > - Aktiviert die Wochenendunterst & uuml ; tzung und somit , ob im Rollladenger & auml ; t das Attribut <em> ASC_Time_Up_WE_Holiday </em> beachtet werden soll oder nicht . </li>
<li> <strong> wiggle </strong> - bewegt einen oder mehrere Rolll & auml ; den um einen definierten Wert ( Default: 5 % ) und nach einer Minute wieder zur & uuml ; ck in die Ursprungsposition . Diese Funktion k & ouml ; nnte bspw . zur Abschreckung in einem Alarmsystem eingesetzt werden . </li>
</ul>
< br /><br / >
< a name = "AutoShuttersControlGet" > </a>
<strong> Get </strong>
<ul>
<li> <strong> showShuttersInformations </strong> - zeigt eine & Uuml ; bersicht aller Rolll & auml ; den mit den Fahrzeiten , Modus und diverse weitere Statusanzeigen . </li>
<li> <strong> showNotifyDevsInformations </strong> - zeigt eine & Uuml ; bersicht der abgelegten NOTIFYDEV Struktur . Diese Funktion wird prim & auml ; r f & uuml ; rs Debugging genutzt . Hierzu ist das Attribut <em> ASC_expert = 1 </em> zu setzen . </li>
</ul>
< br /><br / >
< a name = "AutoShuttersControlAttributes" > </a>
<strong> Attributes </strong>
<ul>
<u> Im ASC - Device </u>
<ul>
< a name = "ASC_autoAstroModeEvening" > </a>
<li> <strong> ASC_autoAstroModeEvening </strong> - REAL , CIVIL , NAUTIC , ASTRONOMIC oder HORIZON </li>
< a name = "ASC_autoAstroModeEveningHorizon" > </a>
<li> <strong> ASC_autoAstroModeEveningHorizon </strong> - H & ouml ; he & uuml ; ber dem Horizont . Wird nur ber & uuml ; cksichtigt , wenn im Attribut <em> ASC_autoAstroModeEvening </em> der Wert <em> HORIZON </em> ausgew & auml ; hlt wurde . ( default: 0 ) </li>
< a name = "ASC_autoAstroModeMorning" > </a>
<li> <strong> ASC_autoAstroModeMorning </strong> - REAL , CIVIL , NAUTIC , ASTRONOMIC oder HORIZON </li>
< a name = "ASC_autoAstroModeMorningHorizon" > </a>
2019-06-03 07:44:35 +02:00
<li> <strong> ASC_autoAstroModeMorningHorizon </strong> - H & ouml ; he & uuml ; ber dem Horizont . Wird nur ber & uuml ; cksichtigt , wenn im Attribut <em> ASC_autoAstroModeMorning </em> der Wert <em> HORIZON </em> ausgew & auml ; hlt wurde . ( default: 0 ) </li>
2019-05-24 19:56:38 +02:00
< a name = "ASC_autoShuttersControlComfort" > </a>
<li> <strong> ASC_autoShuttersControlComfort - on /off</s trong > - schaltet die Komfortfunktion an . Bedeutet , dass ein Rollladen mit einem threestate - Sensor am Fenster beim & Ouml ; ffnen in eine Offenposition f & auml ; hrt . Hierzu muss beim Rollladen das Attribut <em> ASC_ComfortOpen_Pos </em> entsprechend konfiguriert sein . ( default: off ) </li>
< a name = "ASC_autoShuttersControlEvening" > </a>
<li> <strong> ASC_autoShuttersControlEvening - on /off</s trong > - Aktiviert die automatische Steuerung durch das ASC - Modul am Abend . </li>
< a name = "ASC_autoShuttersControlMorning" > </a>
<li> <strong> ASC_autoShuttersControlMorning - on /off</s trong > - Aktiviert die automatische Steuerung durch das ASC - Modul am Morgen . </li>
< a name = "ASC_blockAscDrivesAfterManual" > </a>
<li> <strong> ASC_blockAscDrivesAfterManual - 0 , 1 </strong> - wenn dieser Wert auf 1 gesetzt ist , dann werden Rolll & auml ; den vom ASC - Modul nicht mehr gesteuert , wenn zuvor manuell eingegriffen wurde . Voraussetzung hierf & uuml ; r ist jedoch , dass im Reading <em> ASC_ShuttersLastDrive </em> der Status <em> manual </em> enthalten ist und sich der Rollladen auf eine unbekannte ( nicht in den Attributen anderweitig konfigurierte ) Position befindet . </li>
< a name = "ASC_brightnessDriveUpDown" > </a>
<li> <strong> ASC_brightnessDriveUpDown - WERT - MORGENS:WERT - ABENDS </strong> - Werte bei dem Schaltbedingungen f & uuml ; r Sonnenauf - und - untergang gepr & uuml ; ft werden sollen . Diese globale Einstellung kann durch die WERT - MORGENS:WERT - ABENDS Einstellung von ASC_BrightnessSensor im Rollladen selbst & uuml ; berschrieben werden . </li>
< a name = "ASC_debug" > </a>
<li> <strong> ASC_debug </strong> - Aktiviert die erweiterte Logausgabe f & uuml ; r Debugausgaben </li>
< a name = "ASC_expert" > </a>
<li> <strong> ASC_expert </strong> - ist der Wert 1 , so werden erweiterte Informationen bez & uuml ; glich des NotifyDevs unter set und get angezeigt </li>
< a name = "ASC_freezeTemp" > </a>
<li> <strong> ASC_freezeTemp </strong> - Temperatur , ab welcher der Frostschutz greifen soll und der Rollladen nicht mehr f & auml ; hrt . Der letzte Fahrbefehl wird gespeichert . </li>
< a name = "ASC_rainSensor" > </a>
<li> <strong> ASC_rainSensor - DEVICENAME [ : READINGNAME ] MAXTRIGGER [ : HYSTERESE ] [ CLOSEDPOS ] </strong> - der Inhalt ist eine Kombination aus Devicename , Readingname , Wert ab dem getriggert werden soll , Hysterese Wert ab dem der Status Regenschutz aufgehoben werden soll und der "wegen Regen geschlossen Position" . </li>
< a name = "ASC_residentsDev" > </a>
<li> <strong> ASC_residentsDev - DEVICENAME [ : READINGNAME ] </strong> - der Inhalt ist eine Kombination aus Devicenamen und Readingnamen des Residents - Device der obersten Ebene ( z . B . rgr_Residents:presence ) </li>
< a name = "ASC_shuttersDriveOffset" > </a>
<li> <strong> ASC_shuttersDriveOffset </strong> - maximale Zufallsverz & ouml ; gerung in Sekunden bei der Berechnung der Fahrzeiten . 0 bedeutet keine Verz & ouml ; gerung </li>
< a name = "ASC_tempSensor" > </a>
<li> <strong> ASC_tempSensor - DEVICENAME [ : READINGNAME ] </strong> - der Inhalt ist eine Kombination aus Device und Reading f & uuml ; r die Au & szlig ; entemperatur </li>
< a name = "ASC_twilightDevice" > </a>
<li> <strong> ASC_twilightDevice </strong> - das Device , welches die Informationen zum Sonnenstand liefert . Wird unter anderem f & uuml ; r die Beschattung verwendet . </li>
< a name = "ASC_windSensor" > </a>
<li> <strong> ASC_windSensor - DEVICE [ : READING ] </strong> - Sensor f & uuml ; r die Windgeschwindigkeit . Kombination aus Device und Reading . </li>
</ul>
< br / >
<ul>
<u> Folgende Attribute sind obsolet und sollten nicht mehr verwendet werden . </u>
< a name = "ASC_temperatureSensor" > </a>
<li> ASC_temperatureSensor - <em> WARNUNG ! ! ! OBSOLET ! ! ! NICHT VERWENDEN ! ! ! </em> </li>
< a name = "ASC_temperatureReading" > </a>
<li> ASC_temperatureReading - <em> WARNUNG ! ! ! OBSOLET ! ! ! NICHT VERWENDEN ! ! ! </em> </li>
< a name = "ASC_residentsDevice" > </a>
<li> ASC_residentsDevice - <em> WARNUNG ! ! ! OBSOLET ! ! ! NICHT VERWENDEN ! ! ! </em> </li>
< a name = "ASC_residentsDeviceReading" > </a>
<li> ASC_residentsDeviceReading - <em> WARNUNG ! ! ! OBSOLET ! ! ! NICHT VERWENDEN ! ! ! </em> </li>
< a name = "ASC_rainSensorDevice" > </a>
<li> ASC_rainSensorDevice - <em> WARNUNG ! ! ! OBSOLET ! ! ! NICHT VERWENDEN ! ! ! </em> </li>
< a name = "ASC_rainSensorReading" > </a>
<li> ASC_rainSensorReading - <em> WARNUNG ! ! ! OBSOLET ! ! ! NICHT VERWENDEN ! ! ! </em> </li>
< a name = "ASC_rainSensorShuttersClosedPos" > </a>
<li> ASC_rainSensorShuttersClosedPos - <em> WARNUNG ! ! ! OBSOLET ! ! ! NICHT VERWENDEN ! ! ! </em> </li>
< a name = "ASC_brightnessMinVal" > </a>
<li> ASC_brightnessMinVal - <em> WARNUNG ! ! ! OBSOLET ! ! ! NICHT VERWENDEN ! ! ! </em> </li>
< a name = "ASC_brightnessMaxVal" > </a>
<li> ASC_brightnessMaxVal - <em> WARNUNG ! ! ! OBSOLET ! ! ! NICHT VERWENDEN ! ! ! </em> </li>
</ul>
< br / >
<u> In den Rolll & auml ; den - Ger & auml ; ten </u>
<ul>
<li> <strong> ASC - 0 /1/ 2 </strong> 0 = "kein Anlegen der Attribute beim ersten Scan bzw. keine Beachtung eines Fahrbefehles" , 1 = "Inverse oder Rollo - Bsp.: Rollo oben 0, Rollo unten 100 und der Befehl zum prozentualen Fahren ist position" , 2 = " Homematic Style - Bsp . : Rollo oben 100 , Rollo unten 0 und der Befehl zum prozentualen Fahren ist pct </li>
<li> <strong> ASC_Antifreeze - soft /am/ pm /hard/o ff </strong> - Frostschutz , wenn soft f & auml ; hrt der Rollladen in die ASC_Antifreeze_Pos und wenn hard /am/ pm wird gar nicht oder innerhalb der entsprechenden Tageszeit nicht gefahren ( default: off ) </li>
<li> <strong> ASC_Antifreeze_Pos </strong> - Position die angefahren werden soll , wenn der Fahrbefehl komplett schlie & szlig ; en lautet , aber der Frostschutz aktiv ist ( default: 50 ) </li>
<li> <strong> ASC_AutoAstroModeEvening </strong> - aktuell REAL , CIVIL , NAUTIC , ASTRONOMIC ( default: none ) </li>
<li> <strong> ASC_AutoAstroModeEveningHorizon </strong> - H & ouml ; he & uuml ; ber Horizont , wenn beim Attribut ASC_autoAstroModeEvening HORIZON ausgew & auml ; hlt ( default: none ) </li>
<li> <strong> ASC_AutoAstroModeMorning </strong> - aktuell REAL , CIVIL , NAUTIC , ASTRONOMIC ( default: none ) </li>
<li> <strong> ASC_AutoAstroModeMorningHorizon </strong> - H & ouml ; he & uuml ; ber Horizont , a wenn beim Attribut ASC_autoAstroModeMorning HORIZON ausgew & auml ; hlt ( default: none ) </li>
<li> <strong> ASC_BlockingTime_afterManual </strong> - wie viel Sekunden soll die Automatik nach einer manuellen Fahrt aussetzen . ( default: 1200 ) </li>
<li> <strong> ASC_BlockingTime_beforDayOpen </strong> - wie viel Sekunden vor dem morgendlichen & ouml ; ffnen soll keine schlie & szlig ; en Fahrt mehr stattfinden . ( default: 3600 ) </li>
<li> <strong> ASC_BlockingTime_beforNightClose </strong> - wie viel Sekunden vor dem n & auml ; chtlichen schlie & szlig ; en soll keine & ouml ; ffnen Fahrt mehr stattfinden . ( default: 3600 ) </li>
<li> <strong> ASC_BrightnessSensor - DEVICE [ : READING ] WERT - MORGENS:WERT - ABENDS </strong> / 'Sensorname[:brightness [400:800]]' Angaben zum Helligkeitssensor mit (Readingname, optional) für die Beschattung und dem Fahren der Rollladen nach brightness und den optionalen Brightnesswerten für Sonnenauf- und Sonnenuntergang. (default: none)</ li >
<li> <strong> ASC_Closed_Pos </strong> - in 10 Schritten von 0 bis 100 ( Default: ist abh & auml ; ngig vom Attribut <em> ASC </em> ) </li>
<li> <strong> ASC_ComfortOpen_Pos </strong> - in 10 Schritten von 0 bis 100 ( Default: ist abh & auml ; ngig vom Attribut <em> ASC </em> ) </li>
2019-06-03 11:32:50 +02:00
<li> <strong> ASC_Down - astro /time/ brightness </strong> - bei astro wird Sonnenuntergang berechnet , bei time wird der Wert aus ASC_Time_Down_Early als Fahrzeit verwendet und bei brightness muss ASC_Time_Down_Early und ASC_Time_Down_Late korrekt gesetzt werden . Der Timer l & auml ; uft dann nach ASC_Time_Down_Late Zeit , es wird aber in der Zeit zwischen ASC_Time_Down_Early und ASC_Time_Down_Late geschaut , ob die als Attribut im Moduldevice hinterlegte ASC_brightnessDriveUpDown der Down Wert erreicht wurde . Wenn ja , wird der Rollladen runter gefahren ( default: astro ) </li>
2019-05-24 19:56:38 +02:00
<li> <strong> ASC_DriveUpMaxDuration </strong> - die Dauer des Hochfahrens des Rollladens plus 5 Sekunden ( default: 60 ) </li>
<li> <strong> ASC_Drive_Offset </strong> - maximaler Wert f & uuml ; r einen zuf & auml ; llig ermittelte Verz & ouml ; gerungswert in Sekunden bei der Berechnung der Fahrzeiten , 0 bedeutet keine Verz & ouml ; gerung , - 1 bedeutet , dass das gleichwertige Attribut aus dem ASC Device ausgewertet werden soll . ( default: - 1 ) </li>
<li> <strong> ASC_Drive_OffsetStart </strong> - in Sekunden verz & ouml ; gerter Wert ab welchen dann erst das Offset startet und dazu addiert wird . Funktioniert nur wenn gleichzeitig ASC_Drive_Offset gesetzt wird . ( default: - 1 ) </li>
<li> <strong> ASC_LockOut - soft /hard/o ff </strong> - stellt entsprechend den Aussperrschutz ein . Bei global aktivem Aussperrschutz ( set ASC - Device lockOut soft ) und einem Fensterkontakt open bleibt dann der Rollladen oben . Dies gilt nur bei Steuerbefehlen & uuml ; ber das ASC Modul . Stellt man global auf hard , wird bei entsprechender M & ouml ; glichkeit versucht den Rollladen hardwareseitig zu blockieren . Dann ist auch ein Fahren & uuml ; ber die Taster nicht mehr m & ouml ; glich . ( default: off ) </li>
<li> <strong> ASC_LockOut_Cmd - inhibit /blocked/ protection </strong> - set Befehl f & uuml ; r das Rollladen - Device zum Hardware sperren . Dieser Befehl wird gesetzt werden , wenn man "ASC_LockOut" auf hard setzt ( default: none ) </li>
<li> <strong> ASC_Mode_Down - always /home/ absent /off</s trong > - Wann darf die Automatik steuern . immer , niemals , bei Abwesenheit des Roommate ( ist kein Roommate und absent eingestellt , wird gar nicht gesteuert ) ( default: always ) </li>
<li> <strong> ASC_Mode_Up - always /home/ absent /off</s trong > - Wann darf die Automatik steuern . immer , niemals , bei Abwesenheit des Roommate ( ist kein Roommate und absent eingestellt , wird gar nicht gesteuert ) ( default: always ) </li>
<li> <strong> ASC_Open_Pos </strong> - in 10 Schritten von 0 bis 100 ( default: ist abh & auml ; ngig vom Attribut <em> ASC </em> ) </li>
<li> <strong> ASC_Partymode - on /off</s trong > - schaltet den Partymodus an oder aus . Wird am ASC Device set ASC - DEVICE partyMode on geschalten , werden alle Fahrbefehle an den Rolll & auml ; den , welche das Attribut auf on haben , zwischengespeichert und sp & auml ; ter erst ausgef & uuml ; hrt ( default: off ) </li>
<li> <strong> ASC_Pos_Reading </strong> - Name des Readings , welches die Position des Rollladen in Prozent an gibt ; wird bei unbekannten Device Typen auch als set Befehl zum fahren verwendet </li>
<li> <strong> ASC_PrivacyDownTime_beforNightClose </strong> - wie viele Sekunden vor dem abendlichen schlie & szlig ; en soll der Rollladen in die Sichtschutzposition fahren , - 1 bedeutet das diese Funktion unbeachtet bleiben soll ( default: - 1 ) </li>
<li> <strong> ASC_PrivacyDown_Pos </strong> - Position den Rollladens f & uuml ; r den Sichtschutz ( default: 50 ) </li>
2019-06-10 13:41:46 +02:00
<li> <strong> ASC_WindProtection - on /off</s trong > - soll der Rollladen beim Regenschutz beachtet werden . on = JA , off = NEIN . </li>
2019-05-24 19:56:38 +02:00
<li> <strong> ASC_Roommate_Device </strong> - mit Komma getrennte Namen des /der Roommate Device/s , welche den /die Bewohner des Raumes vom Rollladen wiedergibt. Es macht nur Sinn in Schlaf- oder Kinderzimmern (default: none)</ li >
<li> <strong> ASC_Roommate_Reading </strong> - das Reading zum Roommate Device , welches den Status wieder gibt ( default: state ) </li>
2019-06-10 13:41:46 +02:00
<li> <strong> ASC_Self_Defense_Exclude - on /off</s trong > - bei on Wert wird dieser Rollladen bei aktiven Self Defense und offenen Fenster nicht runter gefahren , wenn Residents absent ist . ( default: off ) </li> </p>
2019-05-24 19:56:38 +02:00
<ul>
<strong> <u> Beschreibung der Beschattungsfunktion </u> </strong>
</br> Damit die Beschattung Funktion hat , m & uuml ; ssen folgende Anforderungen erf & uuml ; llt sein .
</br> <strong> Im ASC Device </strong> das Attribut "ASC_autoShuttersControlShading" mit dem Wert on , sowie ein Astro / Twilight Device im Attribut "ASC_twilightDevice" und das Attribut "ASC_tempSensor" .
</br> <strong> In den Rollladendevices </strong> ben & ouml ; tigt ihr ein Helligkeitssensor als Attribut "ASC_BrightnessSensor" , sofern noch nicht vorhanden . Findet der Sensor nur f & uuml ; r die Beschattung Verwendung ist der Wert DEVICENAME [ : READING ] ausreichend .
</br> Alle weiteren Attribute sind optional und wenn nicht gesetzt mit Default - Werten belegt . Ihr solltet sie dennoch einmal anschauen und entsprechend Euren Gegebenheiten setzen . Die Werte f & uumlr ; die Fensterposition und den Vor - Nachlaufwinkel sowie die Grenzwerte f & uuml ; r die StateChange_Cloudy und StateChange_Sunny solltet ihr besondere Beachtung dabei schenken .
<li> <strong> ASC_Shading_Angle_Left </strong> - Vorlaufwinkel im Bezug zum Fenster , ab wann abgeschattet wird . Beispiel: Fenster 180 ° - 85 ° == > ab Sonnenpos . 95 ° wird abgeschattet ( default: 75 ) </li>
<li> <strong> ASC_Shading_Angle_Right </strong> - Nachlaufwinkel im Bezug zum Fenster , bis wann abgeschattet wird . Beispiel: Fenster 180 ° + 85 ° == > bis Sonnenpos . 265 ° wird abgeschattet ( default: 75 ) </li>
<li> <strong> ASC_Shading_Direction </strong> - Position in Grad , auf der das Fenster liegt - genau Osten w & auml ; re 90 , S & uuml ; den 180 und Westen 270 ( default: 180 ) </li>
2019-06-10 13:41:46 +02:00
<li> <strong> ASC_Shading_MinMax_Elevation </strong> - ab welcher min H & ouml ; he des Sonnenstandes soll beschattet und ab welcher max H & ouml ; he wieder beendet werden , immer in Abh & auml ; ngigkeit der anderen einbezogenen Sensorwerte ( default: 25.0 : 100.0 ) </li>
2019-05-24 19:56:38 +02:00
<li> <strong> ASC_Shading_Min_OutsideTemperature </strong> - ab welcher Temperatur soll Beschattet werden , immer in Abh & auml ; ngigkeit der anderen einbezogenen Sensorwerte ( default: 18 ) </li>
<li> <strong> ASC_Shading_Mode - absent , always , off , home </strong> / wann soll die Beschattung nur stattfinden. (default: off)</ li >
<li> <strong> ASC_Shading_Pos </strong> - Position des Rollladens f & uuml ; r die Beschattung </li>
<li> <strong> ASC_Shading_StateChange_Cloudy </strong> - Brightness Wert ab welchen die Beschattung aufgehoben werden soll , immer in Abh & auml ; ngigkeit der anderen einbezogenen Sensorwerte ( default: 20000 ) </li>
<li> <strong> ASC_Shading_StateChange_Sunny </strong> - Brightness Wert ab welchen Beschattung stattfinden soll , immer in Abh & auml ; ngigkeit der anderen einbezogenen Sensorwerte ( default: 35000 ) </li>
<li> <strong> ASC_Shading_WaitingPeriod </strong> - wie viele Sekunden soll gewartet werden bevor eine weitere Auswertung der Sensordaten f & uuml ; r die Beschattung stattfinden soll ( default: 1200 ) </li>
</ul>
<li> <strong> ASC_ShuttersPlace - window /terrace</s trong > - Wenn dieses Attribut auf terrace gesetzt ist , das Residence Device in den Status "gone" geht und SelfDefense aktiv ist ( ohne das das Reading selfDefense gesetzt sein muss ) , wird das Rollo geschlossen ( default: window ) </li>
<li> <strong> ASC_Time_Down_Early </strong> - Sonnenuntergang fr & uuml ; hste Zeit zum Runterfahren ( default: 16 : 00 ) </li>
<li> <strong> ASC_Time_Down_Late </strong> - Sonnenuntergang sp & auml ; teste Zeit zum Runterfahren ( default: 22 : 00 ) </li>
<li> <strong> ASC_Time_Up_Early </strong> - Sonnenaufgang fr & uuml ; hste Zeit zum Hochfahren ( default: 05 : 00 ) </li>
<li> <strong> ASC_Time_Up_Late </strong> - Sonnenaufgang sp & auml ; teste Zeit zum Hochfahren ( default: 08 : 30 ) </li>
<li> <strong> ASC_Time_Up_WE_Holiday </strong> - Sonnenaufgang fr & uuml ; hste Zeit zum Hochfahren am Wochenende und /oder Urlaub (holiday2we wird beachtet). (default: 08:00) ACHTUNG!!! in Verbindung mit Brightness für <em>ASC_Up</ em > muss die Uhrzeit kleiner sein wie die Uhrzeit aus <em> ASC_Time_Up_Late </em> </li>
2019-06-03 11:32:50 +02:00
<li> <strong> ASC_Up - astro /time/ brightness </strong> - bei astro wird Sonnenaufgang berechnet , bei time wird der Wert aus ASC_Time_Up_Early als Fahrzeit verwendet und bei brightness muss ASC_Time_Up_Early und ASC_Time_Up_Late korrekt gesetzt werden . Der Timer l & auml ; uft dann nach ASC_Time_Up_Late Zeit , es wird aber in der Zeit zwischen ASC_Time_Up_Early und ASC_Time_Up_Late geschaut , ob die als Attribut im Moduldevice hinterlegte Down Wert von ASC_brightnessDriveUpDown erreicht wurde . Wenn ja , wird der Rollladen hoch gefahren ( default: astro ) </li>
2019-05-24 19:56:38 +02:00
<li> <strong> ASC_Ventilate_Pos </strong> - in 10 Schritten von 0 bis 100 ( default: ist abh & auml ; ngig vom Attribut <em> ASC </em> ) </li>
<li> <strong> ASC_Ventilate_Window_Open </strong> - auf l & uuml ; ften , wenn das Fenster gekippt /geöffnet wird und aktuelle Position unterhalb der Lüften-Position ist (default: on)</ li >
<li> <strong> ASC_WiggleValue </strong> - Wert um welchen sich die Position des Rollladens & auml ; ndern soll ( default: 5 ) </li>
<li> <strong> ASC_WindParameters - TRIGGERMAX [ : HYSTERESE ] [ DRIVEPOSITION ] </strong> / Angabe von Max Wert ab dem für Wind getriggert werden soll, Hytsrese Wert ab dem der Windschutz aufgehoben werden soll TRIGGERMAX - HYSTERESE / Ist es bei einigen Rolll & auml ; den nicht gew & uuml ; nscht das gefahren werden soll , so ist der TRIGGERMAX Wert mit - 1 an zu geben . ( default: '50:20 ClosedPosition' ) </li>
<li> <strong> ASC_WindowRec </strong> - Name des Fensterkontaktes , an dessen Fenster der Rollladen angebracht ist ( default: none ) </li>
<li> <strong> ASC_WindowRec_subType </strong> - Typ des verwendeten Fensterkontaktes: twostate ( optisch oder magnetisch ) oder threestate ( Drehgriffkontakt ) ( default: twostate ) </li>
</ul>
</ul>
</p>
<strong> <u> Beschreibung der AutoShuttersControl API </u> </strong>
</br> Mit dem Aufruf der API Funktion und & Uuml ; bergabe der entsprechenden Parameter ist es m & ouml ; glich auf interne Daten zu zu greifen .
2019-05-20 14:23:11 +02:00
</p>
2019-05-24 19:56:38 +02:00
<u> & Uuml ; bersicht f & uuml ; r das Rollladen - Device </u>
2019-05-20 14:23:11 +02:00
<ul>
2019-05-24 19:56:38 +02:00
<code> { ascAPIget ( 'Getter' , 'ROLLODEVICENAME' ) } </code> <br>
2019-05-20 14:23:11 +02:00
</ul>
< table border = "1" >
2019-05-24 19:56:38 +02:00
<tr> <th> Getter </th> <th> Erl & auml ; uterung </th> </tr>
<tr> <td> FreezeStatus </td> <td> 1 = soft , 2 = Daytime , 3 = hard </td> </tr>
<tr> <td> NoOffset </td> <td> Wurde die Behandlung von Offset deaktiviert ( Beispiel bei Fahrten & uuml ; ber Fensterevents ) </td> </tr>
<tr> <td> LastDrive </td> <td> Grund des letzten Fahrens </td> </tr>
<tr> <td> LastPos </td> <td> die letzte Position des Rollladens </td> </tr>
<tr> <td> LastPosTimestamp </td> <td> Timestamp der letzten festgestellten Position </td> </tr>
<tr> <td> LastManPos </td> <td> Position der letzten manuellen Fahrt </td> </tr>
<tr> <td> LastManPosTimestamp </td> <td> Timestamp der letzten manuellen Position </td> </tr>
<tr> <td> SunsetUnixTime </td> <td> berechnete Unixzeit f & uuml ; r Abends ( Sonnenuntergang ) </td> </tr>
<tr> <td> Sunset </td> <td> 1 = Abendfahrt wurde durchgef & uuml ; hrt , 0 = noch keine Abendfahrt durchgef & uuml ; hrt </td> </tr>
<tr> <td> SunriseUnixTime </td> <td> berechnete Unixzeit f & uuml ; r Morgens ( Sonnenaufgang ) </td> </tr>
<tr> <td> Sunrise </td> <td> 1 = Morgenfahrt wurde durchgef & uuml ; hrt , 0 = noch keine Morgenfahrt durchgef & uuml ; hrt </td> </tr>
<tr> <td> RoommatesStatus </td> <td> aktueller Status der /des Roommate/s f & uuml ; r den Rollladen </td> </tr>
<tr> <td> RoommatesLastStatus </td> <td> letzter Status der /des Roommate/s f & uuml ; r den Rollladen </td> </tr>
<tr> <td> ShadingStatus </td> <td> Ausgabe des aktuellen Shading Status , „ in “ , „ out “ , „ in reserved “ , „ out reserved “ </td> </tr>
<tr> <td> ShadingStatusTimestamp </td> <td> Timestamp des letzten Beschattungsstatus </td> </tr>
<tr> <td> IfInShading </td> <td> Befindet sich der Rollladen , in Abh & auml ; ngigkeit des Shading Mode , in der Beschattung </td> </tr>
2019-06-03 07:44:35 +02:00
<tr> <td> WindProtectionStatus </td> <td> aktueller Status der Wind Protection „ protected “ oder „ unprotected “ </td> </tr>
<tr> <td> RainProtectionStatus </td> <td> aktueller Status der Regen Protection „ unprotected “ oder „ unprotected “ </td> </tr>
2019-05-24 19:56:38 +02:00
<tr> <td> DelayCmd </td> <td> letzter Fahrbefehl welcher in die Warteschlange kam . Grund z . B . Partymodus . </td> </tr>
<tr> <td> Status </td> <td> Position des Rollladens </td> </tr>
<tr> <td> ASCenable </td> <td> Abfrage ob f & uuml ; r den Rollladen die ASC Steuerung aktiv ist . </td> </tr>
2019-06-04 10:53:28 +02:00
<tr> <td> IsDay </td> <td> Abfrage ob das Rollo im Tag oder Nachtmodus ist . Also nach Sunset oder nach Sunrise </td> </tr>
2019-05-29 22:35:33 +02:00
<table/>
2019-05-24 19:56:38 +02:00
</p>
<u> & Uuml ; bersicht f & uuml ; r das ASC Device </u>
<ul>
<code> { ascAPIget ( 'Getter' ) } </code> <br>
</ul>
< table border = "1" >
<tr> <th> Getter </th> <th> Erl & auml ; uterung </th> </tr>
<tr> <td> outTemp </td> <td> aktuelle Außentemperatur sofern Sensor definiert </td> </tr>
<tr> <td> ResidentsStatus </td> <td> aktueller Status des Residents Devices </td> </tr>
<tr> <td> ResidentsLastStatus </td> <td> letzter Status des Residents Devices </td> </tr>
<tr> <td> Azimuth </td> <td> Azimut Wert </td> </tr>
<tr> <td> Elevation </td> <td> Elevation Wert </td> </tr>
<tr> <td> ASCenable </td> <td> ist die ASC Steuerung global aktiv ? </td> </tr>
2019-05-29 22:35:33 +02:00
<table/>
2019-05-07 16:45:39 +02:00
</ul>
2018-08-15 10:27:53 +02:00
= end html_DE
2019-03-27 08:41:15 +01:00
= for : application / json ; q = META . json 73 _AutoShuttersControl . pm
{
"abstract" : "Module for controlling shutters depending on various conditions" ,
"x_lang" : {
"de" : {
"abstract" : "Modul zur Automatischen Rolladensteuerung auf Basis bestimmter Ereignisse"
}
} ,
"keywords" : [
"fhem-mod-device" ,
"fhem-core" ,
"Shutter" ,
"Automation" ,
"Rollladen" ,
"Rollo" ,
"Control"
] ,
"release_status" : "under develop" ,
"license" : "GPL_2" ,
"author" : [
"Marko Oldenburg <leongaultier@gmail.com>"
] ,
"x_fhem_maintainer" : [
"CoolTux"
] ,
"x_fhem_maintainer_github" : [
"LeonGaultier"
] ,
"prereqs" : {
"runtime" : {
"requires" : {
"FHEM" : 5.00918799 ,
"perl" : 5.016 ,
"Meta" : 0 ,
2019-06-07 19:49:33 +02:00
"JSON" : 0 ,
"Date::Parse" : 0
2019-03-27 08:41:15 +01:00
} ,
"recommends" : {
} ,
"suggests" : {
}
}
}
}
= end : application / json ; q = META . json
2018-08-15 10:27:53 +02:00
= cut