From a0a31e2334019c72cddcdd6cc216543269f79070 Mon Sep 17 00:00:00 2001 From: LeonGaultier Date: Fri, 14 Jan 2022 07:55:06 +0000 Subject: [PATCH] 73_AutoShuttersControl: change Attribut ASC_advDate to ASC_advStartDate. Add Attribut ASC_advEndDate git-svn-id: https://svn.fhem.de/fhem/trunk@25464 2b470e98-0d58-463d-a4d8-8e2adae1ed80 --- fhem/CHANGED | 2 + fhem/FHEM/73_AutoShuttersControl.pm | 57 +- fhem/lib/FHEM/Automation/ShuttersControl.pm | 835 +++++++++--------- .../FHEM/Automation/ShuttersControl/Dev.pm | 6 +- .../Automation/ShuttersControl/Dev/Attr.pm | 113 ++- .../ShuttersControl/Dev/Readings.pm | 53 +- .../EventProcessingFunctions.pm | 508 ++++++----- .../FHEM/Automation/ShuttersControl/Helper.pm | 306 +++---- .../ShuttersControl/Rainprotection.pm | 124 +-- .../Automation/ShuttersControl/Roommate.pm | 36 +- .../Automation/ShuttersControl/Shading.pm | 238 ++--- .../Automation/ShuttersControl/Shutters.pm | 73 +- .../ShuttersControl/Shutters/Attr.pm | 283 +++--- .../ShuttersControl/Shutters/Readings.pm | 23 +- .../FHEM/Automation/ShuttersControl/Window.pm | 6 +- .../Automation/ShuttersControl/Window/Attr.pm | 28 +- .../ShuttersControl/Window/Readings.pm | 16 +- 17 files changed, 1383 insertions(+), 1324 deletions(-) diff --git a/fhem/CHANGED b/fhem/CHANGED index c648a2f87..12ecfe279 100644 --- a/fhem/CHANGED +++ b/fhem/CHANGED @@ -1,5 +1,7 @@ # Add changes at the top of the list. Keep it in ASCII, and 80-char wide. # Do not insert empty lines here, update check depends on it. + - change: 73_AutoShuttersControl: change Attribut ASC_advDate + to ASC_advStartDate. Add Attribut ASC_advEndDate - change: 50_Signalbot: new favorite feature and bug fixes - change: 93_DbRep: usage of placeholder §device§, §reading§ in sqlCmd changed (refer to commandRef) diff --git a/fhem/FHEM/73_AutoShuttersControl.pm b/fhem/FHEM/73_AutoShuttersControl.pm index 0dc5c838c..f6840ebec 100644 --- a/fhem/FHEM/73_AutoShuttersControl.pm +++ b/fhem/FHEM/73_AutoShuttersControl.pm @@ -1,8 +1,8 @@ ############################################################################### # -# Developed with Kate +# Developed with VSCodium and richterger perl plugin # -# (c) 2018-2021 Copyright: Marko Oldenburg (fhemdevelopment at cooltux dot net) +# (c) 2018-2022 Copyright: Marko Oldenburg (fhemdevelopment at cooltux dot net) # All rights reserved # # Special thanks goes to: @@ -49,26 +49,17 @@ use utf8; use FHEM::Meta; use FHEM::Automation::ShuttersControl; -use GPUtils qw(GP_Import GP_Export); +use GPUtils qw(GP_Import); ## Import der FHEM Funktionen #-- Run before package compilation BEGIN { # Import from main context - GP_Import( - qw( - readingFnAttributes - ) - ); - - #-- Export to main context with different name - GP_Export( - qw( - Initialize - ) - ); + GP_Import(qw(readingFnAttributes)); } +sub ::AutoShuttersControl_Initialize { goto &Initialize } + sub Initialize { my $hash = shift; @@ -81,7 +72,7 @@ sub Initialize { $hash->{UndefFn} = \&FHEM::Automation::ShuttersControl::Undef; $hash->{DeleteFn} = \&FHEM::Automation::ShuttersControl::Delete; $hash->{ShutdownFn} = \&FHEM::Automation::ShuttersControl::Shutdown; - $hash->{AttrList} = + $hash->{AttrList} = 'ASC_tempSensor ' . 'ASC_brightnessDriveUpDown ' . 'ASC_autoShuttersControlMorning:on,off ' @@ -100,7 +91,8 @@ sub Initialize { . 'ASC_expert:1 ' . 'ASC_blockAscDrivesAfterManual:0,1 ' . 'ASC_debug:1 ' - . 'ASC_advDate:DeadSunday,FirstAdvent ' + . 'ASC_advStartDate:DeadSunday,FirstAdvent ' + . 'ASC_advEndDate:CandlemasDay,EpiphanyDay ' . $readingFnAttributes; $hash->{NotifyOrderPrefix} = '51-'; # Order Nummer für NotifyFn $hash->{FW_detailFn} = @@ -328,8 +320,11 @@ __END__
  • ASC_freezeTemp - Temperature threshold for the freeze protection. The freeze protection prevents the shutter to be operated by ASC. Last operating order will be kept.
  • - -
  • ASC_advDate - Advent Season, selected FirstAdvent or DeadSunday. + +
  • ASC_advStartDate - Begin of Advent Season, selected FirstAdvent or DeadSunday. +
  • + +
  • ASC_advEndDate - End of Advent Season, selected CandlemasDay 6. January or EpiphanyDay 2. February.
  • ASC_rainSensor DEVICENAME[:READINGNAME] MAXTRIGGER[:HYSTERESE] [CLOSEDPOS] - Contains @@ -416,11 +411,11 @@ __END__ after the last manual operation in seconds. Defaults to 1200 (20 minutes).
  • -
  • ASC_BlockingTime_beforeDayOpen - Time in which no closing operation is made by +
  • ASC_BlockingTime_beforDayOpen - Time in which no closing operation is made by ASC after opening at the morning in seconds. Defaults to 3600 (one hour).
  • - -
  • ASC_BlockingTime_beforeNightClose - Time in which no closing operation is made by + +
  • ASC_BlockingTime_beforNightClose - Time in which no closing operation is made by ASC before closing at the evening in seconds. Defaults to 3600 (one hour).
  • @@ -1006,8 +1001,10 @@ __END__
  • ASC_expert - ist der Wert 1, so werden erweiterte Informationen bezüglich des NotifyDevs unter set und get angezeigt
  • ASC_freezeTemp - Temperatur, ab welcher der Frostschutz greifen soll und der Rollladen nicht mehr fährt. Der letzte Fahrbefehl wird gespeichert.
  • - -
  • ASC_advDate - Adventszeit, Auswahl ab wann die Adventszeit beginnen soll.
  • + +
  • ASC_advStartDate - Start der Adventszeit, Auswahl ab wann die Adventszeit beginnen soll. 1. Advent oder Totensonntag
  • + +
  • ASC_advEndDate - Ende der Adventszeit, Auswahl ab wann die Adventszeit Enden soll. EpiphanyDay 6. Januar oder CandlemasDay 2. Februar
  • ASC_rainSensor - DEVICENAME[:READINGNAME] MAXTRIGGER[:HYSTERESE] [CLOSEDPOS:[WAITINGTIME]] - 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", sowie der Wartezeit bis dann tatsächlich die aktion ausgeführt wird.
  • @@ -1041,10 +1038,10 @@ __END__
  • ASC_AutoAstroModeMorningHorizon - Höhe über Horizont,a wenn beim Attribut ASC_autoAstroModeMorning HORIZON ausgewählt (default: none)
  • ASC_BlockingTime_afterManual - wie viel Sekunden soll die Automatik nach einer manuellen Fahrt aussetzen. (default: 1200)
  • - -
  • ASC_BlockingTime_beforeDayOpen - wie viel Sekunden vor dem morgendlichen öffnen soll keine schließen Fahrt mehr stattfinden. (default: 3600)
  • - -
  • ASC_BlockingTime_beforeNightClose - wie viel Sekunden vor dem nächtlichen schließen soll keine öffnen Fahrt mehr stattfinden. (default: 3600)
  • + +
  • ASC_BlockingTime_beforDayOpen - wie viel Sekunden vor dem morgendlichen öffnen soll keine schließen Fahrt mehr stattfinden. (default: 3600)
  • + +
  • ASC_BlockingTime_beforNightClose - wie viel Sekunden vor dem nächtlichen schließen soll keine öffnen Fahrt mehr stattfinden. (default: 3600)
  • ASC_BrightnessSensor - DEVICE[:READING] WERT-MORGENS:WERT-ABENDS / '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)
  • @@ -1465,7 +1462,7 @@ __END__ ], "release_status": "stable", "license": "GPL_2", - "version": "v0.10.19", + "version": "v0.10.20", "author": [ "Marko Oldenburg " ], @@ -1479,7 +1476,7 @@ __END__ "runtime": { "requires": { "FHEM": 5.00918799, - "perl": 5.016, + "perl": 5.023, "Meta": 0, "JSON": 0, "Date::Parse": 0 diff --git a/fhem/lib/FHEM/Automation/ShuttersControl.pm b/fhem/lib/FHEM/Automation/ShuttersControl.pm index b53a2809c..a887296c8 100644 --- a/fhem/lib/FHEM/Automation/ShuttersControl.pm +++ b/fhem/lib/FHEM/Automation/ShuttersControl.pm @@ -1,8 +1,8 @@ ############################################################################### # -# Developed with Kate +# Developed with VSCodium and richterger perl plugin # -# (c) 2018-2021 Copyright: Marko Oldenburg (fhemsupport@cooltux.net) +# (c) 2018-2022 Copyright: Marko Oldenburg (fhemdevelopment at cooltux dot net) # All rights reserved # # Special thanks goes to: @@ -72,11 +72,13 @@ use FHEM::Meta; use GPUtils qw(GP_Import GP_Export); use Data::Dumper; #only for Debugging use Date::Parse; +use experimental qw( switch ); use FHEM::Automation::ShuttersControl::Shutters; use FHEM::Automation::ShuttersControl::Dev; -use FHEM::Automation::ShuttersControl::Shading qw (CheckASC_ConditionsForShadingFn); +use FHEM::Automation::ShuttersControl::Shading + qw (CheckASC_ConditionsForShadingFn); use FHEM::Automation::ShuttersControl::EventProcessingFunctions qw (:ALL); use FHEM::Automation::ShuttersControl::Helper qw (:ALL); @@ -86,27 +88,20 @@ eval { require JSON::MaybeXS; import JSON::MaybeXS qw( decode_json encode_json ); 1; -}; - -if ($@) { - $@ = undef; +} or do { # 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' - if ( !defined( $ENV{PERL_JSON_BACKEND} ) ); + unless ( defined( $ENV{PERL_JSON_BACKEND} ) ); require JSON; import JSON qw( decode_json encode_json ); 1; - }; - - if ($@) { - $@ = undef; + } or do { # In rare cases, Cpanel::JSON::XS may # be installed but JSON|JSON::MaybeXS not ... @@ -114,10 +109,7 @@ if ($@) { require Cpanel::JSON::XS; import Cpanel::JSON::XS qw(decode_json encode_json); 1; - }; - - if ($@) { - $@ = undef; + } or do { # In rare cases, JSON::XS may # be installed but JSON not ... @@ -125,10 +117,7 @@ if ($@) { require JSON::XS; import JSON::XS qw(decode_json encode_json); 1; - }; - - if ($@) { - $@ = undef; + } or do { # Fallback to built-in JSON which SHOULD # be available since 5.014 ... @@ -136,55 +125,40 @@ if ($@) { require JSON::PP; import JSON::PP qw(decode_json encode_json); 1; - }; - - if ($@) { - $@ = undef; + } or do { # Fallback to JSON::backportPP in really rare cases require JSON::backportPP; import JSON::backportPP qw(decode_json encode_json); 1; - } - } - } - } -} + }; + }; + }; + }; +}; ## Import der FHEM Funktionen #-- Run before package compilation BEGIN { - # Import from main context GP_Import( qw( - devspec2array - readingsSingleUpdate - readingsBulkUpdate - readingsBulkUpdateIfChanged - readingsBeginUpdate - readingsEndUpdate defs modules - Log3 - CommandAttr attr - CommandDeleteAttr - CommandDeleteReading - CommandSet readingFnAttributes - AttrVal - ReadingsVal - IsDisabled - deviceEvents - init_done - addToDevAttrList - addToAttrList - delFromDevAttrList - delFromAttrList - gettimeofday - InternalTimer - RemoveInternalTimer) + ::AttrVal + ::ReadingsVal + ::IsDisabled + ::deviceEvents + ::init_done + ::addToDevAttrList + ::addToAttrList + ::delFromDevAttrList + ::delFromAttrList + ::gettimeofday + ::InternalTimer + ::RemoveInternalTimer) ); #-- Export to main context with different name @@ -198,6 +172,7 @@ BEGIN { } ## Die Attributsliste welche an die Rolläden verteilt wird. Zusammen mit Default Werten +##no critic our %userAttrList = ( 'ASC_Mode_Up:absent,always,off,home' => '-', 'ASC_Mode_Down:absent,always,off,home' => '-', @@ -227,8 +202,8 @@ our %userAttrList = ( 'ASC_LockOut:soft,hard,off' => '-', 'ASC_LockOut_Cmd:inhibit,blocked,protection' => '-', 'ASC_BlockingTime_afterManual' => '-', - 'ASC_BlockingTime_beforeNightClose' => '-', - 'ASC_BlockingTime_beforeDayOpen' => '-', + 'ASC_BlockingTime_beforeNightClose' => '-', + 'ASC_BlockingTime_beforeDayOpen' => '-', 'ASC_BrightnessSensor' => '-', 'ASC_Shading_Pos:10,20,30,40,50,60,70,80,90,100' => [ '', 80, 20 ], 'ASC_Shading_Mode:absent,always,off,home' => '-', @@ -267,6 +242,11 @@ our %userAttrList = ( 'ASC_SlatPosCmd_SlatDevice' => '-', ); +## 2 Objekte werden erstellt +our $shutters = FHEM::Automation::ShuttersControl::Shutters->new(); +our $ascDev = FHEM::Automation::ShuttersControl::Dev->new(); +##use critic + my %posSetCmds = ( ZWave => 'dim', Siro => 'pct', @@ -284,10 +264,6 @@ my %posSetCmds = ( EnOcean => 'position', ); -## 2 Objekte werden erstellt -our $shutters = FHEM::Automation::ShuttersControl::Shutters->new(); -our $ascDev = FHEM::Automation::ShuttersControl::Dev->new(); - sub ascAPIget { my $getCommand = shift; my $shutterDev = shift; @@ -331,12 +307,14 @@ sub ascAPIset { sub Define { my $hash = shift // return; my $aArg = shift // return; + my $version; - return $@ if ( !FHEM::Meta::SetInternals($hash) ); - use version 0.60; our $VERSION = FHEM::Meta::Get( $hash, 'version' ); + return $@ unless ( FHEM::Meta::SetInternals($hash) ); + $version = FHEM::Meta::Get( $hash, 'version' ); + our $VERSION = $version; return 'only one AutoShuttersControl instance allowed' - if ( devspec2array('TYPE=AutoShuttersControl') > 1 ) + if ( ::devspec2array('TYPE=AutoShuttersControl') > 1 ) ; # es wird geprüft ob bereits eine Instanz unseres Modules existiert,wenn ja wird abgebrochen return 'too few parameters: define ShuttersControl' if ( scalar( @{$aArg} ) != 2 ); @@ -351,24 +329,24 @@ sub Define { #$hash->{ascDev} = $ascDev; $ascDev->setName($name); - readingsSingleUpdate( + ::readingsSingleUpdate( $hash, 'state', 'please set attribute ASC with value 1 or 2 in all auto controlled shutter devices and then execute \'set DEVICENAME scanForShutters\'', 1 ); - 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' ); - CommandAttr( undef, + ::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' ); + ::CommandAttr( undef, $name . ' devStateIcon { ShuttersControl_DevStateIcon($name) }' ) - if ( AttrVal( $name, 'devStateIcon', 'none' ) eq 'none' ); + if ( ::AttrVal( $name, 'devStateIcon', 'none' ) eq 'none' ); - addToAttrList('ASC:0,1,2','AutoShuttersControl'); + ::addToAttrList( 'ASC:0,1,2', 'AutoShuttersControl' ); - Log3( $name, 3, "AutoShuttersControl ($name) - defined" ); + ::Log3( $name, 3, "AutoShuttersControl ($name) - defined" ); $modules{AutoShuttersControl}{defptr}{ $hash->{MID} } = $hash; @@ -381,11 +359,11 @@ sub Undef { UserAttributs_Readings_ForShutters( $hash, 'del' ) ; # es sollen alle Attribute und Readings in den Rolläden Devices gelöscht werden welche vom Modul angelegt wurden - delFromAttrList('ASC:0,1,2'); + ::delFromAttrList('ASC:0,1,2'); delete( $modules{AutoShuttersControl}{defptr}{ $hash->{MID} } ); - Log3( $name, 3, "AutoShuttersControl ($name) - delete device $name" ); + ::Log3( $name, 3, "AutoShuttersControl ($name) - delete device $name" ); return; } @@ -413,10 +391,10 @@ sub Notify { my $name = $hash->{NAME}; my $devname = $dev->{NAME}; my $devtype = $dev->{TYPE}; - my $events = deviceEvents( $dev, 1 ); + my $events = ::deviceEvents( $dev, 1 ); return if ( !$events ); - Log3( $name, 4, + ::Log3( $name, 4, "AutoShuttersControl ($name) - Devname: " . $devname . " Name: " @@ -426,46 +404,45 @@ sub Notify { if ( ( - grep m{^DEFINED.$name$}xms, - @{$events} && $devname eq 'global' && $init_done - ) - || ( - grep m{^INITIALIZED$}xms, - @{$events} or grep m{^REREADCFG$}xms, - @{$events} or grep m{^MODIFIED.$name$}xms, - @{$events} + grep { /^DEFINED.$name$/ } + @{$events} && $devname eq 'global' && $::init_done ) + || ( grep { /^INITIALIZED$/ } @{$events} + or grep { /^REREADCFG$/ } @{$events} + or grep { /^MODIFIED.$name$/ } @{$events} ) && $devname eq 'global' ) { - readingsSingleUpdate( $hash, 'partyMode', 'off', 0 ) + ::readingsSingleUpdate( $hash, 'partyMode', 'off', 0 ) if ( $ascDev->getPartyMode eq 'none' ); - readingsSingleUpdate( $hash, 'hardLockOut', 'off', 0 ) + ::readingsSingleUpdate( $hash, 'hardLockOut', 'off', 0 ) if ( $ascDev->getHardLockOut eq 'none' ); - readingsSingleUpdate( $hash, 'sunriseTimeWeHoliday', 'off', 0 ) + ::readingsSingleUpdate( $hash, 'sunriseTimeWeHoliday', 'off', 0 ) if ( $ascDev->getSunriseTimeWeHoliday eq 'none' ); - readingsSingleUpdate( $hash, 'selfDefense', 'off', 0 ) + ::readingsSingleUpdate( $hash, 'selfDefense', 'off', 0 ) if ( $ascDev->getSelfDefense eq 'none' ); - readingsSingleUpdate( $hash, 'controlShading', 'off', 0 ) + ::readingsSingleUpdate( $hash, 'controlShading', 'off', 0 ) if ( $ascDev->getAutoShuttersControlShading eq 'none' ); - readingsSingleUpdate( $hash, 'ascEnable', 'on', 0 ) + ::readingsSingleUpdate( $hash, 'ascEnable', 'on', 0 ) if ( $ascDev->getASCenable eq 'none' ); - CommandAttr( undef, + ::CommandAttr( undef, $name . ' devStateIcon { ShuttersControl_DevStateIcon($name) }' ) if ( - AttrVal( + ::AttrVal( $name, 'devStateIcon', '{ ShuttersControl_DevStateIcon($name) }' ) ne '{ ShuttersControl_DevStateIcon($name) }' ); - CommandDeleteAttr( undef, $name . ' event-on-change-reading' ) - if ( AttrVal( $name, 'event-on-change-reading', 'none' ) ne 'none' ); - CommandDeleteAttr( undef, $name . ' event-on-update-reading' ) - if ( AttrVal( $name, 'event-on-update-reading', 'none' ) ne 'none' ); + ::CommandDeleteAttr( undef, $name . ' event-on-change-reading' ) + if ( + ::AttrVal( $name, 'event-on-change-reading', 'none' ) ne 'none' ); + ::CommandDeleteAttr( undef, $name . ' event-on-update-reading' ) + if ( + ::AttrVal( $name, 'event-on-update-reading', 'none' ) ne 'none' ); # 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) - if ( ReadingsVal( $name, 'userAttrList', 'none' ) ne 'none' ); + if ( ::ReadingsVal( $name, 'userAttrList', 'none' ) ne 'none' ); } return if ( ref( $hash->{helper}{shuttersList} ) ne 'ARRAY' @@ -474,49 +451,52 @@ sub Notify { my $posReading = $shutters->getPosCmd; if ( $devname eq $name ) { - if ( grep m{^userAttrList:.rolled.out$}xms, @{$events} ) { + if ( grep { /^userAttrList:.rolled.out$/ } @{$events} ) { if ( scalar( @{ $hash->{helper}{shuttersList} } ) > 0 ) { WriteReadingsShuttersList($hash); UserAttributs_Readings_ForShutters( $hash, 'add' ); - InternalTimer( - gettimeofday() + 3, + ::InternalTimer( + ::gettimeofday() + 3, 'FHEM::Automation::ShuttersControl::RenewSunRiseSetShuttersTimer', $hash ); - InternalTimer( - gettimeofday() + 5, + ::InternalTimer( + ::gettimeofday() + 5, 'FHEM::Automation::ShuttersControl::AutoSearchTwilightDev', $hash ); - InternalTimer( - gettimeofday() + 5, - sub() { CommandSet( undef, $name . ' controlShading on' ) }, + ::InternalTimer( + ::gettimeofday() + 5, + sub() { + ::CommandSet( undef, $name . ' controlShading on' ); + }, $hash ) - if ( ReadingsVal( $name, 'controlShading', 'off' ) ne 'off' ); + if ( + ::ReadingsVal( $name, 'controlShading', 'off' ) ne 'off' ); } } - elsif ( grep m{^partyMode:.off$}xms, @{$events} ) { + elsif ( grep { /^partyMode:.off$/ } @{$events} ) { EventProcessingPartyMode($hash); } - elsif ( grep m{^sunriseTimeWeHoliday:.(on|off)$}xms, @{$events} ) { + elsif ( grep { /^sunriseTimeWeHoliday:.(on|off)$/ } @{$events} ) { RenewSunRiseSetShuttersTimer($hash); } } elsif ( $devname eq "global" ) { # Kommt ein globales Event und beinhaltet folgende Syntax wird die Funktion zur Verarbeitung aufgerufen if ( - grep -m{^(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_PrivacyDownValue_beforeNightClose|.*ASC_PrivacyUpValue_beforeDayOpen|.*ASC_autoAstroModeEvening|.*ASC_autoAstroModeEveningHorizon|.*ASC_Roommate_Device|.*ASC_WindowRec|.*ASC_residentsDev|.*ASC_rainSensor|.*ASC_windSensor|.*ASC_tempSensor|.*ASC_BrightnessSensor|.*ASC_twilightDevice|.*ASC_ExternalTrigger|.*ASC_Shading_StateChange_SunnyCloudy|.*ASC_TempSensor|.*ASC_Shading_Mode)(\s.*|$)}xms, - @{$events} + grep { +/^(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_PrivacyDownValue_beforeNightClose|.*ASC_PrivacyUpValue_beforeDayOpen|.*ASC_autoAstroModeEvening|.*ASC_autoAstroModeEveningHorizon|.*ASC_Roommate_Device|.*ASC_WindowRec|.*ASC_residentsDev|.*ASC_rainSensor|.*ASC_windSensor|.*ASC_tempSensor|.*ASC_BrightnessSensor|.*ASC_twilightDevice|.*ASC_ExternalTrigger|.*ASC_Shading_StateChange_SunnyCloudy|.*ASC_TempSensor|.*ASC_Shading_Mode)(\s.*|$) / + } @{$events} ) { EventProcessingGeneral( $hash, undef, join( ' ', @{$events} ) ); } } - elsif ( grep m{^($posReading):\s\d{1,3}(\.\d{1,3})?$}xms, @{$events} ) { + elsif ( grep { /^($posReading):\s\d{1,3}(\.\d{1,3})?$/ } @{$events} ) { ASC_Debug( 'Notify: ' - . ' ASC_Pos_Reading Event vom Rollo ' + . ' ASC_Pos_Reading Event vom Rollo ' . $devname . ' wurde erkannt ' . ' - RECEIVED EVENT: ' @@ -539,104 +519,111 @@ sub Set { my $cmd = shift @$aArg // return qq{"set $name" needs at least one argument}; - if ( lc $cmd eq 'renewalltimer' ) { - return "usage: $cmd" if ( scalar( @{$aArg} ) != 0 ); - RenewSunRiseSetShuttersTimer($hash); - } - elsif ( lc $cmd eq 'renewtimer' ) { - return "usage: $cmd" if ( scalar( @{$aArg} ) > 1 ); - CreateSunRiseSetShuttersTimer( $hash, $aArg->[0] ); - } - elsif ( lc $cmd eq 'scanforshutters' ) { - return "usage: $cmd" if ( scalar( @{$aArg} ) != 0 ); - ShuttersDeviceScan($hash); - } - elsif ( lc $cmd eq 'createnewnotifydev' ) { - return "usage: $cmd" if ( scalar( @{$aArg} ) != 0 ); - CreateNewNotifyDev($hash); - } - elsif ( lc $cmd eq 'partymode' ) { - return "usage: $cmd" if ( scalar( @{$aArg} ) > 1 ); - readingsSingleUpdate( $hash, $cmd, $aArg->[0], 1 ) - if ( $aArg->[0] ne ReadingsVal( $name, 'partyMode', 0 ) ); - } - elsif ( lc $cmd eq 'hardlockout' ) { - return "usage: $cmd" if ( scalar( @{$aArg} ) > 1 ); - readingsSingleUpdate( $hash, $cmd, $aArg->[0], 1 ); - HardewareBlockForShutters( $hash, $aArg->[0] ); - } - elsif ( lc $cmd eq 'sunrisetimeweholiday' ) { - return "usage: $cmd" if ( scalar( @{$aArg} ) > 1 ); - readingsSingleUpdate( $hash, $cmd, $aArg->[0], 1 ); - } - elsif ( lc $cmd eq 'controlshading' ) { - return "usage: $cmd" if ( scalar( @{$aArg} ) > 1 ); + $cmd = lc($cmd); - my $response = CheckASC_ConditionsForShadingFn($hash,$aArg->[0]); - readingsSingleUpdate( - $hash, $cmd, - ( - $aArg->[0] eq 'off' ? $aArg->[0] - : ( - $response eq 'none' ? $aArg->[0] - : $response - ) - ), - 1 - ); - } - elsif ( lc $cmd eq 'selfdefense' ) { - return "usage: $cmd" if ( scalar( @{$aArg} ) > 1 ); - readingsSingleUpdate( $hash, $cmd, $aArg->[0], 1 ); - } - elsif ( lc $cmd eq 'ascenable' ) { - return "usage: $cmd" if ( scalar( @{$aArg} ) > 1 ); - readingsSingleUpdate( $hash, $cmd, $aArg->[0], 1 ); - } - elsif ( lc $cmd eq 'advdrivedown' ) { - return "usage: $cmd" if ( scalar( @{$aArg} ) != 0 ); - EventProcessingAdvShuttersClose($hash); - } - elsif ( lc $cmd eq 'shutterascenabletoggle' ) { - return "usage: $cmd" if ( scalar( @{$aArg} ) > 1 ); - readingsSingleUpdate( - $defs{ $aArg->[0] }, - 'ASC_Enable', - ( - ReadingsVal( $aArg->[0], 'ASC_Enable', 'off' ) eq 'on' - ? 'off' - : 'on' - ), - 1 - ); - } - elsif ( lc $cmd eq 'wiggle' ) { - return "usage: $cmd" if ( scalar( @{$aArg} ) > 1 ); + given ($cmd) { + when ('renewalltimer') { + return "usage: $cmd" if ( scalar( @{$aArg} ) != 0 ); + RenewSunRiseSetShuttersTimer($hash); + } + when ('renewtimer') { + return "usage: $cmd" if ( scalar( @{$aArg} ) > 1 ); + CreateSunRiseSetShuttersTimer( $hash, $aArg->[0] ); + } + when ('scanforshutters') { + return "usage: $cmd" if ( scalar( @{$aArg} ) != 0 ); + ShuttersDeviceScan($hash); + } + when ('createnewnotifydev') { + return "usage: $cmd" if ( scalar( @{$aArg} ) != 0 ); + CreateNewNotifyDev($hash); + } + when ('partymode') { + return "usage: $cmd" if ( scalar( @{$aArg} ) > 1 ); + ::readingsSingleUpdate( $hash, $cmd, $aArg->[0], 1 ) + if ( $aArg->[0] ne ::ReadingsVal( $name, 'partyMode', 0 ) ); + } + when ('hardlockout') { + return "usage: $cmd" if ( scalar( @{$aArg} ) > 1 ); + ::readingsSingleUpdate( $hash, $cmd, $aArg->[0], 1 ); + HardewareBlockForShutters( $hash, $aArg->[0] ); + } + when ('sunrisetimeweholiday') { + return "usage: $cmd" if ( scalar( @{$aArg} ) > 1 ); + ::readingsSingleUpdate( $hash, $cmd, $aArg->[0], 1 ); + } + when ('controlshading') { + return "usage: $cmd" if ( scalar( @{$aArg} ) > 1 ); - ( - $aArg->[0] eq 'all' - ? wiggleAll($hash) - : wiggle( $hash, $aArg->[0] ) - ); - } - else { - my $list = 'scanForShutters:noArg'; - $list .= + my $response = CheckASC_ConditionsForShadingFn( $hash, $aArg->[0] ); + ::readingsSingleUpdate( + $hash, $cmd, + ( + $aArg->[0] eq 'off' ? $aArg->[0] + : ( + $response eq 'none' ? $aArg->[0] + : $response + ) + ), + 1 + ); + } + when ('selfdefense') { + return "usage: $cmd" if ( scalar( @{$aArg} ) > 1 ); + ::readingsSingleUpdate( $hash, $cmd, $aArg->[0], 1 ); + } + when ('ascenable') { + return "usage: $cmd" if ( scalar( @{$aArg} ) > 1 ); + ::readingsSingleUpdate( $hash, $cmd, $aArg->[0], 1 ); + } + when ('advdrivedown') { + return "usage: $cmd" if ( scalar( @{$aArg} ) != 0 ); + EventProcessingAdvShuttersClose($hash); + } + when ('shutterascenabletoggle') { + return "usage: $cmd" if ( scalar( @{$aArg} ) > 1 ); + ::readingsSingleUpdate( + $defs{ $aArg->[0] }, + 'ASC_Enable', + ( + ::ReadingsVal( $aArg->[0], 'ASC_Enable', 'off' ) eq 'on' + ? 'off' + : 'on' + ), + 1 + ); + } + when ('wiggle') { + return "usage: $cmd" if ( scalar( @{$aArg} ) > 1 ); + + ( + $aArg->[0] eq 'all' + ? wiggleAll($hash) + : wiggle( $hash, $aArg->[0] ) + ); + } + default { + my $list = 'scanForShutters:noArg'; + $list .= ' renewAllTimer:noArg advDriveDown:noArg partyMode:on,off hardLockOut:on,off sunriseTimeWeHoliday:on,off controlShading:on,off selfDefense:on,off ascEnable:on,off wiggle:all,' - . join( ',', @{ $hash->{helper}{shuttersList} } ) - . ' shutterASCenableToggle:' - . join( ',', @{ $hash->{helper}{shuttersList} } ) - . ' renewTimer:' - . join( ',', @{ $hash->{helper}{shuttersList} } ) - if ( ReadingsVal( $name, 'userAttrList', 'none' ) eq 'rolled out' - && defined( $hash->{helper}{shuttersList} ) - && scalar( @{ $hash->{helper}{shuttersList} } ) > 0 ); - $list .= ' createNewNotifyDev:noArg' - if ( ReadingsVal( $name, 'userAttrList', 'none' ) eq 'rolled out' - && AttrVal( $name, 'ASC_expert', 0 ) == 1 ); + . join( ',', @{ $hash->{helper}{shuttersList} } ) + . ' shutterASCenableToggle:' + . join( ',', @{ $hash->{helper}{shuttersList} } ) + . ' renewTimer:' + . join( ',', @{ $hash->{helper}{shuttersList} } ) + if ( + ::ReadingsVal( $name, 'userAttrList', 'none' ) eq 'rolled out' + && defined( $hash->{helper}{shuttersList} ) + && scalar( @{ $hash->{helper}{shuttersList} } ) > 0 ); + $list .= ' createNewNotifyDev:noArg' + if ( + ::ReadingsVal( $name, 'userAttrList', 'none' ) eq 'rolled out' + && ::AttrVal( $name, 'ASC_expert', 0 ) == 1 ); - return "Unknown argument $cmd,choose one of $list"; + return "Unknown argument $cmd,choose one of $list"; + } } + return; } @@ -656,8 +643,8 @@ sub Get { else { my $list = ""; $list .= " showNotifyDevsInformations:noArg" - if ( ReadingsVal( $name, 'userAttrList', 'none' ) eq 'rolled out' - && AttrVal( $name, 'ASC_expert', 0 ) == 1 ); + if ( ::ReadingsVal( $name, 'userAttrList', 'none' ) eq 'rolled out' + && ::AttrVal( $name, 'ASC_expert', 0 ) == 1 ); return "Unknown argument $cmd,choose one of $list"; } @@ -671,15 +658,15 @@ sub ShuttersDeviceScan { delete $hash->{helper}{shuttersList}; my @list; - @list = devspec2array('ASC=[1-2]'); + @list = ::devspec2array('ASC=[1-2]'); - CommandDeleteReading( undef, $name . ' .*_nextAstroTimeEvent' ); + ::CommandDeleteReading( undef, $name . ' .*_nextAstroTimeEvent' ); if ( scalar(@list) == 0 ) { - readingsBeginUpdate($hash); - readingsBulkUpdate( $hash, 'userAttrList', 'none' ); - readingsBulkUpdate( $hash, 'state', 'no shutters found' ); - readingsEndUpdate( $hash, 1 ); + ::readingsBeginUpdate($hash); + ::readingsBulkUpdate( $hash, 'userAttrList', 'none' ); + ::readingsBulkUpdate( $hash, 'state', 'no shutters found' ); + ::readingsEndUpdate( $hash, 1 ); return; } my $shuttersList = ''; @@ -694,24 +681,25 @@ sub ShuttersDeviceScan { #### vorher empfiehlt es sich die dort vergebenen Parameter aus zu lesen um sie dann hier wieder neu zu setzen. Dazu wird das shutters Objekt um einen Eintrag #### 'AttrUpdateChanges' erweitert if ( - ReadingsVal( + ::ReadingsVal( $shuttersDev, '.ASC_AttrUpdateChanges_' . $hash->{VERSION}, 0 ) == 0 ) { $shutters->setAttrUpdateChanges( 'ASC_ShuttersPlace', - AttrVal( $shuttersDev, 'ASC_ShuttersPlace', 'none' ) ); - delFromDevAttrList( $shuttersDev, 'ASC_ShuttersPlace' ); + ::AttrVal( $shuttersDev, 'ASC_ShuttersPlace', 'none' ) ); + ::delFromDevAttrList( $shuttersDev, 'ASC_ShuttersPlace' ); + # $shutters->setAttrUpdateChanges( 'ASC_Down', -# AttrVal( $shuttersDev, 'ASC_Down', 'none' ) ); -# delFromDevAttrList( $shuttersDev, 'ASC_Down' ); +# ::AttrVal( $shuttersDev, 'ASC_Down', 'none' ) ); +# ::delFromDevAttrList( $shuttersDev, 'ASC_Down' ); # $shutters->setAttrUpdateChanges( 'ASC_Self_Defense_Mode', -# AttrVal( $shuttersDev, 'ASC_Self_Defense_Mode', 'none' ) ); -# delFromDevAttrList( $shuttersDev, 'ASC_Self_Defense_Mode' ); +# ::AttrVal( $shuttersDev, 'ASC_Self_Defense_Mode', 'none' ) ); +# ::delFromDevAttrList( $shuttersDev, 'ASC_Self_Defense_Mode' ); # $shutters->setAttrUpdateChanges( 'ASC_Self_Defense_Exclude', -# AttrVal( $shuttersDev, 'ASC_Self_Defense_Exclude', 'none' ) ); -# delFromDevAttrList( $shuttersDev, 'ASC_Self_Defense_Exclude' ); +# ::AttrVal( $shuttersDev, 'ASC_Self_Defense_Exclude', 'none' ) ); +# ::delFromDevAttrList( $shuttersDev, 'ASC_Self_Defense_Exclude' ); } #### @@ -732,8 +720,8 @@ sub ShuttersDeviceScan { # ( $shutters->getStatus != $shutters->getShadingPos ? 'in' : 'out' ) # ); $shutters->setPushBrightnessInArray( $shutters->getBrightness ); - readingsSingleUpdate( $defs{$shuttersDev}, 'ASC_Enable', 'on', 0 ) - if ( ReadingsVal( $shuttersDev, 'ASC_Enable', 'none' ) eq 'none' ); + ::readingsSingleUpdate( $defs{$shuttersDev}, 'ASC_Enable', 'on', 0 ) + if ( ::ReadingsVal( $shuttersDev, 'ASC_Enable', 'none' ) eq 'none' ); if ( $shutters->getIsDay ) { $shutters->setSunrise(1); @@ -757,7 +745,7 @@ sub ShuttersDeviceScan { $hash->{NOTIFYDEV} = $notifyDevString; } - readingsSingleUpdate( $hash, 'userAttrList', 'rolled out', 1 ); + ::readingsSingleUpdate( $hash, 'userAttrList', 'rolled out', 1 ); return; } @@ -768,19 +756,21 @@ sub WriteReadingsShuttersList { my $name = $hash->{NAME}; - CommandDeleteReading( undef, $name . ' room_.*' ); + ::CommandDeleteReading( undef, $name . ' room_.*' ); - readingsBeginUpdate($hash); + ::readingsBeginUpdate($hash); for my $shuttersDev ( @{ $hash->{helper}{shuttersList} } ) { - readingsBulkUpdate( + ::readingsBulkUpdate( $hash, 'room_' - . ::makeReadingName( AttrVal( $shuttersDev, 'room', 'unsorted' ) ), - ReadingsVal( + . ::makeReadingName( + ::AttrVal( $shuttersDev, 'room', 'unsorted' ) + ), + ::ReadingsVal( $name, 'room_' . ::makeReadingName( - AttrVal( $shuttersDev, 'room', 'unsorted' ) + ::AttrVal( $shuttersDev, 'room', 'unsorted' ) ), '' ) @@ -788,35 +778,37 @@ sub WriteReadingsShuttersList { . $shuttersDev ) if ( - ReadingsVal( + ::ReadingsVal( $name, 'room_' . ::makeReadingName( - AttrVal( $shuttersDev, 'room', 'unsorted' ) + ::AttrVal( $shuttersDev, 'room', 'unsorted' ) ), 'none' ) ne 'none' ); - readingsBulkUpdate( + ::readingsBulkUpdate( $hash, 'room_' - . ::makeReadingName( AttrVal( $shuttersDev, 'room', 'unsorted' ) ), + . ::makeReadingName( + ::AttrVal( $shuttersDev, 'room', 'unsorted' ) + ), $shuttersDev ) if ( - ReadingsVal( + ::ReadingsVal( $name, 'room_' . ::makeReadingName( - AttrVal( $shuttersDev, 'room', 'unsorted' ) + ::AttrVal( $shuttersDev, 'room', 'unsorted' ) ), 'none' ) eq 'none' ); } - readingsBulkUpdate( $hash, 'state', 'active' ); - readingsEndUpdate( $hash, 0 ); + ::readingsBulkUpdate( $hash, 'state', 'active' ); + ::readingsEndUpdate( $hash, 0 ); return; } @@ -829,7 +821,7 @@ sub UserAttributs_Readings_ForShutters { while ( my ( $attrib, $attribValue ) = each %{userAttrList} ) { for my $shuttersDev ( @{ $hash->{helper}{shuttersList} } ) { - addToDevAttrList( $shuttersDev, $attrib, 'AutoShuttersControl' ) + ::addToDevAttrList( $shuttersDev, $attrib, 'AutoShuttersControl' ) ; ## 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 ## Danach werden die Attribute die im userAttr stehen gesetzt und mit default Werten befüllt ## CommandAttr hat nicht funktioniert. Führte zu Problemen @@ -847,7 +839,7 @@ sub UserAttributs_Readings_ForShutters { } else { $attr{$shuttersDev}{ ( split( ':', $attrib ) )[0] } = - $attribValue->[ AttrVal( $shuttersDev, 'ASC', 2 ) ] + $attribValue->[ ::AttrVal( $shuttersDev, 'ASC', 2 ) ] if ( !defined( $attr{$shuttersDev}{ ( split( ':', $attrib ) )[0] } @@ -858,17 +850,17 @@ sub UserAttributs_Readings_ForShutters { ### associatedWith damit man sieht das der Rollladen mit einem ASC Device verbunden ist my $associatedString = - ReadingsVal( $shuttersDev, 'associatedWith', 'none' ); + ::ReadingsVal( $shuttersDev, 'associatedWith', 'none' ); if ( $associatedString ne 'none' ) { my %hash; %hash = map { ( $_ => 1 ) } split( ',', "$associatedString,$name" ); - readingsSingleUpdate( $defs{$shuttersDev}, + ::readingsSingleUpdate( $defs{$shuttersDev}, 'associatedWith', join( ',', sort keys %hash ), 0 ); } else { - readingsSingleUpdate( $defs{$shuttersDev}, + ::readingsSingleUpdate( $defs{$shuttersDev}, 'associatedWith', $name, 0 ); } ####################################### @@ -877,25 +869,25 @@ sub UserAttributs_Readings_ForShutters { elsif ( $cmd eq 'del' ) { $shutters->setShuttersDev($shuttersDev); - RemoveInternalTimer( $shutters->getInTimerFuncHash ); - CommandDeleteReading( undef, $shuttersDev . ' .?(ASC)_.*' ); - CommandDeleteAttr( undef, $shuttersDev . ' ASC' ); - delFromDevAttrList( $shuttersDev, $attrib ); + ::RemoveInternalTimer( $shutters->getInTimerFuncHash ); + ::CommandDeleteReading( undef, $shuttersDev . ' .?(ASC)_.*' ); + ::CommandDeleteAttr( undef, $shuttersDev . ' ASC' ); + ::delFromDevAttrList( $shuttersDev, $attrib ); ### associatedWith wird wieder entfernt my $associatedString = - ReadingsVal( $shuttersDev, 'associatedWith', 'none' ); + ::ReadingsVal( $shuttersDev, 'associatedWith', 'none' ); my %hash; %hash = map { ( $_ => 1 ) } grep { " $name " !~ m{ $shuttersDev }xms } split( ',', "$associatedString,$name" ); if ( keys %hash > 1 ) { - readingsSingleUpdate( $defs{$shuttersDev}, + ::readingsSingleUpdate( $defs{$shuttersDev}, 'associatedWith', join( ',', sort keys %hash ), 0 ); } else { - CommandDeleteReading( undef, + ::CommandDeleteReading( undef, $shuttersDev . ' associatedWith' ); } ################################### @@ -932,7 +924,7 @@ sub AddNotifyDev { $hash->{monitoredDevs}{$dev}{$shuttersDev} = $shuttersAttr; } - readingsSingleUpdate( $hash, '.monitoredDevs', + ::readingsSingleUpdate( $hash, '.monitoredDevs', eval { encode_json( $hash->{monitoredDevs} ) }, 0 ); return; @@ -950,7 +942,7 @@ sub DeleteNotifyDev { ExtractNotifyDevFromEvent( $hash, $shuttersDev, $shuttersAttr ); for my $notifyDev ( keys( %{$notifyDevs} ) ) { - Log3( $name, 4, + ::Log3( $name, 4, "AutoShuttersControl ($name) - DeleteNotifyDev - NotifyDev: " . $notifyDev ); delete $hash->{monitoredDevs}{$notifyDev}{$shuttersDev}; @@ -967,7 +959,7 @@ sub DeleteNotifyDev { $hash->{NOTIFYDEV} = join( ',', sort keys %hash ); } } - readingsSingleUpdate( $hash, '.monitoredDevs', + ::readingsSingleUpdate( $hash, '.monitoredDevs', eval { encode_json( $hash->{monitoredDevs} ) }, 0 ); return; @@ -1014,11 +1006,13 @@ sub ShuttersCommandSet { || $shutters->getLockOut eq 'hard' ) && !$shutters->getQueryShuttersPos($posValue) ) - || ( CheckIfShuttersWindowRecOpen($shuttersDev) == 2 + || ( + CheckIfShuttersWindowRecOpen($shuttersDev) == 2 && $shutters->getShuttersPlace eq 'terrace' && !$shutters->getQueryShuttersPos($posValue) && ( $shutters->getLockOut eq 'soft' - || $shutters->getLockOut eq 'hard' ) ) + || $shutters->getLockOut eq 'hard' ) + ) || ( $shutters->getRainProtectionStatus eq 'protected' || $shutters->getWindProtectionStatus eq 'protected' ) ) @@ -1027,7 +1021,7 @@ sub ShuttersCommandSet { $shutters->setDelayCmd($posValue); $ascDev->setDelayCmdReading; $shutters->setNoDelay(0); - Log3( $name, 4, + ::Log3( $name, 4, "AutoShuttersControl ($name) - ShuttersCommandSet in Delay" ); ASC_Debug( 'FnShuttersCommandSet: ' @@ -1038,7 +1032,7 @@ sub ShuttersCommandSet { else { $shutters->setDriveCmd($posValue); $ascDev->setLastPosReading; - Log3( $name, 4, + ::Log3( $name, 4, "AutoShuttersControl ($name) - ShuttersCommandSet setDriveCmd wird aufgerufen" ); @@ -1054,28 +1048,30 @@ sub ShuttersCommandSet { ## Sub welche die InternalTimer nach entsprechenden Sunset oder Sunrise zusammen stellt sub CreateSunRiseSetShuttersTimer { my $hash = shift; - my $shuttersDev = shift // return Log3( $hash->{NAME}, 1, + my $shuttersDev = shift // return ::Log3( $hash->{NAME}, 1, "AutoShuttersControl ($hash->{NAME}) - Error in function CreateSunRiseSetShuttersTimer. No shuttersDev given" ); my $name = $hash->{NAME}; - my $shuttersDevHash = $defs{$shuttersDev} // return Log3( $hash->{NAME}, 1, + my $shuttersDevHash = $defs{$shuttersDev} // return ::Log3( + $hash->{NAME}, + 1, "AutoShuttersControl ($hash->{NAME}) - Error in function CreateSunRiseSetShuttersTimer. No shuttersDevHash found for device name $shuttersDev" ); my %funcHash; $shutters->setShuttersDev($shuttersDev); - return if ( IsDisabled($name) ); + return if ( ::IsDisabled($name) ); my $shuttersSunriseUnixtime = ShuttersSunrise( $shuttersDev, 'unix' ) + 1; - my $shuttersSunsetUnixtime = ShuttersSunset( $shuttersDev, 'unix' ) + 1; + my $shuttersSunsetUnixtime = ShuttersSunset( $shuttersDev, 'unix' ) + 1; $shutters->setSunriseUnixTime($shuttersSunriseUnixtime); $shutters->setSunsetUnixTime($shuttersSunsetUnixtime); ## In jedem Rolladen werden die errechneten Zeiten hinterlegt,es sei denn das autoShuttersControlEvening/Morning auf off steht - readingsBeginUpdate($shuttersDevHash); - readingsBulkUpdate( + ::readingsBeginUpdate($shuttersDevHash); + ::readingsBulkUpdate( $shuttersDevHash, 'ASC_Time_DriveDown', ( @@ -1089,7 +1085,7 @@ sub CreateSunRiseSetShuttersTimer { : 'AutoShuttersControl off' ) ); - readingsBulkUpdate( + ::readingsBulkUpdate( $shuttersDevHash, 'ASC_Time_DriveUp', ( @@ -1103,10 +1099,10 @@ sub CreateSunRiseSetShuttersTimer { : 'AutoShuttersControl off' ) ); - readingsEndUpdate( $shuttersDevHash, 0 ); + ::readingsEndUpdate( $shuttersDevHash, 0 ); - readingsBeginUpdate($hash); - readingsBulkUpdateIfChanged( + ::readingsBeginUpdate($hash); + ::readingsBulkUpdateIfChanged( $hash, $shuttersDev . '_nextAstroTimeEvent', ( @@ -1118,9 +1114,9 @@ sub CreateSunRiseSetShuttersTimer { ) ) ); - readingsEndUpdate( $hash, 1 ); + ::readingsEndUpdate( $hash, 1 ); - RemoveInternalTimer( $shutters->getInTimerFuncHash ) + ::RemoveInternalTimer( $shutters->getInTimerFuncHash ) if ( defined( $shutters->getInTimerFuncHash ) ); ## Setzt den Privacy Modus für die Sichtschutzfahrt auf den Status 0 @@ -1137,8 +1133,10 @@ sub CreateSunRiseSetShuttersTimer { PrivacyUpTime( $shuttersDevHash, $shuttersSunriseUnixtime ); } else { - CommandDeleteReading( undef, $shuttersDev . ' ASC_Time_PrivacyDriveUp' ) - if ( ReadingsVal( $shuttersDev, 'ASC_Time_PrivacyDriveUp', 'none' ) ne + ::CommandDeleteReading( undef, + $shuttersDev . ' ASC_Time_PrivacyDriveUp' ) + if ( + ::ReadingsVal( $shuttersDev, 'ASC_Time_PrivacyDriveUp', 'none' ) ne 'none' ); } @@ -1148,11 +1146,11 @@ sub CreateSunRiseSetShuttersTimer { PrivacyDownTime( $shuttersDevHash, $shuttersSunsetUnixtime ); } else { - CommandDeleteReading( undef, + ::CommandDeleteReading( undef, $shuttersDev . ' ASC_Time_PrivacyDriveDown' ) if ( - ReadingsVal( $shuttersDev, 'ASC_Time_PrivacyDriveDown', 'none' ) ne - 'none' ); + ::ReadingsVal( $shuttersDev, 'ASC_Time_PrivacyDriveDown', 'none' ) + ne 'none' ); } ## kleine Hilfe für InternalTimer damit ich alle benötigten Variablen an die Funktion übergeben kann welche von Internal Timer aufgerufen wird. @@ -1165,9 +1163,9 @@ sub CreateSunRiseSetShuttersTimer { ## Ich brauche beim löschen des InternalTimer den Hash welchen ich mitgegeben habe,dieser muss gesichert werden $shutters->setInTimerFuncHash( \%funcHash ); - InternalTimer( $shuttersSunsetUnixtime, \&SunSetShuttersAfterTimerFn, + ::InternalTimer( $shuttersSunsetUnixtime, \&SunSetShuttersAfterTimerFn, \%funcHash ); - InternalTimer( $shuttersSunriseUnixtime, \&SunRiseShuttersAfterTimerFn, + ::InternalTimer( $shuttersSunriseUnixtime, \&SunRiseShuttersAfterTimerFn, \%funcHash ); $ascDev->setStateReading('created new drive timer'); @@ -1184,7 +1182,7 @@ sub RenewSunRiseSetShuttersTimer { $shutters->setShuttersDev($shuttersDev); - RemoveInternalTimer( $shutters->getInTimerFuncHash ); + ::RemoveInternalTimer( $shutters->getInTimerFuncHash ); $shutters->setInTimerFuncHash(undef); CreateSunRiseSetShuttersTimer( $hash, $shuttersDev ); @@ -1193,15 +1191,18 @@ sub RenewSunRiseSetShuttersTimer { #### vorher empfiehlt es sich die dort vergebenen Parameter aus zu lesen um sie dann hier wieder neu zu setzen. Dazu wird das shutters Objekt um einen Eintrag #### 'AttrUpdateChanges' erweitert if ( - ( int( gettimeofday() ) - $::fhem_started ) < 60 - and ReadingsVal( + ( int( ::gettimeofday() ) - $::fhem_started ) < 60 + and ::ReadingsVal( $shuttersDev, '.ASC_AttrUpdateChanges_' . $hash->{VERSION}, 0 ) == 0 ) { - $attr{$shuttersDev}{'ASC_ShuttersPlace'} = $shutters->getAttrUpdateChanges('ASC_ShuttersPlace') - if ( $shutters->getAttrUpdateChanges('ASC_ShuttersPlace') ne 'none' ); + $attr{$shuttersDev}{'ASC_ShuttersPlace'} = + $shutters->getAttrUpdateChanges('ASC_ShuttersPlace') + if ( $shutters->getAttrUpdateChanges('ASC_ShuttersPlace') ne + 'none' ); + # $attr{$shuttersDev}{'ASC_Down'} = # $shutters->getAttrUpdateChanges('ASC_Down') # if ( $shutters->getAttrUpdateChanges('ASC_Down') ne 'none' ); @@ -1214,59 +1215,65 @@ sub RenewSunRiseSetShuttersTimer { # $shutters->getAttrUpdateChanges('ASC_Self_Defense_Exclude') eq # 'on' ); - CommandDeleteReading( undef, + ::CommandDeleteReading( undef, $shuttersDev . ' .ASC_AttrUpdateChanges_.*' ) if ( - ReadingsVal( $shuttersDev, + ::ReadingsVal( $shuttersDev, '.ASC_AttrUpdateChanges_' . $hash->{VERSION}, 'none' ) eq 'none' ); - readingsSingleUpdate( $dhash, + ::readingsSingleUpdate( $dhash, '.ASC_AttrUpdateChanges_' . $hash->{VERSION}, 1, 0 ); } $attr{$shuttersDev}{ASC_BlockingTime_beforeNightClose} = - AttrVal( $shuttersDev, 'ASC_BlockingTime_beforNightClose', 'none' ) - if ( AttrVal( $shuttersDev, 'ASC_BlockingTime_beforNightClose', 'none' ) ne 'none' ); - delFromDevAttrList( $shuttersDev, 'ASC_BlockingTime_beforNightClose' ); + ::AttrVal( $shuttersDev, 'ASC_BlockingTime_beforNightClose', 'none' ) + if ( + ::AttrVal( $shuttersDev, 'ASC_BlockingTime_beforNightClose', + 'none' ) ne 'none' + ); + ::delFromDevAttrList( $shuttersDev, + 'ASC_BlockingTime_beforNightClose' ); $attr{$shuttersDev}{ASC_BlockingTime_beforeDayOpen} = - AttrVal( $shuttersDev, 'ASC_BlockingTime_beforDayOpen', 'none' ) - if ( AttrVal( $shuttersDev, 'ASC_BlockingTime_beforDayOpen', 'none' ) ne 'none' ); - delFromDevAttrList( $shuttersDev, 'ASC_BlockingTime_beforDayOpen' ); + ::AttrVal( $shuttersDev, 'ASC_BlockingTime_beforDayOpen', 'none' ) + if ( + ::AttrVal( $shuttersDev, 'ASC_BlockingTime_beforDayOpen', 'none' ) + ne 'none' ); + ::delFromDevAttrList( $shuttersDev, 'ASC_BlockingTime_beforDayOpen' ); # # $attr{$shuttersDev}{ASC_Shading_StateChange_SunnyCloudy} = -# AttrVal( $shuttersDev, 'ASC_Shading_StateChange_Sunny', 'none' ) . ':' -# . AttrVal( $shuttersDev, 'ASC_Shading_StateChange_Cloudy', 'none' ) +# ::AttrVal( $shuttersDev, 'ASC_Shading_StateChange_Sunny', 'none' ) . ':' +# . ::AttrVal( $shuttersDev, 'ASC_Shading_StateChange_Cloudy', 'none' ) # if ( -# AttrVal( $shuttersDev, 'ASC_Shading_StateChange_Sunny', 'none' ) ne 'none' -# && AttrVal( $shuttersDev, 'ASC_Shading_StateChange_Cloudy', 'none' ) ne +# ::AttrVal( $shuttersDev, 'ASC_Shading_StateChange_Sunny', 'none' ) ne 'none' +# && ::AttrVal( $shuttersDev, 'ASC_Shading_StateChange_Cloudy', 'none' ) ne # 'none' ); -# delFromDevAttrList( $shuttersDev, 'ASC_Shading_StateChange_Sunny' ); -# delFromDevAttrList( $shuttersDev, 'ASC_Shading_StateChange_Cloudy' ); +# ::delFromDevAttrList( $shuttersDev, 'ASC_Shading_StateChange_Sunny' ); +# ::delFromDevAttrList( $shuttersDev, 'ASC_Shading_StateChange_Cloudy' ); # # $attr{$shuttersDev}{ASC_Shading_InOutAzimuth} = -# ( AttrVal( $shuttersDev, 'ASC_Shading_Direction', 180 ) - -# AttrVal( $shuttersDev, 'ASC_Shading_Angle_Left', 85 ) ) +# ( ::AttrVal( $shuttersDev, 'ASC_Shading_Direction', 180 ) - +# ::AttrVal( $shuttersDev, 'ASC_Shading_Angle_Left', 85 ) ) # . ':' -# . ( AttrVal( $shuttersDev, 'ASC_Shading_Direction', 180 ) + -# AttrVal( $shuttersDev, 'ASC_Shading_Angle_Right', 85 ) ) -# if ( AttrVal( $shuttersDev, 'ASC_Shading_Direction', 'none' ) ne 'none' -# || AttrVal( $shuttersDev, 'ASC_Shading_Angle_Left', 'none' ) ne 'none' -# || AttrVal( $shuttersDev, 'ASC_Shading_Angle_Right', 'none' ) ne 'none' ); -# delFromDevAttrList( $shuttersDev, 'ASC_Shading_Direction' ); -# delFromDevAttrList( $shuttersDev, 'ASC_Shading_Angle_Left' ); -# delFromDevAttrList( $shuttersDev, 'ASC_Shading_Angle_Right' ); +# . ( ::AttrVal( $shuttersDev, 'ASC_Shading_Direction', 180 ) + +# ::AttrVal( $shuttersDev, 'ASC_Shading_Angle_Right', 85 ) ) +# if ( ::AttrVal( $shuttersDev, 'ASC_Shading_Direction', 'none' ) ne 'none' +# || ::AttrVal( $shuttersDev, 'ASC_Shading_Angle_Left', 'none' ) ne 'none' +# || ::AttrVal( $shuttersDev, 'ASC_Shading_Angle_Right', 'none' ) ne 'none' ); +# ::delFromDevAttrList( $shuttersDev, 'ASC_Shading_Direction' ); +# ::delFromDevAttrList( $shuttersDev, 'ASC_Shading_Angle_Left' ); +# ::delFromDevAttrList( $shuttersDev, 'ASC_Shading_Angle_Right' ); # # $attr{$shuttersDev}{ASC_PrivacyDownValue_beforeNightClose} = -# AttrVal( $shuttersDev, 'ASC_PrivacyDownTime_beforNightClose', 'none' ) +# ::AttrVal( $shuttersDev, 'ASC_PrivacyDownTime_beforNightClose', 'none' ) # if ( -# AttrVal( $shuttersDev, 'ASC_PrivacyDownTime_beforNightClose', 'none' ) ne +# ::AttrVal( $shuttersDev, 'ASC_PrivacyDownTime_beforNightClose', 'none' ) ne # 'none' ); -# delFromDevAttrList( $shuttersDev, 'ASC_PrivacyDownTime_beforNightClose' ); +# ::delFromDevAttrList( $shuttersDev, 'ASC_PrivacyDownTime_beforNightClose' ); # -# delFromDevAttrList( $shuttersDev, 'ASC_ExternalTriggerDevice' ); +# ::delFromDevAttrList( $shuttersDev, 'ASC_ExternalTriggerDevice' ); } return; @@ -1331,7 +1338,7 @@ sub wiggle { } } - InternalTimer( gettimeofday() + 60, \&_SetCmdFn, \%h ); + ::InternalTimer( ::gettimeofday() + 60, \&SetCmdFn, \%h ); return; } @@ -1520,43 +1527,43 @@ sub CreateNewNotifyDev { $hash->{NOTIFYDEV} = "global," . $name; delete $hash->{monitoredDevs}; - CommandDeleteReading( undef, $name . ' .monitoredDevs' ); + ::CommandDeleteReading( undef, $name . ' .monitoredDevs' ); my $shuttersList = ''; for my $shuttersDev ( @{ $hash->{helper}{shuttersList} } ) { AddNotifyDev( $hash, - AttrVal( $shuttersDev, 'ASC_Roommate_Device', 'none' ), + ::AttrVal( $shuttersDev, 'ASC_Roommate_Device', 'none' ), $shuttersDev, 'ASC_Roommate_Device' ) - if ( - AttrVal( $shuttersDev, 'ASC_Roommate_Device', 'none' ) ne 'none' ); - AddNotifyDev( $hash, AttrVal( $shuttersDev, 'ASC_WindowRec', 'none' ), + if ( ::AttrVal( $shuttersDev, 'ASC_Roommate_Device', 'none' ) ne + 'none' ); + AddNotifyDev( $hash, ::AttrVal( $shuttersDev, 'ASC_WindowRec', 'none' ), $shuttersDev, 'ASC_WindowRec' ) - if ( AttrVal( $shuttersDev, 'ASC_WindowRec', 'none' ) ne 'none' ); + if ( ::AttrVal( $shuttersDev, 'ASC_WindowRec', 'none' ) ne 'none' ); AddNotifyDev( $hash, - AttrVal( $shuttersDev, 'ASC_BrightnessSensor', 'none' ), + ::AttrVal( $shuttersDev, 'ASC_BrightnessSensor', 'none' ), $shuttersDev, 'ASC_BrightnessSensor' ) - if ( - AttrVal( $shuttersDev, 'ASC_BrightnessSensor', 'none' ) ne 'none' ); + if ( ::AttrVal( $shuttersDev, 'ASC_BrightnessSensor', 'none' ) ne + 'none' ); AddNotifyDev( $hash, - AttrVal( $shuttersDev, 'ASC_ExternalTrigger', 'none' ), + ::AttrVal( $shuttersDev, 'ASC_ExternalTrigger', 'none' ), $shuttersDev, 'ASC_ExternalTrigger' ) - if ( - AttrVal( $shuttersDev, 'ASC_ExternalTrigger', 'none' ) ne 'none' ); + if ( ::AttrVal( $shuttersDev, 'ASC_ExternalTrigger', 'none' ) ne + 'none' ); $shuttersList = $shuttersList . ',' . $shuttersDev; } - AddNotifyDev( $hash, AttrVal( $name, 'ASC_residentsDev', 'none' ), + 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' ), + 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' ); - AddNotifyDev( $hash, AttrVal( $name, 'ASC_twilightDevice', 'none' ), + if ( ::AttrVal( $name, 'ASC_rainSensor', 'none' ) ne 'none' ); + AddNotifyDev( $hash, ::AttrVal( $name, 'ASC_twilightDevice', 'none' ), $name, 'ASC_twilightDevice' ) - if ( AttrVal( $name, 'ASC_twilightDevice', 'none' ) ne 'none' ); - AddNotifyDev( $hash, AttrVal( $name, 'ASC_windSensor', 'none' ), + if ( ::AttrVal( $name, 'ASC_twilightDevice', 'none' ) ne 'none' ); + AddNotifyDev( $hash, ::AttrVal( $name, 'ASC_windSensor', 'none' ), $name, 'ASC_windSensor' ) - if ( AttrVal( $name, 'ASC_windSensor', 'none' ) ne 'none' ); + if ( ::AttrVal( $name, 'ASC_windSensor', 'none' ) ne 'none' ); $hash->{NOTIFYDEV} = $hash->{NOTIFYDEV} . $shuttersList; @@ -1638,7 +1645,7 @@ sub ShuttersInformation { $ret .= "" . $shutters->getLockOut . ""; $ret .= " "; $ret .= "" - . ReadingsVal( $shuttersDev, 'ASC_ShuttersLastDrive', 'none' ) + . ::ReadingsVal( $shuttersDev, 'ASC_ShuttersLastDrive', 'none' ) . ""; $ret .= " "; $ret .= "" . $shutters->getStatus . ""; @@ -1663,7 +1670,7 @@ sub GetMonitoredDevs { my $hash = shift; my $notifydevs = eval { - decode_json( ReadingsVal( $hash->{NAME}, '.monitoredDevs', 'none' ) ); + decode_json( ::ReadingsVal( $hash->{NAME}, '.monitoredDevs', 'none' ) ); }; my $ret = '
    '; $ret .= ''; @@ -1708,26 +1715,34 @@ sub _DetermineSlatCmd { my $value = shift; my $posValue = shift; - return $posValue == $shutters->getShadingPos - && $shutters->getShadingPositionAssignment ne 'none' ? $shutters->getShadingPositionAssignment - : $posValue == $shutters->getVentilatePos - && $shutters->getVentilatePositionAssignment ne 'none' ? $shutters->getVentilatePositionAssignment - : $posValue == $shutters->getOpenPos - && $shutters->getOpenPositionAssignment ne 'none' ? $shutters->getOpenPositionAssignment - : $posValue == $shutters->getClosedPos - && $shutters->getClosedPositionAssignment ne 'none' ? $shutters->getClosedPositionAssignment - : $posValue == $shutters->getSleepPos - && $shutters->getSleepPositionAssignment ne 'none' ? $shutters->getSleepPositionAssignment - : $posValue == $shutters->getComfortOpenPos - && $shutters->getComfortOpenPositionAssignment ne 'none' ? $shutters->getComfortOpenPositionAssignment - : $posValue == $shutters->getPrivacyUpPos - && $shutters->getPrivacyUpPositionAssignment ne 'none' ? $shutters->getPrivacyUpPositionAssignment - : $posValue == $shutters->getPrivacyDownPos - && $shutters->getPrivacyDownPositionAssignment ne 'none' ? $shutters->getPrivacyDownPositionAssignment - : $value; + return $posValue == $shutters->getShadingPos + && $shutters->getShadingPositionAssignment ne 'none' + ? $shutters->getShadingPositionAssignment + : $posValue == $shutters->getVentilatePos + && $shutters->getVentilatePositionAssignment ne 'none' + ? $shutters->getVentilatePositionAssignment + : $posValue == $shutters->getOpenPos + && $shutters->getOpenPositionAssignment ne 'none' + ? $shutters->getOpenPositionAssignment + : $posValue == $shutters->getClosedPos + && $shutters->getClosedPositionAssignment ne 'none' + ? $shutters->getClosedPositionAssignment + : $posValue == $shutters->getSleepPos + && $shutters->getSleepPositionAssignment ne 'none' + ? $shutters->getSleepPositionAssignment + : $posValue == $shutters->getComfortOpenPos + && $shutters->getComfortOpenPositionAssignment ne 'none' + ? $shutters->getComfortOpenPositionAssignment + : $posValue == $shutters->getPrivacyUpPos + && $shutters->getPrivacyUpPositionAssignment ne 'none' + ? $shutters->getPrivacyUpPositionAssignment + : $posValue == $shutters->getPrivacyDownPos + && $shutters->getPrivacyDownPositionAssignment ne 'none' + ? $shutters->getPrivacyDownPositionAssignment + : $value; } -sub _SetCmdFn { +sub SetCmdFn { my $h = shift; my $shuttersDev = $h->{shuttersDev}; @@ -1750,7 +1765,7 @@ sub _SetCmdFn { } else { $shutters->setLastDrive( - ReadingsVal( $shuttersDev, 'ASC_ShuttersLastDrive', 'none' ) ); + ::ReadingsVal( $shuttersDev, 'ASC_ShuttersLastDrive', 'none' ) ); ASC_Debug( 'FnSetCmdFn: ' . $shuttersDev . ' - Abbruch aktuelle Position ist gleich der Zielposition ' @@ -1809,12 +1824,12 @@ sub _SetCmdFn { $driveCommand = _DetermineSlatCmd( $driveCommand, $posValue ); } elsif ($shutters->getShadingPositionAssignment =~ m{\A\d{1,3}\z}xms - || $shutters->getOpenPositionAssignment =~ m{\A\d{1,3}\z}xms - || $shutters->getClosedPositionAssignment =~ m{\A\d{1,3}\z}xms - || $shutters->getPrivacyUpPositionAssignment =~ m{\A\d{1,3}\z}xms + || $shutters->getOpenPositionAssignment =~ m{\A\d{1,3}\z}xms + || $shutters->getClosedPositionAssignment =~ m{\A\d{1,3}\z}xms + || $shutters->getPrivacyUpPositionAssignment =~ m{\A\d{1,3}\z}xms || $shutters->getPrivacyDownPositionAssignment =~ m{\A\d{1,3}\z}xms - || $shutters->getSleepPositionAssignment =~ m{\A\d{1,3}\z}xms - || $shutters->getVentilatePositionAssignment =~ m{\A\d{1,3}\z}xms + || $shutters->getSleepPositionAssignment =~ m{\A\d{1,3}\z}xms + || $shutters->getVentilatePositionAssignment =~ m{\A\d{1,3}\z}xms || $shutters->getComfortOpenPositionAssignment =~ m{\A\d{1,3}\z}xms ) { @@ -1822,47 +1837,49 @@ sub _SetCmdFn { } } - if ( $commandTemplate ne 'none' ) { # Patch von Beta-User Forum https://forum.fhem.de/index.php/topic,123659.0.html - # Nutzervariablen setzen + if ( $commandTemplate ne 'none' ) + { # Patch von Beta-User Forum https://forum.fhem.de/index.php/topic,123659.0.html + # Nutzervariablen setzen my %specials = ( - '$name' => $shuttersDev, - '$pos' => $posValue, - '$slatPos' => $slatPos, - '$cause' => $shutters->getLastDrive + '$name' => $shuttersDev, + '$pos' => $posValue, + '$slatPos' => $slatPos, + '$cause' => $shutters->getLastDrive ); - - $commandTemplate = ::EvalSpecials($commandTemplate, %specials); + + $commandTemplate = ::EvalSpecials( $commandTemplate, %specials ); + # CMD ausführen ::AnalyzeCommandChain( $h, $commandTemplate ); } else { - CommandSet( undef, + ::CommandSet( undef, $shuttersDev - . ':FILTER=' - . $shutters->getPosCmd . '!=' - . $posValue . ' ' - . $driveCommand ); + . ':FILTER=' + . $shutters->getPosCmd . '!=' + . $posValue . ' ' + . $driveCommand ); - InternalTimer( - gettimeofday() + 3, + ::InternalTimer( + ::gettimeofday() + 3, sub() { - CommandSet( + ::CommandSet( undef, ( - $shutters->getSlatDevice ne 'none' + $shutters->getSlatDevice ne 'none' ? $shutters->getSlatDevice : $shuttersDev - ) - . ' ' - . $shutters->getSlatPosCmd . ' ' - . $slatPos + ) + . ' ' + . $shutters->getSlatPosCmd . ' ' + . $slatPos ); }, $shuttersDev - ) - if ( $slatPos > -1 + ) + if ( $slatPos > -1 && $shutters->getSlatPosCmd ne 'none' ); - + } $shutters->setSelfDefenseAbsent( 0, 0 ) @@ -1872,13 +1889,13 @@ sub _SetCmdFn { return; } -sub _setShuttersLastDriveDelayed { +sub setShuttersLastDriveDelayed { my $h = shift; my $shuttersDevHash = $h->{devHash}; my $lastDrive = $h->{lastDrive}; - readingsSingleUpdate( $shuttersDevHash, 'ASC_ShuttersLastDrive', + ::readingsSingleUpdate( $shuttersDevHash, 'ASC_ShuttersLastDrive', $lastDrive, 1 ); return; @@ -1886,9 +1903,9 @@ sub _setShuttersLastDriveDelayed { sub ASC_Debug { return - if ( !AttrVal( $ascDev->getName, 'ASC_debug', 0 ) ); + if ( !::AttrVal( $ascDev->getName, 'ASC_debug', 0 ) ); - my $debugMsg = shift; + my $debugMsg = shift; my $debugTimestamp = strftime( "%Y.%m.%d %T", localtime(time) ); print( @@ -1907,7 +1924,7 @@ sub PrivacyUpTime { my $privacyUpUnixtime; if ( ( $shuttersSunriseUnixtime - $shutters->getPrivacyUpTime ) > - ( gettimeofday() + 1 ) + ( ::gettimeofday() + 1 ) || $shutters->getPrivacyUpStatus == 2 ) { $privacyUpUnixtime = @@ -1916,7 +1933,7 @@ sub PrivacyUpTime { $privacyUpUnixtime += 86400 if ( $shutters->getPrivacyUpStatus == 2 ); - readingsSingleUpdate( $shuttersDevHash, 'ASC_Time_PrivacyDriveUp', + ::readingsSingleUpdate( $shuttersDevHash, 'ASC_Time_PrivacyDriveUp', strftime( "%d.%m.%Y - %H:%M", localtime($privacyUpUnixtime) ), 1 ); ## Setzt den PrivacyUp Modus für die Sichtschutzfahrt auf den Status 1 ## und gibt die Unixtime für die nächste Fahrt korrekt zurück @@ -1926,7 +1943,7 @@ sub PrivacyUpTime { } } else { - readingsSingleUpdate( + ::readingsSingleUpdate( $shuttersDevHash, 'ASC_Time_PrivacyDriveUp', strftime( @@ -1950,7 +1967,7 @@ sub PrivacyDownTime { my $privacyDownUnixtime; if ( ( $shuttersSunsetUnixtime - $shutters->getPrivacyDownTime ) > - ( gettimeofday() + 1 ) + ( ::gettimeofday() + 1 ) || $shutters->getPrivacyDownStatus == 2 ) { $privacyDownUnixtime = @@ -1959,7 +1976,7 @@ sub PrivacyDownTime { $privacyDownUnixtime += 86400 if ( $shutters->getPrivacyDownStatus == 2 ); - readingsSingleUpdate( $shuttersDevHash, 'ASC_Time_PrivacyDriveDown', + ::readingsSingleUpdate( $shuttersDevHash, 'ASC_Time_PrivacyDriveDown', strftime( "%d.%m.%Y - %H:%M", localtime($privacyDownUnixtime) ), 1 ); ## Setzt den PrivacyDown Modus für die Sichtschutzfahrt auf den Status 1 @@ -1970,7 +1987,7 @@ sub PrivacyDownTime { } } else { - readingsSingleUpdate( + ::readingsSingleUpdate( $shuttersDevHash, 'ASC_Time_PrivacyDriveDown', strftime( @@ -1995,55 +2012,55 @@ sub DevStateIcon { return if ( !$hash ); my $name = $hash->{NAME}; - if ( ReadingsVal( $name, 'state', undef ) eq 'created new drive timer' ) { + if ( ::ReadingsVal( $name, 'state', undef ) eq 'created new drive timer' ) { return '.*:clock'; } - elsif ( ReadingsVal( $name, 'state', undef ) eq 'selfDefense terrace' ) { + elsif ( ::ReadingsVal( $name, 'state', undef ) eq 'selfDefense terrace' ) { return '.*:fts_door_tilt'; } - elsif ( ReadingsVal( $name, 'state', undef ) =~ m{.*asleep$}xms ) { + elsif ( ::ReadingsVal( $name, 'state', undef ) =~ m{.*asleep$}xms ) { return '.*:scene_sleeping'; } - elsif ( ReadingsVal( $name, 'state', undef ) =~ + elsif ( ::ReadingsVal( $name, 'state', undef ) =~ m{^roommate(.come)?.(awoken|home)$}xms ) { return '.*:user_available'; } - elsif ( ReadingsVal( $name, 'state', undef ) =~ + elsif ( ::ReadingsVal( $name, 'state', undef ) =~ m{^residents.(home|awoken)$}xms ) { return '.*:status_available'; } - elsif ( ReadingsVal( $name, 'state', undef ) eq 'manual' ) { + elsif ( ::ReadingsVal( $name, 'state', undef ) eq 'manual' ) { return '.*:fts_shutter_manual'; } - elsif ( ReadingsVal( $name, 'state', undef ) eq 'selfDefense inactive' ) { + elsif ( ::ReadingsVal( $name, 'state', undef ) eq 'selfDefense inactive' ) { return '.*:status_open'; } elsif ( - ReadingsVal( $name, 'state', undef ) =~ m{^selfDefense.*.active$}xms ) + ::ReadingsVal( $name, 'state', undef ) =~ m{^selfDefense.*.active$}xms ) { return '.*:status_locked'; } - elsif ( ReadingsVal( $name, 'state', undef ) eq 'day open' ) { + elsif ( ::ReadingsVal( $name, 'state', undef ) eq 'day open' ) { return '.*:scene_day'; } - elsif ( ReadingsVal( $name, 'state', undef ) eq 'night close' ) { + elsif ( ::ReadingsVal( $name, 'state', undef ) eq 'night close' ) { return '.*:scene_night'; } - elsif ( ReadingsVal( $name, 'state', undef ) eq 'shading in' ) { + elsif ( ::ReadingsVal( $name, 'state', undef ) eq 'shading in' ) { return '.*:fts_shutter_shadding_run'; } - elsif ( ReadingsVal( $name, 'state', undef ) eq 'shading out' ) { + elsif ( ::ReadingsVal( $name, 'state', undef ) eq 'shading out' ) { return '.*:fts_shutter_shadding_stop'; } - elsif ( ReadingsVal( $name, 'state', undef ) eq 'active' ) { + elsif ( ::ReadingsVal( $name, 'state', undef ) eq 'active' ) { return '.*:hourglass'; } - elsif ( ReadingsVal( $name, 'state', undef ) =~ m{.*privacy.*}xms ) { + elsif ( ::ReadingsVal( $name, 'state', undef ) =~ m{.*privacy.*}xms ) { return '.*:fts_shutter_50'; } - elsif ( ReadingsVal( $name, 'state', undef ) eq 'adv delay close' ) { + elsif ( ::ReadingsVal( $name, 'state', undef ) eq 'adv delay close' ) { return '.*:christmas_tree'; } @@ -2056,7 +2073,7 @@ sub RemoveShuttersTimer { for my $shuttersDev ( @{ $hash->{helper}{shuttersList} } ) { $shutters->setShuttersDev($shuttersDev); - RemoveInternalTimer( $shutters->getInTimerFuncHash ); + ::RemoveInternalTimer( $shutters->getInTimerFuncHash ); $shutters->setInTimerFuncHash(undef); } diff --git a/fhem/lib/FHEM/Automation/ShuttersControl/Dev.pm b/fhem/lib/FHEM/Automation/ShuttersControl/Dev.pm index 7fb0052b3..ced5bc4d0 100644 --- a/fhem/lib/FHEM/Automation/ShuttersControl/Dev.pm +++ b/fhem/lib/FHEM/Automation/ShuttersControl/Dev.pm @@ -1,8 +1,8 @@ ############################################################################### # -# Developed with Kate +# Developed with VSCodium and richterger perl plugin # -# (c) 2018-2021 Copyright: Marko Oldenburg (leongaultier at gmail dot com) +# (c) 2018-2022 Copyright: Marko Oldenburg (fhemdevelopment at cooltux dot net) # All rights reserved # # Special thanks goes to: @@ -43,7 +43,7 @@ package FHEM::Automation::ShuttersControl::Dev; use FHEM::Automation::ShuttersControl::Dev::Readings; use FHEM::Automation::ShuttersControl::Dev::Attr; -our @ISA = +use base qw(FHEM::Automation::ShuttersControl::Dev::Readings FHEM::Automation::ShuttersControl::Dev::Attr); use strict; diff --git a/fhem/lib/FHEM/Automation/ShuttersControl/Dev/Attr.pm b/fhem/lib/FHEM/Automation/ShuttersControl/Dev/Attr.pm index 7cefbf024..121582540 100644 --- a/fhem/lib/FHEM/Automation/ShuttersControl/Dev/Attr.pm +++ b/fhem/lib/FHEM/Automation/ShuttersControl/Dev/Attr.pm @@ -1,8 +1,8 @@ ############################################################################### # -# Developed with Kate +# Developed with VSCodium and richterger perl plugin # -# (c) 2018-2021 Copyright: Marko Oldenburg (fhemdevelopment@cooltux.net) +# (c) 2018-2022 Copyright: Marko Oldenburg (fhemdevelopment at cooltux dot net) # All rights reserved # # Special thanks goes to: @@ -44,23 +44,12 @@ use strict; use warnings; use utf8; -use GPUtils qw(GP_Import); - -## Import der FHEM Funktionen -BEGIN { - GP_Import( - qw( - AttrVal - gettimeofday) - ); -} - sub getShuttersOffset { my $self = shift; my $name = $self->{name}; - return AttrVal( $name, 'ASC_shuttersDriveDelay', -1 ); + return ::AttrVal( $name, 'ASC_shuttersDriveDelay', -1 ); } sub getBrightnessMinVal { @@ -70,7 +59,7 @@ sub getBrightnessMinVal { return $self->{ASC_brightness}->{triggermin} if ( exists( $self->{ASC_brightness}->{LASTGETTIME} ) - && ( gettimeofday() - $self->{ASC_brightness}->{LASTGETTIME} ) < 2 ); + && ( ::gettimeofday() - $self->{ASC_brightness}->{LASTGETTIME} ) < 2 ); $FHEM::Automation::ShuttersControl::ascDev->getBrightnessMaxVal; return $self->{ASC_brightness}->{triggermin}; @@ -83,8 +72,8 @@ sub getBrightnessMaxVal { return $self->{ASC_brightness}->{triggermax} if ( exists( $self->{ASC_brightness}->{LASTGETTIME} ) - && ( gettimeofday() - $self->{ASC_brightness}->{LASTGETTIME} ) < 2 ); - $self->{ASC_brightness}->{LASTGETTIME} = int( gettimeofday() ); + && ( ::gettimeofday() - $self->{ASC_brightness}->{LASTGETTIME} ) < 2 ); + $self->{ASC_brightness}->{LASTGETTIME} = int( ::gettimeofday() ); my ( $triggermax, $triggermin ) = FHEM::Automation::ShuttersControl::Helper::GetAttrValues( $name, @@ -104,7 +93,7 @@ sub _getTwilightDevice { my $name = $self->{name}; - return AttrVal( $name, 'ASC_twilightDevice', 'none' ); + return ::AttrVal( $name, 'ASC_twilightDevice', 'none' ); } sub getAutoAstroModeEvening { @@ -112,7 +101,7 @@ sub getAutoAstroModeEvening { my $name = $self->{name}; - return AttrVal( $name, 'ASC_autoAstroModeEvening', 'REAL' ); + return ::AttrVal( $name, 'ASC_autoAstroModeEvening', 'REAL' ); } sub getAutoAstroModeEveningHorizon { @@ -120,7 +109,7 @@ sub getAutoAstroModeEveningHorizon { my $name = $self->{name}; - return AttrVal( $name, 'ASC_autoAstroModeEveningHorizon', 0 ); + return ::AttrVal( $name, 'ASC_autoAstroModeEveningHorizon', 0 ); } sub getAutoAstroModeMorning { @@ -128,7 +117,7 @@ sub getAutoAstroModeMorning { my $name = $self->{name}; - return AttrVal( $name, 'ASC_autoAstroModeMorning', 'REAL' ); + return ::AttrVal( $name, 'ASC_autoAstroModeMorning', 'REAL' ); } sub getAutoAstroModeMorningHorizon { @@ -136,7 +125,7 @@ sub getAutoAstroModeMorningHorizon { my $name = $self->{name}; - return AttrVal( $name, 'ASC_autoAstroModeMorningHorizon', 0 ); + return ::AttrVal( $name, 'ASC_autoAstroModeMorningHorizon', 0 ); } sub getAutoShuttersControlMorning { @@ -144,7 +133,7 @@ sub getAutoShuttersControlMorning { my $name = $self->{name}; - return AttrVal( $name, 'ASC_autoShuttersControlMorning', 'on' ); + return ::AttrVal( $name, 'ASC_autoShuttersControlMorning', 'on' ); } sub getAutoShuttersControlEvening { @@ -152,7 +141,7 @@ sub getAutoShuttersControlEvening { my $name = $self->{name}; - return AttrVal( $name, 'ASC_autoShuttersControlEvening', 'on' ); + return ::AttrVal( $name, 'ASC_autoShuttersControlEvening', 'on' ); } sub getAutoShuttersControlComfort { @@ -160,7 +149,7 @@ sub getAutoShuttersControlComfort { my $name = $self->{name}; - return AttrVal( $name, 'ASC_autoShuttersControlComfort', 'off' ); + return ::AttrVal( $name, 'ASC_autoShuttersControlComfort', 'off' ); } sub getFreezeTemp { @@ -168,7 +157,7 @@ sub getFreezeTemp { my $name = $self->{name}; - return AttrVal( $name, 'ASC_freezeTemp', 3 ); + return ::AttrVal( $name, 'ASC_freezeTemp', 3 ); } sub getSlatDriveCmdInverse { @@ -176,7 +165,7 @@ sub getSlatDriveCmdInverse { my $name = $self->{name}; - return AttrVal( $name, 'ASC_slatDriveCmdInverse', 0 ); + return ::AttrVal( $name, 'ASC_slatDriveCmdInverse', 0 ); } sub _getTempSensor { @@ -186,11 +175,11 @@ sub _getTempSensor { return $self->{ASC_tempSensor}->{device} if ( exists( $self->{ASC_tempSensor}->{LASTGETTIME} ) - && ( gettimeofday() - $self->{ASC_tempSensor}->{LASTGETTIME} ) < 2 ); - $self->{ASC_tempSensor}->{LASTGETTIME} = int( gettimeofday() ); + && ( ::gettimeofday() - $self->{ASC_tempSensor}->{LASTGETTIME} ) < 2 ); + $self->{ASC_tempSensor}->{LASTGETTIME} = int( ::gettimeofday() ); my ( $device, $reading ) = - FHEM::Automation::ShuttersControl::Helper::GetAttrValues( $name, 'ASC_tempSensor', - 'none' ); + FHEM::Automation::ShuttersControl::Helper::GetAttrValues( $name, + 'ASC_tempSensor', 'none' ); ## erwartetes Ergebnis # DEVICE:READING @@ -208,7 +197,7 @@ sub getTempSensorReading { return $self->{ASC_tempSensor}->{reading} if ( exists( $self->{ASC_tempSensor}->{LASTGETTIME} ) - && ( gettimeofday() - $self->{ASC_tempSensor}->{LASTGETTIME} ) < 2 ); + && ( ::gettimeofday() - $self->{ASC_tempSensor}->{LASTGETTIME} ) < 2 ); $FHEM::Automation::ShuttersControl::ascDev->_getTempSensor; return $self->{ASC_tempSensor}->{reading}; } @@ -220,8 +209,9 @@ sub _getResidentsDev { return $self->{ASC_residentsDev}->{device} if ( exists( $self->{ASC_residentsDev}->{LASTGETTIME} ) - && ( gettimeofday() - $self->{ASC_residentsDev}->{LASTGETTIME} ) < 2 ); - $self->{ASC_residentsDev}->{LASTGETTIME} = int( gettimeofday() ); + && ( ::gettimeofday() - $self->{ASC_residentsDev}->{LASTGETTIME} ) < + 2 ); + $self->{ASC_residentsDev}->{LASTGETTIME} = int( ::gettimeofday() ); my ( $device, $reading ) = FHEM::Automation::ShuttersControl::Helper::GetAttrValues( $name, 'ASC_residentsDev', 'none' ); @@ -240,7 +230,8 @@ sub getResidentsReading { return $self->{ASC_residentsDev}->{reading} if ( exists( $self->{ASC_residentsDev}->{LASTGETTIME} ) - && ( gettimeofday() - $self->{ASC_residentsDev}->{LASTGETTIME} ) < 2 ); + && ( ::gettimeofday() - $self->{ASC_residentsDev}->{LASTGETTIME} ) < + 2 ); $FHEM::Automation::ShuttersControl::ascDev->_getResidentsDev; return $self->{ASC_residentsDev}->{reading}; } @@ -252,11 +243,11 @@ sub _getRainSensor { return $self->{ASC_rainSensor}->{device} if ( exists( $self->{ASC_rainSensor}->{LASTGETTIME} ) - && ( gettimeofday() - $self->{ASC_rainSensor}->{LASTGETTIME} ) < 2 ); - $self->{ASC_rainSensor}->{LASTGETTIME} = int( gettimeofday() ); + && ( ::gettimeofday() - $self->{ASC_rainSensor}->{LASTGETTIME} ) < 2 ); + $self->{ASC_rainSensor}->{LASTGETTIME} = int( ::gettimeofday() ); my ( $device, $reading, $max, $hyst, $pos, $wait ) = - FHEM::Automation::ShuttersControl::Helper::GetAttrValues( $name, 'ASC_rainSensor', - 'none' ); + FHEM::Automation::ShuttersControl::Helper::GetAttrValues( $name, + 'ASC_rainSensor', 'none' ); ## erwartetes Ergebnis # DEVICE:READING MAX:HYST @@ -266,10 +257,10 @@ sub _getRainSensor { $self->{ASC_rainSensor}->{reading} = ( $reading ne 'none' ? $reading : 'rain' ); $self->{ASC_rainSensor}->{triggermax} = ( - ( $max ne 'none' - && $max =~ m{\A(-?\d+(\.\d+)?)\z}xms ) + ( $max ne 'none' && $max =~ m{\A(-?\d+(\.\d+)?)\z}xms ) ? $max - : 1000 ); + : 1000 + ); $self->{ASC_rainSensor}->{triggerhyst} = ( $hyst ne 'none' @@ -277,10 +268,11 @@ sub _getRainSensor { : ( $self->{ASC_rainSensor}->{triggermax} * 0 ) ); - $self->{ASC_rainSensor}->{shuttersClosedPos} = - ( $pos ne 'none' + $self->{ASC_rainSensor}->{shuttersClosedPos} = ( + $pos ne 'none' ? $pos - : $FHEM::Automation::ShuttersControl::shutters->getClosedPos ); + : $FHEM::Automation::ShuttersControl::shutters->getClosedPos + ); $self->{ASC_rainSensor}->{waitingTime} = ( $wait ne 'none' ? $wait : 0 ); @@ -294,7 +286,7 @@ sub getRainSensorReading { return $self->{ASC_rainSensor}->{reading} if ( exists( $self->{ASC_rainSensor}->{LASTGETTIME} ) - && ( gettimeofday() - $self->{ASC_rainSensor}->{LASTGETTIME} ) < 2 ); + && ( ::gettimeofday() - $self->{ASC_rainSensor}->{LASTGETTIME} ) < 2 ); $FHEM::Automation::ShuttersControl::ascDev->_getRainSensor; return $self->{ASC_rainSensor}->{reading}; } @@ -306,7 +298,7 @@ sub getRainTriggerMax { return $self->{ASC_rainSensor}->{triggermax} if ( exists( $self->{ASC_rainSensor}->{LASTGETTIME} ) - && ( gettimeofday() - $self->{ASC_rainSensor}->{LASTGETTIME} ) < 2 ); + && ( ::gettimeofday() - $self->{ASC_rainSensor}->{LASTGETTIME} ) < 2 ); $FHEM::Automation::ShuttersControl::ascDev->_getRainSensor; return $self->{ASC_rainSensor}->{triggermax}; } @@ -318,7 +310,7 @@ sub getRainTriggerMin { return $self->{ASC_rainSensor}->{triggerhyst} if ( exists( $self->{ASC_rainSensor}->{LASTGETTIME} ) - && ( gettimeofday() - $self->{ASC_rainSensor}->{LASTGETTIME} ) < 2 ); + && ( ::gettimeofday() - $self->{ASC_rainSensor}->{LASTGETTIME} ) < 2 ); $FHEM::Automation::ShuttersControl::ascDev->_getRainSensor; return $self->{ASC_rainSensor}->{triggerhyst}; } @@ -330,7 +322,7 @@ sub getRainSensorShuttersClosedPos { return $self->{ASC_rainSensor}->{shuttersClosedPos} if ( exists( $self->{ASC_rainSensor}->{LASTGETTIME} ) - && ( gettimeofday() - $self->{ASC_rainSensor}->{LASTGETTIME} ) < 2 ); + && ( ::gettimeofday() - $self->{ASC_rainSensor}->{LASTGETTIME} ) < 2 ); $FHEM::Automation::ShuttersControl::ascDev->_getRainSensor; return $self->{ASC_rainSensor}->{shuttersClosedPos}; } @@ -342,7 +334,7 @@ sub getRainWaitingTime { return $self->{ASC_rainSensor}->{waitingTime} if ( exists( $self->{ASC_rainSensor}->{LASTGETTIME} ) - && ( gettimeofday() - $self->{ASC_rainSensor}->{LASTGETTIME} ) < 2 ); + && ( ::gettimeofday() - $self->{ASC_rainSensor}->{LASTGETTIME} ) < 2 ); $FHEM::Automation::ShuttersControl::ascDev->_getRainSensor; return $self->{ASC_rainSensor}->{waitingTime}; } @@ -354,11 +346,11 @@ sub _getWindSensor { return $self->{ASC_windSensor}->{device} if ( exists( $self->{ASC_windSensor}->{LASTGETTIME} ) - && ( gettimeofday() - $self->{ASC_windSensor}->{LASTGETTIME} ) < 2 ); - $self->{ASC_windSensor}->{LASTGETTIME} = int( gettimeofday() ); + && ( ::gettimeofday() - $self->{ASC_windSensor}->{LASTGETTIME} ) < 2 ); + $self->{ASC_windSensor}->{LASTGETTIME} = int( ::gettimeofday() ); my ( $device, $reading ) = - FHEM::Automation::ShuttersControl::Helper::GetAttrValues( $name, 'ASC_windSensor', - 'none' ); + FHEM::Automation::ShuttersControl::Helper::GetAttrValues( $name, + 'ASC_windSensor', 'none' ); return $device if ( $device eq 'none' ); $self->{ASC_windSensor}->{device} = $device; @@ -375,7 +367,7 @@ sub getWindSensorReading { return $self->{ASC_windSensor}->{reading} if ( exists( $self->{ASC_windSensor}->{LASTGETTIME} ) - && ( gettimeofday() - $self->{ASC_windSensor}->{LASTGETTIME} ) < 2 ); + && ( ::gettimeofday() - $self->{ASC_windSensor}->{LASTGETTIME} ) < 2 ); $FHEM::Automation::ShuttersControl::ascDev->_getWindSensor; return ( defined( $self->{ASC_windSensor}->{reading} ) @@ -389,18 +381,23 @@ sub getBlockAscDrivesAfterManual { my $name = $self->{name}; - return AttrVal( $name, 'ASC_blockAscDrivesAfterManual', 0 ); + return ::AttrVal( $name, 'ASC_blockAscDrivesAfterManual', 0 ); } -sub getAdvDate { +sub getAdvStartDate { my $self = shift; my $name = $self->{name}; - return AttrVal( $name, 'ASC_advDate', 'FirstAdvent' ); + return ::AttrVal( $name, 'ASC_advStartDate', 'FirstAdvent' ); } +sub getAdvEndDate { + my $self = shift; + my $name = $self->{name}; + return ::AttrVal( $name, 'ASC_advEndDate', 'EpiphanyDay' ); +} 1; diff --git a/fhem/lib/FHEM/Automation/ShuttersControl/Dev/Readings.pm b/fhem/lib/FHEM/Automation/ShuttersControl/Dev/Readings.pm index c6591663a..1a7178157 100644 --- a/fhem/lib/FHEM/Automation/ShuttersControl/Dev/Readings.pm +++ b/fhem/lib/FHEM/Automation/ShuttersControl/Dev/Readings.pm @@ -1,8 +1,8 @@ ############################################################################### # -# Developed with Kate +# Developed with VSCodium and richterger perl plugin # -# (c) 2018-2021 Copyright: Marko Oldenburg (fhemdevelopment@cooltux.net) +# (c) 2018-2022 Copyright: Marko Oldenburg (fhemdevelopment at cooltux dot net) # All rights reserved # # Special thanks goes to: @@ -48,12 +48,7 @@ use GPUtils qw(GP_Import); ## Import der FHEM Funktionen BEGIN { - GP_Import( - qw( - readingsSingleUpdate - ReadingsVal - defs) - ); + GP_Import(qw(defs)); } sub setDelayCmdReading { @@ -62,7 +57,7 @@ sub setDelayCmdReading { my $name = $self->{name}; my $hash = $defs{$name}; - readingsSingleUpdate( + ::readingsSingleUpdate( $hash, $FHEM::Automation::ShuttersControl::shutters->getShuttersDev . '_lastDelayPosValue', @@ -79,7 +74,7 @@ sub setStateReading { my $name = $self->{name}; my $hash = $defs{$name}; - readingsSingleUpdate( + ::readingsSingleUpdate( $hash, 'state', ( defined($value) @@ -97,7 +92,7 @@ sub setPosReading { my $name = $self->{name}; my $hash = $defs{$name}; - readingsSingleUpdate( + ::readingsSingleUpdate( $hash, $FHEM::Automation::ShuttersControl::shutters->getShuttersDev . '_PosValue', @@ -113,7 +108,7 @@ sub setLastPosReading { my $name = $self->{name}; my $hash = $defs{$name}; - readingsSingleUpdate( + ::readingsSingleUpdate( $hash, $FHEM::Automation::ShuttersControl::shutters->getShuttersDev . '_lastPosValue', @@ -128,7 +123,7 @@ sub getPartyMode { my $name = $self->{name}; - return ReadingsVal( $name, 'partyMode', 'off' ); + return ::ReadingsVal( $name, 'partyMode', 'off' ); } sub getHardLockOut { @@ -136,7 +131,7 @@ sub getHardLockOut { my $name = $self->{name}; - return ReadingsVal( $name, 'hardLockOut', 'none' ); + return ::ReadingsVal( $name, 'hardLockOut', 'none' ); } sub getSunriseTimeWeHoliday { @@ -144,7 +139,7 @@ sub getSunriseTimeWeHoliday { my $name = $self->{name}; - return ReadingsVal( $name, 'sunriseTimeWeHoliday', 'none' ); + return ::ReadingsVal( $name, 'sunriseTimeWeHoliday', 'none' ); } sub getMonitoredDevs { @@ -152,14 +147,14 @@ sub getMonitoredDevs { my $name = $self->{name}; - $self->{monitoredDevs} = ReadingsVal( $name, '.monitoredDevs', 'none' ); + $self->{monitoredDevs} = ::ReadingsVal( $name, '.monitoredDevs', 'none' ); return $self->{monitoredDevs}; } sub getOutTemp { my $self = shift; - return ReadingsVal( + return ::ReadingsVal( $FHEM::Automation::ShuttersControl::ascDev->_getTempSensor, $FHEM::Automation::ShuttersControl::ascDev->getTempSensorReading, -100 ); @@ -169,7 +164,8 @@ sub getResidentsStatus { my $self = shift; my $val = - ReadingsVal( $FHEM::Automation::ShuttersControl::ascDev->_getResidentsDev, + ::ReadingsVal( + $FHEM::Automation::ShuttersControl::ascDev->_getResidentsDev, $FHEM::Automation::ShuttersControl::ascDev->getResidentsReading, 'none' ); @@ -178,7 +174,7 @@ sub getResidentsStatus { return $1 && $1 eq 'pet' ? 'absent' : $2; } elsif ( - ReadingsVal( + ::ReadingsVal( $FHEM::Automation::ShuttersControl::ascDev->_getResidentsDev, 'homealoneType', '-' ) eq 'PET' ) @@ -196,7 +192,8 @@ sub getResidentsLastStatus { my $self = shift; my $val = - ReadingsVal( $FHEM::Automation::ShuttersControl::ascDev->_getResidentsDev, + ::ReadingsVal( + $FHEM::Automation::ShuttersControl::ascDev->_getResidentsDev, 'lastState', 'none' ); if ( $val =~ m{^(?:(.+)_)?(.+)$}xms ) { @@ -204,7 +201,7 @@ sub getResidentsLastStatus { return $1 && $1 eq 'pet' ? 'absent' : $2; } elsif ( - ReadingsVal( + ::ReadingsVal( $FHEM::Automation::ShuttersControl::ascDev->_getResidentsDev, 'lastHomealoneType', '-' ) eq 'PET' ) @@ -223,7 +220,7 @@ sub getAutoShuttersControlShading { my $name = $self->{name}; - return ReadingsVal( $name, 'controlShading', 'none' ); + return ::ReadingsVal( $name, 'controlShading', 'none' ); } sub getSelfDefense { @@ -231,7 +228,7 @@ sub getSelfDefense { my $name = $self->{name}; - return ReadingsVal( $name, 'selfDefense', 'none' ); + return ::ReadingsVal( $name, 'selfDefense', 'none' ); } sub getAzimuth { @@ -239,13 +236,13 @@ sub getAzimuth { my $azimuth; - $azimuth = ReadingsVal( + $azimuth = ::ReadingsVal( $FHEM::Automation::ShuttersControl::ascDev->_getTwilightDevice, 'azimuth', -1 ) if ( $defs{ $FHEM::Automation::ShuttersControl::ascDev->_getTwilightDevice } ->{TYPE} eq 'Twilight' ); - $azimuth = ReadingsVal( + $azimuth = ::ReadingsVal( $FHEM::Automation::ShuttersControl::ascDev->_getTwilightDevice, 'SunAz', -1 ) if ( @@ -260,13 +257,13 @@ sub getElevation { my $elevation; - $elevation = ReadingsVal( + $elevation = ::ReadingsVal( $FHEM::Automation::ShuttersControl::ascDev->_getTwilightDevice, 'elevation', -1 ) if ( $defs{ $FHEM::Automation::ShuttersControl::ascDev->_getTwilightDevice } ->{TYPE} eq 'Twilight' ); - $elevation = ReadingsVal( + $elevation = ::ReadingsVal( $FHEM::Automation::ShuttersControl::ascDev->_getTwilightDevice, 'SunAlt', -1 ) if ( @@ -281,7 +278,7 @@ sub getASCenable { my $name = $self->{name}; - return ReadingsVal( $name, 'ascEnable', 'none' ); + return ::ReadingsVal( $name, 'ascEnable', 'none' ); } 1; diff --git a/fhem/lib/FHEM/Automation/ShuttersControl/EventProcessingFunctions.pm b/fhem/lib/FHEM/Automation/ShuttersControl/EventProcessingFunctions.pm index 10509275e..32eef96e9 100644 --- a/fhem/lib/FHEM/Automation/ShuttersControl/EventProcessingFunctions.pm +++ b/fhem/lib/FHEM/Automation/ShuttersControl/EventProcessingFunctions.pm @@ -1,8 +1,8 @@ ############################################################################### # -# Developed with Kate +# Developed with VSCodium and richterger perl plugin # -# (c) 2018-2021 Copyright: Marko Oldenburg (fhemdevelopment@cooltux.net) +# (c) 2018-2022 Copyright: Marko Oldenburg (fhemdevelopment at cooltux dot net) # All rights reserved # # Special thanks goes to: @@ -52,39 +52,26 @@ use FHEM::Automation::ShuttersControl::Shading qw (:ALL); use FHEM::Automation::ShuttersControl::Rainprotection qw (:ALL); require Exporter; -our @ISA = qw(Exporter); +use base qw(Exporter); + +# our @ISA = qw(Exporter); our @EXPORT_OK = qw( - EventProcessingPartyMode - EventProcessingGeneral - EventProcessingShutters - EventProcessingAdvShuttersClose + EventProcessingPartyMode + EventProcessingGeneral + EventProcessingShutters + EventProcessingAdvShuttersClose ); our %EXPORT_TAGS = ( ALL => [ qw( - EventProcessingPartyMode - EventProcessingGeneral - EventProcessingShutters - EventProcessingAdvShuttersClose + EventProcessingPartyMode + EventProcessingGeneral + EventProcessingShutters + EventProcessingAdvShuttersClose ) ], ); -use GPUtils qw(GP_Import); -## Import der FHEM Funktionen -BEGIN { - GP_Import( - qw( - Log3 - gettimeofday - computeAlignTime - CommandSet - ReadingsVal - RemoveInternalTimer - ) - ); -} - sub EventProcessingGeneral { my $hash = shift; my $devname = shift; @@ -94,8 +81,12 @@ sub EventProcessingGeneral { if ( defined($devname) && ($devname) ) { # es wird lediglich der Devicename der Funktion mitgegeben wenn es sich nicht um global handelt daher hier die Unterscheidung - my $windReading = $FHEM::Automation::ShuttersControl::ascDev->getWindSensorReading // 'none'; - my $rainReading = $FHEM::Automation::ShuttersControl::ascDev->getRainSensorReading // 'none'; + my $windReading = + $FHEM::Automation::ShuttersControl::ascDev->getWindSensorReading + // 'none'; + my $rainReading = + $FHEM::Automation::ShuttersControl::ascDev->getRainSensorReading + // 'none'; while ( my ( $device, $deviceAttr ) = each %{ $hash->{monitoredDevs}{$devname} } ) @@ -122,13 +113,16 @@ sub EventProcessingGeneral { EventProcessingExternalTriggerDevice( $hash, $device, $events ) if ( $deviceAttr eq 'ASC_ExternalTrigger' ); - $FHEM::Automation::ShuttersControl::shutters->setShuttersDev($device) + $FHEM::Automation::ShuttersControl::shutters->setShuttersDev( + $device) if ( $deviceAttr eq 'ASC_BrightnessSensor' ); if ( $deviceAttr eq 'ASC_BrightnessSensor' - && ( $FHEM::Automation::ShuttersControl::shutters->getDown eq 'brightness' - || $FHEM::Automation::ShuttersControl::shutters->getUp eq 'brightness' ) + && ( $FHEM::Automation::ShuttersControl::shutters->getDown eq + 'brightness' + || $FHEM::Automation::ShuttersControl::shutters->getUp eq + 'brightness' ) ) { EventProcessingBrightness( $hash, $device, $events ); @@ -147,8 +141,9 @@ sub EventProcessingGeneral { \s(.*)$}xms ) { # wurde den Attributen unserer Rolläden ein Wert zugewiesen ? - FHEM::Automation::ShuttersControl::AddNotifyDev( $hash, $3, $1, $2 ) if ( $3 ne 'none' ); - Log3( $name, 4, + FHEM::Automation::ShuttersControl::AddNotifyDev( $hash, $3, $1, $2 ) + if ( $3 ne 'none' ); + ::Log3( $name, 4, "AutoShuttersControl ($name) - EventProcessing: ATTR" ); } elsif ( @@ -160,7 +155,7 @@ sub EventProcessingGeneral { $}xms ) { # wurde das Attribut unserer Rolläden gelöscht ? - Log3( $name, 4, + ::Log3( $name, 4, "AutoShuttersControl ($name) - EventProcessing: DELETEATTR" ); FHEM::Automation::ShuttersControl::DeleteNotifyDev( $hash, $1, $2 ); } @@ -175,11 +170,13 @@ sub EventProcessingGeneral { (.*)?}xms ) { - FHEM::Automation::ShuttersControl::CreateSunRiseSetShuttersTimer( $hash, $2 ) + FHEM::Automation::ShuttersControl::CreateSunRiseSetShuttersTimer( + $hash, $2 ) if ( $3 ne 'ASC_Time_Up_WE_Holiday' || ( $3 eq 'ASC_Time_Up_WE_Holiday' - && $FHEM::Automation::ShuttersControl::ascDev->getSunriseTimeWeHoliday eq 'on' ) + && $FHEM::Automation::ShuttersControl::ascDev + ->getSunriseTimeWeHoliday eq 'on' ) ); } elsif ( @@ -189,7 +186,8 @@ sub EventProcessingGeneral { (.*)?}xms ) { - FHEM::Automation::ShuttersControl::RenewSunRiseSetShuttersTimer($hash); + FHEM::Automation::ShuttersControl::RenewSunRiseSetShuttersTimer( + $hash); } elsif ( $events =~ m{^(DELETEATTR|ATTR) @@ -197,7 +195,8 @@ sub EventProcessingGeneral { (.*)?}xms ) { - $FHEM::Automation::ShuttersControl::shutters->deleteShadingStateChangeSunny; + $FHEM::Automation::ShuttersControl::shutters + ->deleteShadingStateChangeSunny; } if ( @@ -210,20 +209,22 @@ m{^(DELETEATTR|ATTR) #global ATTR myASC ASC_tempSensor Cellar (.*)?}xms ) { -# ATTR RolloKinZimSteven_F1 ASC_Shading_Mode off + # ATTR RolloKinZimSteven_F1 ASC_Shading_Mode off if ( $events =~ m{^ATTR\s(.*)\sASC_Shading_Mode\s(off)}xms ) { my %funcHash = ( - hash => $hash, - shuttersdevice => $1, - value => $2, - attrEvent => 1, + hash => $hash, + shuttersdevice => $1, + value => $2, + attrEvent => 1, ); - FHEM::Automation::ShuttersControl::Shading::_CheckShuttersConditionsForShadingFn(\%funcHash); + FHEM::Automation::ShuttersControl::Shading::_CheckShuttersConditionsForShadingFn( + \%funcHash ); } else { - CommandSet( undef, $name . ' controlShading on' ) - if ( ReadingsVal( $name, 'controlShading', 'off' ) ne 'off' ); + ::CommandSet( undef, $name . ' controlShading on' ) + if ( + ::ReadingsVal( $name, 'controlShading', 'off' ) ne 'off' ); } } } @@ -243,9 +244,17 @@ sub EventProcessingWindowRec { $FHEM::Automation::ShuttersControl::shutters->getWinDevReading; if ( $events =~ - m{.*$reading:.*?([Oo]pen(?>ed)?|[Cc]losed?|tilt(?>ed)?|true|false)}xms - && IsAfterShuttersManualBlocking($shuttersDev) ) + m{.*$reading:.*?([Oo]pen(?>ed)?|[Cc]losed?|tilt(?>ed)?|true|false)}xms ) { + return + if ( + !IsAfterShuttersManualBlocking($shuttersDev) + && ( $FHEM::Automation::ShuttersControl::shutters->getLockOut eq + 'off' + || $FHEM::Automation::ShuttersControl::shutters + ->getShuttersPlace ne 'terrace' ) + ); + my $match = $1; FHEM::Automation::ShuttersControl::ASC_Debug( @@ -260,11 +269,6 @@ sub EventProcessingWindowRec { $FHEM::Automation::ShuttersControl::shutters->setShuttersDev( $shuttersDev); - my $homemode = - $FHEM::Automation::ShuttersControl::shutters->getRoommatesStatus; - $homemode = - $FHEM::Automation::ShuttersControl::ascDev->getResidentsStatus - if ( $homemode eq 'none' ); #### Hardware Lock der Rollläden $FHEM::Automation::ShuttersControl::shutters->setHardLockOut('off') @@ -272,9 +276,25 @@ sub EventProcessingWindowRec { && $FHEM::Automation::ShuttersControl::shutters->getShuttersPlace eq 'terrace' ); $FHEM::Automation::ShuttersControl::shutters->setHardLockOut('on') - if ( $match =~ m{[Oo]pen|false}xms + if ( + $match =~ m{[Oo]pen|false}xms && $FHEM::Automation::ShuttersControl::shutters->getShuttersPlace - eq 'terrace' ); + eq 'terrace' + && ( $FHEM::Automation::ShuttersControl::shutters->getStatus == + $FHEM::Automation::ShuttersControl::shutters->getOpenPos + || $FHEM::Automation::ShuttersControl::shutters->getStatus == + $FHEM::Automation::ShuttersControl::shutters->getComfortOpenPos + ) + ); + + return + if ( !IsAfterShuttersManualBlocking($shuttersDev) ); + + my $homemode = + $FHEM::Automation::ShuttersControl::shutters->getRoommatesStatus; + $homemode = + $FHEM::Automation::ShuttersControl::ascDev->getResidentsStatus + if ( $homemode eq 'none' ); FHEM::Automation::ShuttersControl::ASC_Debug( 'EventProcessingWindowRec: ' @@ -283,12 +303,12 @@ sub EventProcessingWindowRec { . $homemode . ' QueryShuttersPosWinRecTilted:' . $FHEM::Automation::ShuttersControl::shutters - ->getQueryShuttersPos( + ->getQueryShuttersPos( $FHEM::Automation::ShuttersControl::shutters->getVentilatePos ) . ' QueryShuttersPosWinRecComfort: ' . $FHEM::Automation::ShuttersControl::shutters - ->getQueryShuttersPos( + ->getQueryShuttersPos( $FHEM::Automation::ShuttersControl::shutters->getComfortOpenPos ) ); @@ -301,41 +321,40 @@ sub EventProcessingWindowRec { $FHEM::Automation::ShuttersControl::shutters->getVentilatePos || $FHEM::Automation::ShuttersControl::shutters->getStatus == $FHEM::Automation::ShuttersControl::shutters->getComfortOpenPos - || ( $FHEM::Automation::ShuttersControl::shutters->getStatus == + || ( $FHEM::Automation::ShuttersControl::shutters->getStatus == $FHEM::Automation::ShuttersControl::shutters->getOpenPos - && $FHEM::Automation::ShuttersControl::shutters->getLastDrive - eq 'ventilate - window open' + && $FHEM::Automation::ShuttersControl::shutters + ->getLastDrive eq 'ventilate - window open' && $FHEM::Automation::ShuttersControl::shutters->getSubTyp - eq 'twostate' - && $FHEM::Automation::ShuttersControl::shutters->getVentilateOpen - eq 'on' ) + eq 'twostate' + && $FHEM::Automation::ShuttersControl::shutters + ->getVentilateOpen eq 'on' ) || ( $FHEM::Automation::ShuttersControl::shutters->getStatus == $FHEM::Automation::ShuttersControl::shutters - ->getPrivacyDownPos + ->getPrivacyDownPos && $FHEM::Automation::ShuttersControl::shutters - ->getPrivacyDownStatus != 2 + ->getPrivacyDownStatus != 2 && !$FHEM::Automation::ShuttersControl::shutters->getIsDay ) - || ( $FHEM::Automation::ShuttersControl::shutters->getStatus == - $FHEM::Automation::ShuttersControl::shutters - ->getOpenPos - && ( $FHEM::Automation::ShuttersControl::shutters - ->getLockOut ne 'off' + || ( + $FHEM::Automation::ShuttersControl::shutters->getStatus == + $FHEM::Automation::ShuttersControl::shutters->getOpenPos + && ( $FHEM::Automation::ShuttersControl::shutters + ->getLockOut ne 'off' || $FHEM::Automation::ShuttersControl::shutters - ->getShuttersPlace eq 'terrace' - ) - && !$FHEM::Automation::ShuttersControl::shutters->getIsDay ) + ->getShuttersPlace eq 'terrace' ) + && !$FHEM::Automation::ShuttersControl::shutters->getIsDay + ) || ( $FHEM::Automation::ShuttersControl::shutters->getStatus == - $FHEM::Automation::ShuttersControl::shutters - ->getOpenPos + $FHEM::Automation::ShuttersControl::shutters->getOpenPos && $FHEM::Automation::ShuttersControl::shutters - ->getDelayCmd ne 'none' + ->getDelayCmd ne 'none' && $FHEM::Automation::ShuttersControl::shutters - ->getShuttersPlace eq 'terrace' ) + ->getShuttersPlace eq 'terrace' ) ) && ( $FHEM::Automation::ShuttersControl::shutters->getVentilateOpen eq 'on' || $FHEM::Automation::ShuttersControl::ascDev - ->getAutoShuttersControlComfort eq 'on' ) + ->getAutoShuttersControlComfort eq 'on' ) ) { FHEM::Automation::ShuttersControl::ASC_Debug( @@ -371,18 +390,19 @@ sub EventProcessingWindowRec { elsif ( !$FHEM::Automation::ShuttersControl::shutters ->getIfInShading - && ( $FHEM::Automation::ShuttersControl::shutters->getStatus + && ( + $FHEM::Automation::ShuttersControl::shutters->getStatus != $FHEM::Automation::ShuttersControl::shutters ->getOpenPos || $FHEM::Automation::ShuttersControl::shutters ->getStatus != $FHEM::Automation::ShuttersControl::shutters ->getLastManPos - || ( $FHEM::Automation::ShuttersControl::shutters - ->getDelayCmd ne 'none' + || ( $FHEM::Automation::ShuttersControl::shutters + ->getDelayCmd ne 'none' && $FHEM::Automation::ShuttersControl::shutters - ->getShuttersPlace eq 'terrace' ) - ) + ->getShuttersPlace eq 'terrace' ) + ) ) { if ( $FHEM::Automation::ShuttersControl::shutters @@ -407,40 +427,44 @@ sub EventProcessingWindowRec { ->setDriveCmd( ( $FHEM::Automation::ShuttersControl::shutters - ->getDelayCmd ne 'none' + ->getDelayCmd ne 'none' && $FHEM::Automation::ShuttersControl::shutters - ->getShuttersPlace eq 'terrace' + ->getShuttersPlace eq 'terrace' ? $FHEM::Automation::ShuttersControl::shutters - ->getDelayCmd - : ( $FHEM::Automation::ShuttersControl::shutters + ->getDelayCmd + : ( + $FHEM::Automation::ShuttersControl::shutters ->getVentilatePosAfterDayClosed eq 'open' - ? $FHEM::Automation::ShuttersControl::shutters - ->getOpenPos - : $FHEM::Automation::ShuttersControl::shutters - ->getLastManPos ) + ? $FHEM::Automation::ShuttersControl::shutters + ->getOpenPos + : $FHEM::Automation::ShuttersControl::shutters + ->getLastManPos + ) ) ); } } } elsif ( - !$FHEM::Automation::ShuttersControl::shutters->getIsDay - && $FHEM::Automation::ShuttersControl::shutters->getModeDown eq 'roommate' - && ( $FHEM::Automation::ShuttersControl::shutters->getRoommatesStatus eq 'home' - || $FHEM::Automation::ShuttersControl::shutters->getRoommatesStatus eq 'awoken' ) + !$FHEM::Automation::ShuttersControl::shutters->getIsDay + && $FHEM::Automation::ShuttersControl::shutters->getModeDown eq + 'roommate' + && ( $FHEM::Automation::ShuttersControl::shutters + ->getRoommatesStatus eq 'home' + || $FHEM::Automation::ShuttersControl::shutters + ->getRoommatesStatus eq 'awoken' ) ) { - $FHEM::Automation::ShuttersControl::shutters - ->setDriveCmd( - ( - $FHEM::Automation::ShuttersControl::shutters - ->getVentilatePosAfterDayClosed eq 'open' - ? $FHEM::Automation::ShuttersControl::shutters - ->getOpenPos - : $FHEM::Automation::ShuttersControl::shutters - ->getLastManPos - ) - ); + $FHEM::Automation::ShuttersControl::shutters->setDriveCmd( + ( + $FHEM::Automation::ShuttersControl::shutters + ->getVentilatePosAfterDayClosed eq 'open' + ? $FHEM::Automation::ShuttersControl::shutters + ->getOpenPos + : $FHEM::Automation::ShuttersControl::shutters + ->getLastManPos + ) + ); } elsif ( $FHEM::Automation::ShuttersControl::shutters->getModeDown ne @@ -495,9 +519,16 @@ sub EventProcessingWindowRec { ) && $FHEM::Automation::ShuttersControl::shutters->getVentilateOpen eq 'on' - && $FHEM::Automation::ShuttersControl::shutters - ->getQueryShuttersPos( - $FHEM::Automation::ShuttersControl::shutters->getVentilatePos + && ( + $FHEM::Automation::ShuttersControl::shutters + ->getQueryShuttersPos( + $FHEM::Automation::ShuttersControl::shutters + ->getVentilatePos + ) + || ( $FHEM::Automation::ShuttersControl::shutters + ->getShuttersPlace eq 'terrace' + && $FHEM::Automation::ShuttersControl::shutters->getSubTyp + eq 'twostate' ) ) ) { @@ -528,7 +559,7 @@ sub EventProcessingWindowRec { if ( $FHEM::Automation::ShuttersControl::ascDev ->getAutoShuttersControlComfort eq 'on' - and $FHEM::Automation::ShuttersControl::shutters + && $FHEM::Automation::ShuttersControl::shutters ->getQueryShuttersPos( $FHEM::Automation::ShuttersControl::shutters ->getComfortOpenPos @@ -580,14 +611,15 @@ sub EventProcessingRoommate { $FHEM::Automation::ShuttersControl::shutters->getRoommatesReading; if ( $events =~ m{$reading:\s(absent|gotosleep|asleep|awoken|home)}xms ) { - Log3( $name, 4, + ::Log3( $name, 4, "AutoShuttersControl ($name) - EventProcessingRoommate: " . $FHEM::Automation::ShuttersControl::shutters ->getRoommatesReading ); - Log3( $name, 4, + ::Log3( $name, 4, "AutoShuttersControl ($name) - EventProcessingRoommate: $shuttersDev und Events $events" ); + my $event = $1; my $getModeUp = $FHEM::Automation::ShuttersControl::shutters->getModeUp; my $getModeDown = $FHEM::Automation::ShuttersControl::shutters->getModeDown; @@ -595,21 +627,30 @@ sub EventProcessingRoommate { $FHEM::Automation::ShuttersControl::shutters->getRoommatesStatus; my $getRoommatesLastStatus = $FHEM::Automation::ShuttersControl::shutters->getRoommatesLastStatus; - my $event = $1; - my $posValue = $FHEM::Automation::ShuttersControl::shutters->getStatus; + my $getUp = $FHEM::Automation::ShuttersControl::shutters->getUp; + my $getDown = $FHEM::Automation::ShuttersControl::shutters->getDown; + my $getIsDay = $FHEM::Automation::ShuttersControl::shutters->getIsDay; + + my $posValue = $FHEM::Automation::ShuttersControl::shutters + ->getStatus; # !!! ACHTUNG!!! if ( ( $event eq 'home' || $event eq 'awoken' ) && ( $getRoommatesStatus eq 'home' || $getRoommatesStatus eq 'awoken' ) - && ( $FHEM::Automation::ShuttersControl::ascDev + && ( + $FHEM::Automation::ShuttersControl::ascDev ->getAutoShuttersControlMorning eq 'on' - || $FHEM::Automation::ShuttersControl::shutters->getUp eq - 'roommate' ) + || ( + $getUp eq 'roommate' + && ( $getRoommatesLastStatus eq 'asleep' + || $getRoommatesLastStatus ne 'awoken' ) + ) + ) && IsAfterShuttersManualBlocking($shuttersDev) ) { - Log3( $name, 4, + ::Log3( $name, 4, "AutoShuttersControl ($name) - EventProcessingRoommate_1: $shuttersDev und Events $events" ); if ( @@ -618,26 +659,24 @@ sub EventProcessingRoommate { $getRoommatesLastStatus eq 'asleep' && ( $FHEM::Automation::ShuttersControl::shutters ->getModeUp eq 'always' - or $FHEM::Automation::ShuttersControl::shutters + || $FHEM::Automation::ShuttersControl::shutters ->getModeUp eq $event ) ) || ( $getRoommatesLastStatus eq 'awoken' && ( $FHEM::Automation::ShuttersControl::shutters ->getModeUp eq 'always' - or $FHEM::Automation::ShuttersControl::shutters + || $FHEM::Automation::ShuttersControl::shutters ->getModeUp eq $event ) ) ) - && ( $FHEM::Automation::ShuttersControl::shutters->getIsDay - || $FHEM::Automation::ShuttersControl::shutters->getUp eq - 'roommate' ) + && ( $getIsDay + || $getUp eq 'roommate' ) && ( IsAfterShuttersTimeBlocking($shuttersDev) - || $FHEM::Automation::ShuttersControl::shutters->getUp eq - 'roommate' ) + || $getUp eq 'roommate' ) ) { - Log3( $name, 4, + ::Log3( $name, 4, "AutoShuttersControl ($name) - EventProcessingRoommate_2: $shuttersDev und Events $events" ); @@ -675,7 +714,7 @@ sub EventProcessingRoommate { ) { if ( - $FHEM::Automation::ShuttersControl::shutters->getIsDay + $getIsDay && $FHEM::Automation::ShuttersControl::shutters ->getIfInShading && $FHEM::Automation::ShuttersControl::shutters->getStatus @@ -695,12 +734,11 @@ sub EventProcessingRoommate { ShadingProcessingDriveCommand( $hash, $shuttersDev, 1 ); } elsif ( - !$FHEM::Automation::ShuttersControl::shutters->getIsDay + !$getIsDay && IsAfterShuttersTimeBlocking($shuttersDev) && ( $getModeDown eq 'home' || $getModeDown eq 'always' ) - && $FHEM::Automation::ShuttersControl::shutters->getDown ne - 'roommate' + && $getDown ne 'roommate' ) { $FHEM::Automation::ShuttersControl::shutters->setLastDrive( @@ -738,11 +776,7 @@ sub EventProcessingRoommate { $hash, $shuttersDev, $posValue ); } elsif ( - ( - $FHEM::Automation::ShuttersControl::shutters->getIsDay - || $FHEM::Automation::ShuttersControl::shutters->getUp - eq 'roommate' - ) + ( $getIsDay || $getUp eq 'roommate' ) && IsAfterShuttersTimeBlocking($shuttersDev) && ( $getModeUp eq 'home' || $getModeUp eq 'always' ) @@ -821,14 +855,12 @@ sub EventProcessingRoommate { elsif ( ( $event eq 'gotosleep' || $event eq 'asleep' ) && $FHEM::Automation::ShuttersControl::shutters->getModeDown ne - 'absent' + 'absent' && ( $FHEM::Automation::ShuttersControl::ascDev ->getAutoShuttersControlEvening eq 'on' - || $FHEM::Automation::ShuttersControl::shutters->getDown eq - 'roommate' ) + || $getDown eq 'roommate' ) && ( IsAfterShuttersManualBlocking($shuttersDev) - || $FHEM::Automation::ShuttersControl::shutters->getDown eq - 'roommate' ) + || $getDown eq 'roommate' ) ) { $FHEM::Automation::ShuttersControl::shutters->setLastDrive( @@ -858,9 +890,8 @@ sub EventProcessingRoommate { } elsif ( $event eq 'absent' - && ( !$FHEM::Automation::ShuttersControl::shutters->getIsDay - || $FHEM::Automation::ShuttersControl::shutters->getDown eq - 'roommate' + && ( !$getIsDay + || $getDown eq 'roommate' || $FHEM::Automation::ShuttersControl::shutters->getShadingMode eq 'absent' || $FHEM::Automation::ShuttersControl::shutters->getModeUp eq @@ -869,16 +900,12 @@ sub EventProcessingRoommate { 'absent' ) ) { - Log3( $name, 4, + ::Log3( $name, 4, "AutoShuttersControl ($name) - EventProcessingRoommate absent: $shuttersDev" ); if ( - ( - $FHEM::Automation::ShuttersControl::shutters->getIsDay - || $FHEM::Automation::ShuttersControl::shutters->getUp eq - 'roommate' - ) + $getIsDay && $FHEM::Automation::ShuttersControl::shutters->getIfInShading && !$FHEM::Automation::ShuttersControl::shutters ->getQueryShuttersPos( @@ -888,7 +915,7 @@ sub EventProcessingRoommate { eq 'absent' ) { - Log3( $name, 4, + ::Log3( $name, 4, "AutoShuttersControl ($name) - EventProcessingRoommate Shading: $shuttersDev" ); @@ -900,17 +927,11 @@ sub EventProcessingRoommate { $FHEM::Automation::ShuttersControl::shutters->getShadingPos ); } - elsif ( - ( - !$FHEM::Automation::ShuttersControl::shutters->getIsDay - || $FHEM::Automation::ShuttersControl::shutters->getDown eq - 'roommate' - ) + elsif (( !$getIsDay || $getDown eq 'roommate' ) && $getModeDown eq 'absent' - && $getRoommatesStatus eq 'absent' - ) + && $getRoommatesStatus eq 'absent' ) { - Log3( $name, 4, + ::Log3( $name, 4, "AutoShuttersControl ($name) - EventProcessingRoommate Down: $shuttersDev" ); @@ -922,12 +943,12 @@ sub EventProcessingRoommate { $FHEM::Automation::ShuttersControl::shutters->getClosedPos ); } - elsif ($FHEM::Automation::ShuttersControl::shutters->getIsDay + elsif ($getIsDay && $FHEM::Automation::ShuttersControl::shutters->getModeUp eq 'absent' && $getRoommatesStatus eq 'absent' ) { - Log3( $name, 4, + ::Log3( $name, 4, "AutoShuttersControl ($name) - EventProcessingRoommate Up: $shuttersDev" ); @@ -938,7 +959,7 @@ sub EventProcessingRoommate { $FHEM::Automation::ShuttersControl::shutters->getOpenPos ); } - Log3( $name, 4, + ::Log3( $name, 4, "AutoShuttersControl ($name) - EventProcessingRoommate NICHTS: $shuttersDev" ); } @@ -975,6 +996,7 @@ sub EventProcessingResidents { && $FHEM::Automation::ShuttersControl::shutters ->getSelfDefenseMode ne 'off' || $getModeDown eq 'absent' + # || $getModeDown eq 'always' ) Wird zu Testzwecken auskommentiert, siehe #90 Github || ( $FHEM::Automation::ShuttersControl::shutters ->getShadingMode eq 'absent' @@ -992,15 +1014,17 @@ sub EventProcessingResidents { && ( $FHEM::Automation::ShuttersControl::shutters ->getSelfDefenseMode eq 'absent' - || ( CheckIfShuttersWindowRecOpen($shuttersDev) == 2 + || ( + CheckIfShuttersWindowRecOpen($shuttersDev) == 2 && $FHEM::Automation::ShuttersControl::shutters ->getSelfDefenseMode eq 'gone' && ( $FHEM::Automation::ShuttersControl::shutters ->getShuttersPlace eq 'terrace' - || $FHEM::Automation::ShuttersControl::shutters + || $FHEM::Automation::ShuttersControl::shutters ->getShuttersPlace eq 'EG_window' ) && $FHEM::Automation::ShuttersControl::shutters - ->getSelfDefenseMode ne 'off' ) + ->getSelfDefenseMode ne 'off' + ) ) ) { @@ -1051,11 +1075,14 @@ sub EventProcessingResidents { $FHEM::Automation::ShuttersControl::shutters ->getLastPos ); } - elsif ( $getModeDown eq 'absent' # || $getModeDown eq 'always' ) Wird zu Testzwecken auskommentiert, siehe #90 Github + elsif ( + $getModeDown eq + 'absent' # || $getModeDown eq 'always' ) Wird zu Testzwecken auskommentiert, siehe #90 Github && !$FHEM::Automation::ShuttersControl::shutters->getIsDay && IsAfterShuttersTimeBlocking($shuttersDev) && $FHEM::Automation::ShuttersControl::shutters - ->getRoommatesStatus eq 'none' ) + ->getRoommatesStatus eq 'none' + ) { $FHEM::Automation::ShuttersControl::shutters->setLastDrive( 'residents absent'); @@ -1115,6 +1142,8 @@ sub EventProcessingResidents { ->getRoommatesStatus eq 'none' && ( $getModeDown eq 'home' || $getModeDown eq 'always' ) + && $FHEM::Automation::ShuttersControl::ascDev + ->getAutoShuttersControlEvening eq 'on' && $getResidentsLastStatus ne 'asleep' && $getResidentsLastStatus ne 'awoken' && IsAfterShuttersTimeBlocking($shuttersDev) @@ -1198,7 +1227,7 @@ sub EventProcessingResidents { ->getSelfDefenseState ) { - RemoveInternalTimer( + ::RemoveInternalTimer( $FHEM::Automation::ShuttersControl::shutters ->getSelfDefenseAbsentTimerhash ) if ( $getResidentsLastStatus eq 'absent' @@ -1262,6 +1291,8 @@ sub EventProcessingResidents { ->getRoommatesStatus eq 'none' && ( $getModeUp eq 'home' || $getModeUp eq 'always' ) + && $FHEM::Automation::ShuttersControl::ascDev + ->getAutoShuttersControlMorning eq 'on' && IsAfterShuttersTimeBlocking($shuttersDev) && !$FHEM::Automation::ShuttersControl::shutters->getIfInShading && !$FHEM::Automation::ShuttersControl::shutters @@ -1380,8 +1411,9 @@ sub EventProcessingWind { $FHEM::Automation::ShuttersControl::shutters->getIsDay ? $FHEM::Automation::ShuttersControl::shutters ->getLastPos - : ( $FHEM::Automation::ShuttersControl::shutters->getShuttersPlace - eq 'awning' + : ( + $FHEM::Automation::ShuttersControl::shutters + ->getShuttersPlace eq 'awning' ? $FHEM::Automation::ShuttersControl::shutters ->getOpenPos : ( @@ -1456,8 +1488,8 @@ sub EventProcessingBrightness { ( ( ( - int( gettimeofday() / 86400 ) == int( - computeAlignTime( + int( ::gettimeofday() / 86400 ) == int( + ::computeAlignTime( '24:00', $FHEM::Automation::ShuttersControl::shutters ->getTimeUpEarly @@ -1478,8 +1510,8 @@ sub EventProcessingBrightness { ) ) || ( - int( gettimeofday() / 86400 ) == int( - computeAlignTime( + int( ::gettimeofday() / 86400 ) == int( + ::computeAlignTime( '24:00', $FHEM::Automation::ShuttersControl::shutters ->getTimeUpWeHoliday @@ -1492,8 +1524,8 @@ sub EventProcessingBrightness { ->getTimeUpWeHoliday ne '01:25' ) ) - && int( gettimeofday() / 86400 ) == int( - computeAlignTime( + && int( ::gettimeofday() / 86400 ) == int( + ::computeAlignTime( '24:00', $FHEM::Automation::ShuttersControl::shutters ->getTimeUpLate @@ -1502,8 +1534,8 @@ sub EventProcessingBrightness { || ( ( - int( gettimeofday() / 86400 ) != int( - computeAlignTime( + int( ::gettimeofday() / 86400 ) != int( + ::computeAlignTime( '24:00', $FHEM::Automation::ShuttersControl::shutters ->getTimeUpEarly @@ -1524,8 +1556,8 @@ sub EventProcessingBrightness { ) ) || ( - int( gettimeofday() / 86400 ) != int( - computeAlignTime( + int( ::gettimeofday() / 86400 ) != int( + ::computeAlignTime( '24:00', $FHEM::Automation::ShuttersControl::shutters ->getTimeUpWeHoliday @@ -1538,8 +1570,8 @@ sub EventProcessingBrightness { ->getTimeUpWeHoliday ne '01:25' ) ) - && int( gettimeofday() / 86400 ) != int( - computeAlignTime( + && int( ::gettimeofday() / 86400 ) != int( + ::computeAlignTime( '24:00', $FHEM::Automation::ShuttersControl::shutters ->getTimeUpLate @@ -1548,15 +1580,15 @@ sub EventProcessingBrightness { ) && ( ( - int( gettimeofday() / 86400 ) == int( - computeAlignTime( + int( ::gettimeofday() / 86400 ) == int( + ::computeAlignTime( '24:00', $FHEM::Automation::ShuttersControl::shutters ->getTimeDownEarly ) / 86400 ) - && int( gettimeofday() / 86400 ) == int( - computeAlignTime( + && int( ::gettimeofday() / 86400 ) == int( + ::computeAlignTime( '24:00', $FHEM::Automation::ShuttersControl::shutters ->getTimeDownLate @@ -1564,15 +1596,15 @@ sub EventProcessingBrightness { ) ) || ( - int( gettimeofday() / 86400 ) != int( - computeAlignTime( + int( ::gettimeofday() / 86400 ) != int( + ::computeAlignTime( '24:00', $FHEM::Automation::ShuttersControl::shutters ->getTimeDownEarly ) / 86400 ) - && int( gettimeofday() / 86400 ) != int( - computeAlignTime( + && int( ::gettimeofday() / 86400 ) != int( + ::computeAlignTime( '24:00', $FHEM::Automation::ShuttersControl::shutters ->getTimeDownLate @@ -1645,8 +1677,8 @@ sub EventProcessingBrightness { ( ( ( - int( gettimeofday() / 86400 ) != int( - computeAlignTime( + int( ::gettimeofday() / 86400 ) != int( + ::computeAlignTime( '24:00', $FHEM::Automation::ShuttersControl::shutters ->getTimeUpEarly @@ -1666,8 +1698,8 @@ sub EventProcessingBrightness { ) ) || ( - int( gettimeofday() / 86400 ) != int( - computeAlignTime( + int( ::gettimeofday() / 86400 ) != int( + ::computeAlignTime( '24:00', $FHEM::Automation::ShuttersControl::shutters ->getTimeUpWeHoliday @@ -1680,8 +1712,8 @@ sub EventProcessingBrightness { ->getTimeUpWeHoliday ne '01:25' ) ) - && int( gettimeofday() / 86400 ) == int( - computeAlignTime( + && int( ::gettimeofday() / 86400 ) == int( + ::computeAlignTime( '24:00', $FHEM::Automation::ShuttersControl::shutters ->getTimeUpLate @@ -1711,7 +1743,7 @@ sub EventProcessingBrightness { ) ) { - Log3( $name, 4, + ::Log3( $name, 4, "AutoShuttersControl ($shuttersDev) - EventProcessingBrightness: Steuerung für Morgens" ); @@ -1792,7 +1824,8 @@ sub EventProcessingBrightness { . $FHEM::Automation::ShuttersControl::shutters ->getLastDrive ); - FHEM::Automation::ShuttersControl::CreateSunRiseSetShuttersTimer( $hash, $shuttersDev ); + FHEM::Automation::ShuttersControl::CreateSunRiseSetShuttersTimer( + $hash, $shuttersDev ); } else { $FHEM::Automation::ShuttersControl::shutters @@ -1835,13 +1868,15 @@ sub EventProcessingBrightness { } } elsif ( - int( gettimeofday() / 86400 ) != int( - computeAlignTime( '24:00', + int( ::gettimeofday() / 86400 ) != int( + ::computeAlignTime( + '24:00', $FHEM::Automation::ShuttersControl::shutters - ->getTimeDownEarly ) / 86400 + ->getTimeDownEarly + ) / 86400 ) - && int( gettimeofday() / 86400 ) == int( - computeAlignTime( + && int( ::gettimeofday() / 86400 ) == int( + ::computeAlignTime( '24:00', $FHEM::Automation::ShuttersControl::shutters ->getTimeDownLate @@ -1861,7 +1896,7 @@ sub EventProcessingBrightness { ->getAutoShuttersControlEvening eq 'on' ) { - Log3( $name, 4, + ::Log3( $name, 4, "AutoShuttersControl ($shuttersDev) - EventProcessingBrightness: Steuerung für Abends" ); @@ -1969,10 +2004,8 @@ sub EventProcessingBrightness { $FHEM::Automation::ShuttersControl::shutters->setLastDrive( $lastDrive); - if ( - $FHEM::Automation::ShuttersControl::shutters - ->getPrivacyDownStatus != 2 - ) + if ( $FHEM::Automation::ShuttersControl::shutters + ->getPrivacyDownStatus != 2 ) { $FHEM::Automation::ShuttersControl::shutters->setSunrise(0); $FHEM::Automation::ShuttersControl::shutters->setSunset(1); @@ -2042,7 +2075,7 @@ sub EventProcessingShadingBrightness { : $FHEM::Automation::ShuttersControl::ascDev->getOutTemp ); - Log3( $name, 4, + ::Log3( $name, 4, "AutoShuttersControl ($shuttersDev) - EventProcessingShadingBrightness" ); @@ -2053,7 +2086,7 @@ sub EventProcessingShadingBrightness { ); if ( $events =~ m{$reading:\s(\d+(\.\d+)?)}xms ) { - Log3( + ::Log3( $name, 4, "AutoShuttersControl ($shuttersDev) - EventProcessingShadingBrightness Brightness: " . $1 @@ -2162,17 +2195,17 @@ sub EventProcessingTwilightDevice { . $FHEM::Automation::ShuttersControl::shutters->getShuttersDev . ' RainProtection: ' . $FHEM::Automation::ShuttersControl::shutters - ->getRainProtectionStatus + ->getRainProtectionStatus . ' WindProtection: ' . $FHEM::Automation::ShuttersControl::shutters - ->getWindProtectionStatus ); + ->getWindProtectionStatus ); - if ( $FHEM::Automation::ShuttersControl::ascDev - ->getAutoShuttersControlShading eq 'on' + if ( $FHEM::Automation::ShuttersControl::ascDev + ->getAutoShuttersControlShading eq 'on' && $FHEM::Automation::ShuttersControl::shutters - ->getRainProtectionStatus eq 'unprotected' + ->getRainProtectionStatus eq 'unprotected' && $FHEM::Automation::ShuttersControl::shutters - ->getWindProtectionStatus eq 'unprotected' ) + ->getWindProtectionStatus eq 'unprotected' ) { ShadingProcessing( $hash, @@ -2220,18 +2253,18 @@ sub EventProcessingPartyMode { && $FHEM::Automation::ShuttersControl::shutters->getSubTyp eq 'threestate' ) { - Log3( $name, 4, + ::Log3( $name, 4, "AutoShuttersControl ($name) - EventProcessingPartyMode Fenster offen" ); $FHEM::Automation::ShuttersControl::shutters->setDelayCmd( $FHEM::Automation::ShuttersControl::shutters->getClosedPos ); - Log3( $name, 4, + ::Log3( $name, 4, "AutoShuttersControl ($name) - EventProcessingPartyMode - Spring in ShuttersCommandDelaySet" ); } else { - Log3( $name, 4, + ::Log3( $name, 4, "AutoShuttersControl ($name) - EventProcessingPartyMode Fenster nicht offen" ); $FHEM::Automation::ShuttersControl::shutters->setLastDrive( @@ -2241,12 +2274,14 @@ sub EventProcessingPartyMode { $shuttersDev, ( CheckIfShuttersWindowRecOpen($shuttersDev) == 0 - ? ($FHEM::Automation::ShuttersControl::shutters + ? ( + $FHEM::Automation::ShuttersControl::shutters ->getSleepPos > 0 ? $FHEM::Automation::ShuttersControl::shutters - ->getSleepPos + ->getSleepPos : $FHEM::Automation::ShuttersControl::shutters - ->getClosedPos) + ->getClosedPos + ) : $FHEM::Automation::ShuttersControl::shutters ->getVentilatePos ) @@ -2254,7 +2289,7 @@ sub EventProcessingPartyMode { } } elsif ( - $FHEM::Automation::ShuttersControl::shutters->getDelayCmd ne 'none' + $FHEM::Automation::ShuttersControl::shutters->getDelayCmd ne 'none' && $FHEM::Automation::ShuttersControl::shutters->getIsDay && IsAfterShuttersManualBlocking($shuttersDev) ) { @@ -2320,8 +2355,8 @@ sub EventProcessingShutters { 'EventProcessingShutters: ' . $FHEM::Automation::ShuttersControl::shutters->getShuttersDev . ' - Event vom Rollo erkannt. Es wird nun eine etwaige manuelle Fahrt ausgewertet.' - . ' Int von gettimeofday: ' - . int( gettimeofday() ) + . ' Int von ::gettimeofday: ' + . int( ::gettimeofday() ) . ' Last Position Timestamp: ' . $FHEM::Automation::ShuttersControl::shutters ->getLastPosTimestamp @@ -2335,13 +2370,13 @@ sub EventProcessingShutters { if ( ( - int( gettimeofday() ) - + int( ::gettimeofday() ) - $FHEM::Automation::ShuttersControl::shutters ->getLastPosTimestamp ) > $FHEM::Automation::ShuttersControl::shutters->getDriveUpMaxDuration && ( - int( gettimeofday() ) - + int( ::gettimeofday() ) - $FHEM::Automation::ShuttersControl::shutters ->getLastManPosTimestamp ) > $FHEM::Automation::ShuttersControl::shutters->getDriveUpMaxDuration @@ -2366,6 +2401,22 @@ sub EventProcessingShutters { $FHEM::Automation::ShuttersControl::shutters->setLastDriveReading; $FHEM::Automation::ShuttersControl::ascDev->setStateReading; + $FHEM::Automation::ShuttersControl::shutters->setHardLockOut('on') + if ( + ( + $FHEM::Automation::ShuttersControl::shutters->getStatus == + $FHEM::Automation::ShuttersControl::shutters + ->getComfortOpenPos + || ( $FHEM::Automation::ShuttersControl::shutters->getStatus + == $FHEM::Automation::ShuttersControl::shutters + ->getOpenPos + && $FHEM::Automation::ShuttersControl::shutters + ->getLastDrive eq 'ventilate - window open' ) + ) + && $FHEM::Automation::ShuttersControl::shutters + ->getShuttersPlace eq 'terrace' + ); + FHEM::Automation::ShuttersControl::ASC_Debug( 'EventProcessingShutters: eine automatisierte Fahrt durch ASC wurde erkannt! Es werden nun die LastDriveReading und StateReading Werte gesetzt!' ); @@ -2478,7 +2529,4 @@ sub EventProcessingExternalTriggerDevice { return; } - - - 1; diff --git a/fhem/lib/FHEM/Automation/ShuttersControl/Helper.pm b/fhem/lib/FHEM/Automation/ShuttersControl/Helper.pm index a6ff9168d..cd587fd7c 100644 --- a/fhem/lib/FHEM/Automation/ShuttersControl/Helper.pm +++ b/fhem/lib/FHEM/Automation/ShuttersControl/Helper.pm @@ -1,8 +1,8 @@ ############################################################################### # -# Developed with Kate +# Developed with VSCodium and richterger perl plugin # -# (c) 2018-2021 Copyright: Marko Oldenburg (fhemsupport@cooltux.net) +# (c) 2018-2022 Copyright: Marko Oldenburg (fhemdevelopment at cooltux dot net) # All rights reserved # # Special thanks goes to: @@ -46,7 +46,9 @@ use POSIX qw(strftime); use utf8; require Exporter; -our @ISA = qw(Exporter); +use base qw(Exporter); + +# our @ISA = qw(Exporter); our @EXPORT_OK = qw( PositionValueWindowRec AutoSearchTwilightDev @@ -89,21 +91,7 @@ our %EXPORT_TAGS = ( use GPUtils qw(GP_Import); ## Import der FHEM Funktionen BEGIN { - GP_Import( - qw( - devspec2array - CommandAttr - AttrVal - Log3 - computeAlignTime - gettimeofday - sunset - sunset_abs - sunrise - sunrise_abs - cmdFromAnalyze - ) - ); + GP_Import(qw(cmdFromAnalyze)); } sub PositionValueWindowRec { @@ -156,12 +144,12 @@ sub AutoSearchTwilightDev { my $name = $hash->{NAME}; - if ( devspec2array('TYPE=(Astro|Twilight)') > 0 ) { - CommandAttr( undef, + if ( ::devspec2array('TYPE=(Astro|Twilight)') > 0 ) { + ::CommandAttr( undef, $name . ' ASC_twilightDevice ' - . ( devspec2array('TYPE=(Astro|Twilight)') )[0] ) - if ( AttrVal( $name, 'ASC_twilightDevice', 'none' ) eq 'none' ); + . ( ::devspec2array('TYPE=(Astro|Twilight)') )[0] ) + if ( ::AttrVal( $name, 'ASC_twilightDevice', 'none' ) eq 'none' ); } return; @@ -172,8 +160,10 @@ sub GetAttrValues { my $attribut = shift; my $default = shift; - my @values = split( ' ', - AttrVal( $dev, $attribut, ( defined($default) ? $default : 'none' ) ) ); + my @values = split( + ' ', + ::AttrVal( $dev, $attribut, ( defined($default) ? $default : 'none' ) ) + ); my ( $value1, $value2 ) = split( ':', $values[0] ); my ( $value3, $value4, $value5, $value6, $value7, $value8 ); @@ -227,10 +217,10 @@ sub ExtractNotifyDevFromEvent { my %notifyDevs; while ( my $notifyDev = each %{ $hash->{monitoredDevs} } ) { - Log3( $hash->{NAME}, 4, + ::Log3( $hash->{NAME}, 4, "AutoShuttersControl ($hash->{NAME}) - ExtractNotifyDevFromEvent - NotifyDev: " . $notifyDev ); - Log3( $hash->{NAME}, 5, + ::Log3( $hash->{NAME}, 5, "AutoShuttersControl ($hash->{NAME}) - ExtractNotifyDevFromEvent - ShuttersDev: " . $shuttersDev ); @@ -238,10 +228,10 @@ sub ExtractNotifyDevFromEvent { && $hash->{monitoredDevs}{$notifyDev}{$shuttersDev} eq $shuttersAttr ) { - Log3( $hash->{NAME}, 4, + ::Log3( $hash->{NAME}, 4, "AutoShuttersControl ($hash->{NAME}) - ExtractNotifyDevFromEvent - ShuttersDevHash: " . $hash->{monitoredDevs}{$notifyDev}{$shuttersDev} ); - Log3( $hash->{NAME}, 5, + ::Log3( $hash->{NAME}, 5, "AutoShuttersControl ($hash->{NAME}) - ExtractNotifyDevFromEvent - return ShuttersDev: " . $notifyDev ); $notifyDevs{$notifyDev} = $shuttersDev; @@ -279,24 +269,27 @@ sub _IsDay { ( ( ( - int( gettimeofday() / 86400 ) != int( - computeAlignTime( '24:00', + int( ::gettimeofday() / 86400 ) != int( + ::computeAlignTime( + '24:00', $FHEM::Automation::ShuttersControl::shutters - ->getTimeUpEarly ) / 86400 + ->getTimeUpEarly + ) / 86400 ) - && ( !IsWe() - || ( IsWe() - && ( $FHEM::Automation::ShuttersControl::ascDev - ->getSunriseTimeWeHoliday eq 'off' - || $FHEM::Automation::ShuttersControl::shutters - ->getTimeUpWeHoliday eq '01:25' - ) - ) + && ( + !IsWe() + || ( + IsWe() + && ( $FHEM::Automation::ShuttersControl::ascDev + ->getSunriseTimeWeHoliday eq 'off' + || $FHEM::Automation::ShuttersControl::shutters + ->getTimeUpWeHoliday eq '01:25' ) ) + ) ) || ( - int( gettimeofday() / 86400 ) != int( - computeAlignTime( + int( ::gettimeofday() / 86400 ) != int( + ::computeAlignTime( '24:00', $FHEM::Automation::ShuttersControl::shutters ->getTimeUpWeHoliday @@ -309,23 +302,23 @@ sub _IsDay { ->getTimeUpWeHoliday ne '01:25' ) ) - && int( gettimeofday() / 86400 ) == int( - computeAlignTime( + && int( ::gettimeofday() / 86400 ) == int( + ::computeAlignTime( '24:00', $FHEM::Automation::ShuttersControl::shutters->getTimeUpLate ) / 86400 ) ) || ( - int( gettimeofday() / 86400 ) != int( - computeAlignTime( + int( ::gettimeofday() / 86400 ) != int( + ::computeAlignTime( '24:00', $FHEM::Automation::ShuttersControl::shutters ->getTimeDownEarly ) / 86400 ) - && int( gettimeofday() / 86400 ) == int( - computeAlignTime( + && int( ::gettimeofday() / 86400 ) == int( + ::computeAlignTime( '24:00', $FHEM::Automation::ShuttersControl::shutters ->getTimeDownLate @@ -390,19 +383,24 @@ sub _IsDay { . $FHEM::Automation::ShuttersControl::shutters->getSunrise ); } - $respIsDay = 1 if ( - ( $FHEM::Automation::ShuttersControl::shutters->getDown eq 'roommate' - and ( $FHEM::Automation::ShuttersControl::shutters->getRoommates ne 'asleep' - or $FHEM::Automation::ShuttersControl::shutters->getRoommates ne 'gotosleep' ) - ) - or ( $FHEM::Automation::ShuttersControl::shutters->getUp eq 'roommate' - and ( $FHEM::Automation::ShuttersControl::shutters->getRoommates ne 'asleep' - or $FHEM::Automation::ShuttersControl::shutters->getRoommates ne 'gotosleep' ) - ) + ( + $FHEM::Automation::ShuttersControl::shutters->getDown eq 'roommate' + and ( $FHEM::Automation::ShuttersControl::shutters->getRoommates ne + 'asleep' + or $FHEM::Automation::ShuttersControl::shutters->getRoommates + ne 'gotosleep' ) + ) + or ( + $FHEM::Automation::ShuttersControl::shutters->getUp eq 'roommate' + and ( $FHEM::Automation::ShuttersControl::shutters->getRoommates ne + 'asleep' + or $FHEM::Automation::ShuttersControl::shutters->getRoommates + ne 'gotosleep' ) + ) ); - + return $respIsDay; } @@ -436,7 +434,7 @@ sub ShuttersSunrise { my $oldFuncHash = $FHEM::Automation::ShuttersControl::shutters->getInTimerFuncHash; my $shuttersSunriseUnixtime = - computeAlignTime( '24:00', sunrise( 'REAL', 0, '4:30', '8:30' ) ); + ::computeAlignTime( '24:00', ::sunrise( 'REAL', 0, '4:30', '8:30' ) ); if ( $tm eq 'unix' ) { if ( $FHEM::Automation::ShuttersControl::shutters->getUp eq 'astro' ) { @@ -449,11 +447,11 @@ sub ShuttersSunrise { if ( !IsWe('tomorrow') ) { if ( IsWe() - && int( gettimeofday() / 86400 ) == int( + && int( ::gettimeofday() / 86400 ) == int( ( - computeAlignTime( + ::computeAlignTime( '24:00', - sunrise_abs( + ::sunrise_abs( $autoAstroMode, 0, $FHEM::Automation::ShuttersControl::shutters @@ -465,9 +463,9 @@ sub ShuttersSunrise { ) { $shuttersSunriseUnixtime = ( - computeAlignTime( + ::computeAlignTime( '24:00', - sunrise_abs( + ::sunrise_abs( $autoAstroMode, 0, $FHEM::Automation::ShuttersControl::shutters @@ -477,11 +475,11 @@ sub ShuttersSunrise { ); } elsif ( - int( gettimeofday() / 86400 ) == int( + int( ::gettimeofday() / 86400 ) == int( ( - computeAlignTime( + ::computeAlignTime( '24:00', - sunrise_abs( + ::sunrise_abs( $autoAstroMode, 0, $FHEM::Automation::ShuttersControl::shutters @@ -495,9 +493,9 @@ sub ShuttersSunrise { ) { $shuttersSunriseUnixtime = ( - computeAlignTime( + ::computeAlignTime( '24:00', - sunrise_abs( + ::sunrise_abs( $autoAstroMode, 0, $FHEM::Automation::ShuttersControl::shutters @@ -508,9 +506,9 @@ sub ShuttersSunrise { } else { $shuttersSunriseUnixtime = ( - computeAlignTime( + ::computeAlignTime( '24:00', - sunrise_abs( + ::sunrise_abs( $autoAstroMode, 0, $FHEM::Automation::ShuttersControl::shutters @@ -526,11 +524,11 @@ sub ShuttersSunrise { if ( IsWe() && ( - int( gettimeofday() / 86400 ) == int( + int( ::gettimeofday() / 86400 ) == int( ( - computeAlignTime( + ::computeAlignTime( '24:00', - sunrise_abs( + ::sunrise_abs( $autoAstroMode, 0, $FHEM::Automation::ShuttersControl::shutters @@ -539,11 +537,11 @@ sub ShuttersSunrise { ) + 1 ) / 86400 ) - || int( gettimeofday() / 86400 ) != int( + || int( ::gettimeofday() / 86400 ) != int( ( - computeAlignTime( + ::computeAlignTime( '24:00', - sunrise_abs( + ::sunrise_abs( $autoAstroMode, 0, $FHEM::Automation::ShuttersControl::shutters @@ -556,9 +554,9 @@ sub ShuttersSunrise { ) { $shuttersSunriseUnixtime = ( - computeAlignTime( + ::computeAlignTime( '24:00', - sunrise_abs( + ::sunrise_abs( $autoAstroMode, 0, $FHEM::Automation::ShuttersControl::shutters @@ -568,11 +566,11 @@ sub ShuttersSunrise { ); } elsif ( - int( gettimeofday() / 86400 ) == int( + int( ::gettimeofday() / 86400 ) == int( ( - computeAlignTime( + ::computeAlignTime( '24:00', - sunrise_abs( + ::sunrise_abs( $autoAstroMode, 0, $FHEM::Automation::ShuttersControl::shutters @@ -586,9 +584,9 @@ sub ShuttersSunrise { ) { $shuttersSunriseUnixtime = ( - computeAlignTime( + ::computeAlignTime( '24:00', - sunrise_abs( + ::sunrise_abs( $autoAstroMode, 0, $FHEM::Automation::ShuttersControl::shutters @@ -601,11 +599,11 @@ sub ShuttersSunrise { } else { if ( - int( gettimeofday() / 86400 ) == int( + int( ::gettimeofday() / 86400 ) == int( ( - computeAlignTime( + ::computeAlignTime( '24:00', - sunrise_abs( + ::sunrise_abs( $autoAstroMode, 0, $FHEM::Automation::ShuttersControl::shutters @@ -617,9 +615,9 @@ sub ShuttersSunrise { ) { $shuttersSunriseUnixtime = ( - computeAlignTime( + ::computeAlignTime( '24:00', - sunrise_abs( + ::sunrise_abs( $autoAstroMode, 0, $FHEM::Automation::ShuttersControl::shutters @@ -630,9 +628,9 @@ sub ShuttersSunrise { } else { $shuttersSunriseUnixtime = ( - computeAlignTime( + ::computeAlignTime( '24:00', - sunrise_abs( + ::sunrise_abs( $autoAstroMode, 0, $FHEM::Automation::ShuttersControl::shutters @@ -646,9 +644,9 @@ sub ShuttersSunrise { } else { $shuttersSunriseUnixtime = ( - computeAlignTime( + ::computeAlignTime( '24:00', - sunrise_abs( + ::sunrise_abs( $autoAstroMode, 0, $FHEM::Automation::ShuttersControl::shutters @@ -669,11 +667,11 @@ sub ShuttersSunrise { { if ( !IsWe('tomorrow') ) { if ( - int( gettimeofday() / 86400 ) == int( + int( ::gettimeofday() / 86400 ) == int( ( - computeAlignTime( + ::computeAlignTime( '24:00', - sunrise_abs( + ::sunrise_abs( $autoAstroMode, 0, $FHEM::Automation::ShuttersControl::shutters @@ -690,7 +688,7 @@ sub ShuttersSunrise { ( $shuttersSunriseUnixtime + 86400 ) if ( $shuttersSunriseUnixtime < ( $oldFuncHash->{sunrisetime} + 180 ) - && $oldFuncHash->{sunrisetime} < gettimeofday() ); + && $oldFuncHash->{sunrisetime} < ::gettimeofday() ); } } } @@ -698,7 +696,7 @@ sub ShuttersSunrise { $shuttersSunriseUnixtime = ( $shuttersSunriseUnixtime + 86400 ) if ( $shuttersSunriseUnixtime < ( $oldFuncHash->{sunrisetime} + 180 ) - && $oldFuncHash->{sunrisetime} < gettimeofday() ); + && $oldFuncHash->{sunrisetime} < ::gettimeofday() ); } } elsif ( $FHEM::Automation::ShuttersControl::shutters->getUp eq 'time' ) @@ -711,8 +709,8 @@ sub ShuttersSunrise { { if ( !IsWe('tomorrow') ) { if ( - int( gettimeofday() / 86400 ) == int( - computeAlignTime( + int( ::gettimeofday() / 86400 ) == int( + ::computeAlignTime( '24:00', $FHEM::Automation::ShuttersControl::shutters ->getTimeUpWeHoliday @@ -720,13 +718,13 @@ sub ShuttersSunrise { ) ) { - $shuttersSunriseUnixtime = computeAlignTime( '24:00', + $shuttersSunriseUnixtime = ::computeAlignTime( '24:00', $FHEM::Automation::ShuttersControl::shutters ->getTimeUpWeHoliday ); } elsif ( - int( gettimeofday() / 86400 ) == int( - computeAlignTime( + int( ::gettimeofday() / 86400 ) == int( + ::computeAlignTime( '24:00', $FHEM::Automation::ShuttersControl::shutters ->getTimeUpEarly @@ -736,12 +734,12 @@ sub ShuttersSunrise { ->getSunrise ) { - $shuttersSunriseUnixtime = computeAlignTime( '24:00', + $shuttersSunriseUnixtime = ::computeAlignTime( '24:00', $FHEM::Automation::ShuttersControl::shutters ->getTimeUpEarly ) + 86400; } else { - $shuttersSunriseUnixtime = computeAlignTime( '24:00', + $shuttersSunriseUnixtime = ::computeAlignTime( '24:00', $FHEM::Automation::ShuttersControl::shutters ->getTimeUpEarly ); } @@ -749,8 +747,8 @@ sub ShuttersSunrise { else { if ( IsWe() - && int( gettimeofday() / 86400 ) == int( - computeAlignTime( + && int( ::gettimeofday() / 86400 ) == int( + ::computeAlignTime( '24:00', $FHEM::Automation::ShuttersControl::shutters ->getTimeUpWeHoliday @@ -758,13 +756,13 @@ sub ShuttersSunrise { ) ) { - $shuttersSunriseUnixtime = computeAlignTime( '24:00', + $shuttersSunriseUnixtime = ::computeAlignTime( '24:00', $FHEM::Automation::ShuttersControl::shutters ->getTimeUpWeHoliday ); } elsif ( - int( gettimeofday() / 86400 ) == int( - computeAlignTime( + int( ::gettimeofday() / 86400 ) == int( + ::computeAlignTime( '24:00', $FHEM::Automation::ShuttersControl::shutters ->getTimeUpEarly @@ -772,13 +770,13 @@ sub ShuttersSunrise { ) ) { - $shuttersSunriseUnixtime = computeAlignTime( '24:00', + $shuttersSunriseUnixtime = ::computeAlignTime( '24:00', $FHEM::Automation::ShuttersControl::shutters ->getTimeUpEarly ); } elsif ( - int( gettimeofday() / 86400 ) != int( - computeAlignTime( + int( ::gettimeofday() / 86400 ) != int( + ::computeAlignTime( '24:00', $FHEM::Automation::ShuttersControl::shutters ->getTimeUpWeHoliday @@ -786,19 +784,19 @@ sub ShuttersSunrise { ) ) { - $shuttersSunriseUnixtime = computeAlignTime( '24:00', + $shuttersSunriseUnixtime = ::computeAlignTime( '24:00', $FHEM::Automation::ShuttersControl::shutters ->getTimeUpWeHoliday ); } else { - $shuttersSunriseUnixtime = computeAlignTime( '24:00', + $shuttersSunriseUnixtime = ::computeAlignTime( '24:00', $FHEM::Automation::ShuttersControl::shutters ->getTimeUpWeHoliday ) + 86400; } } } else { - $shuttersSunriseUnixtime = computeAlignTime( '24:00', + $shuttersSunriseUnixtime = ::computeAlignTime( '24:00', $FHEM::Automation::ShuttersControl::shutters ->getTimeUpEarly ); } @@ -806,15 +804,14 @@ sub ShuttersSunrise { elsif ( $FHEM::Automation::ShuttersControl::shutters->getUp eq 'brightness' ) { - $shuttersSunriseUnixtime = computeAlignTime( '24:00', - $FHEM::Automation::ShuttersControl::shutters->getTimeUpLate - ); + $shuttersSunriseUnixtime = ::computeAlignTime( '24:00', + $FHEM::Automation::ShuttersControl::shutters->getTimeUpLate ); } return $shuttersSunriseUnixtime; } elsif ( $tm eq 'real' ) { - return sunrise_abs( + return ::sunrise_abs( $autoAstroMode, 0, $FHEM::Automation::ShuttersControl::shutters->getTimeUpEarly, @@ -858,15 +855,15 @@ sub ShuttersSunset { my $oldFuncHash = $FHEM::Automation::ShuttersControl::shutters->getInTimerFuncHash; my $shuttersSunsetUnixtime = - computeAlignTime( '24:00', sunset( 'REAL', 0, '15:30', '21:30' ) ); + ::computeAlignTime( '24:00', ::sunset( 'REAL', 0, '15:30', '21:30' ) ); if ( $tm eq 'unix' ) { if ( $FHEM::Automation::ShuttersControl::shutters->getDown eq 'astro' ) { $shuttersSunsetUnixtime = ( - computeAlignTime( + ::computeAlignTime( '24:00', - sunset_abs( + ::sunset_abs( $autoAstroMode, 0, $FHEM::Automation::ShuttersControl::shutters @@ -880,13 +877,13 @@ sub ShuttersSunset { $shuttersSunsetUnixtime += 86400 if ( $shuttersSunsetUnixtime < ( $oldFuncHash->{sunsettime} + 180 ) - && $oldFuncHash->{sunsettime} < gettimeofday() ); + && $oldFuncHash->{sunsettime} < ::gettimeofday() ); } } elsif ( $FHEM::Automation::ShuttersControl::shutters->getDown eq 'time' ) { - $shuttersSunsetUnixtime = computeAlignTime( '24:00', + $shuttersSunsetUnixtime = ::computeAlignTime( '24:00', $FHEM::Automation::ShuttersControl::shutters->getTimeDownEarly ); } @@ -894,13 +891,13 @@ sub ShuttersSunset { 'brightness' ) { $shuttersSunsetUnixtime = - computeAlignTime( '24:00', + ::computeAlignTime( '24:00', $FHEM::Automation::ShuttersControl::shutters->getTimeDownLate ); } return $shuttersSunsetUnixtime; } elsif ( $tm eq 'real' ) { - return sunset_abs( + return ::sunset_abs( $autoAstroMode, 0, $FHEM::Automation::ShuttersControl::shutters->getTimeDownEarly, @@ -923,7 +920,7 @@ sub IsAfterShuttersTimeBlocking { if ( ( - int( gettimeofday() ) - + int( ::gettimeofday() ) - $FHEM::Automation::ShuttersControl::shutters->getLastManPosTimestamp ) < $FHEM::Automation::ShuttersControl::shutters->getBlockingTimeAfterManual @@ -933,7 +930,7 @@ sub IsAfterShuttersTimeBlocking { $FHEM::Automation::ShuttersControl::shutters->getSunriseUnixTime ) && $FHEM::Automation::ShuttersControl::shutters->getSunriseUnixTime - - ( int( gettimeofday() ) ) < + - ( int( ::gettimeofday() ) ) < $FHEM::Automation::ShuttersControl::shutters ->getBlockingTimeBeforDayOpen ) @@ -943,7 +940,7 @@ sub IsAfterShuttersTimeBlocking { $FHEM::Automation::ShuttersControl::shutters->getSunriseUnixTime ) && $FHEM::Automation::ShuttersControl::shutters->getSunsetUnixTime - - ( int( gettimeofday() ) ) < + - ( int( ::gettimeofday() ) ) < $FHEM::Automation::ShuttersControl::shutters ->getBlockingTimeBeforNightClose ) @@ -982,7 +979,7 @@ sub IsAfterShuttersManualBlocking { } elsif ( ( - int( gettimeofday() ) - + int( ::gettimeofday() ) - $FHEM::Automation::ShuttersControl::shutters->getLastManPosTimestamp ) < $FHEM::Automation::ShuttersControl::shutters->getBlockingTimeAfterManual @@ -1019,24 +1016,32 @@ sub PerlCodeCheck { sub IsAdv { use HTTP::Date; my ( undef, undef, undef, $monthday, $month, $year, undef, undef, undef ) = - localtime( gettimeofday() ); + localtime( ::gettimeofday() ); my $adv = 0; $year += 1900; - if ( $month < 1 ) { - if ( $monthday < 7 ) { - $adv = 1; - } + if ( $month < 1 + && $FHEM::Automation::ShuttersControl::ascDev->getAdvEndDate eq + 'EpiphanyDay' ) + { + $adv = $monthday < 7 ? 1 : 0; + } + elsif ($month < 2 + && $FHEM::Automation::ShuttersControl::ascDev->getAdvEndDate eq + 'CandlemasDay' ) + { + $adv = $month = 1 || ( $month = 2 && $monthday < 3 ) ? 1 : 0; } else { my $time = str2time( $year . '-12-25' ); my $wday = ( localtime($time) )[6]; $wday = $wday ? $wday : 7; - $time -= ( $FHEM::Automation::ShuttersControl::ascDev - ->getAdvDate eq 'DeadSunday' - ? ($wday + 27) * 86400 - : ($wday + 21) * 86400 - ); + $time -= ( + $FHEM::Automation::ShuttersControl::ascDev->getAdvStartDate eq + 'DeadSunday' + ? ( $wday + 27 ) * 86400 + : ( $wday + 21 ) * 86400 + ); $adv = 1 if ( $time < time ); } @@ -1046,18 +1051,19 @@ sub IsAdv { sub IsInTime { my $dfi = shift; - $dfi =~ s/{([^\x7d]*)}/$cmdFromAnalyze=$1; eval $1/ge; # Forum #69787 - my ($sec,$min,$hour,$mday,$month,$year,$wday,$yday,$isdst) = localtime(gettimeofday()); - my $dhms = sprintf("%s\@%02d:%02d:%02d", $wday, $hour, $min, $sec); - foreach my $ft (split(" ", $dfi)) { - my ($from, $to) = split("-", $ft); - if(defined($from) && defined($to)) { - $from = "$wday\@$from" if(index($from,"@") < 0); - $to = "$wday\@$to" if(index($to, "@") < 0); - return 1 if($from le $dhms && $dhms le $to); + $dfi =~ s/{([^\x7d]*)}/$cmdFromAnalyze=$1; eval $1/ge; # Forum #69787 + my ( $sec, $min, $hour, $mday, $month, $year, $wday, $yday, $isdst ) = + localtime( ::gettimeofday() ); + my $dhms = sprintf( "%s\@%02d:%02d:%02d", $wday, $hour, $min, $sec ); + foreach my $ft ( split( " ", $dfi ) ) { + my ( $from, $to ) = split( "-", $ft ); + if ( defined($from) && defined($to) ) { + $from = "$wday\@$from" if ( index( $from, "@" ) < 0 ); + $to = "$wday\@$to" if ( index( $to, "@" ) < 0 ); + return 1 if ( $from le $dhms && $dhms le $to ); } } - + return 0; } diff --git a/fhem/lib/FHEM/Automation/ShuttersControl/Rainprotection.pm b/fhem/lib/FHEM/Automation/ShuttersControl/Rainprotection.pm index d6dab570a..e351dd8bb 100644 --- a/fhem/lib/FHEM/Automation/ShuttersControl/Rainprotection.pm +++ b/fhem/lib/FHEM/Automation/ShuttersControl/Rainprotection.pm @@ -1,8 +1,8 @@ ############################################################################### # -# Developed with Kate +# Developed with VSCodium and richterger perl plugin # -# (c) 2018-2021 Copyright: Marko Oldenburg (fhemdevelopment@cooltux.net) +# (c) 2018-2022 Copyright: Marko Oldenburg (fhemdevelopment at cooltux dot net) # All rights reserved # # Special thanks goes to: @@ -47,7 +47,9 @@ use utf8; use FHEM::Automation::ShuttersControl::Helper qw (:ALL); require Exporter; -our @ISA = qw(Exporter); +use base qw(Exporter); + +# our @ISA = qw(Exporter); our @EXPORT_OK = qw( RainProcessing ); @@ -59,12 +61,11 @@ our %EXPORT_TAGS = ( ], ); - sub RainProcessing { my ( $hash, $val, $triggerMax, $triggerMin ) = @_; - + my $rainClosedPos = $FHEM::Automation::ShuttersControl::ascDev - ->getRainSensorShuttersClosedPos; + ->getRainSensorShuttersClosedPos; for my $shuttersDev ( @{ $hash->{helper}{shuttersList} } ) { $FHEM::Automation::ShuttersControl::shutters->setShuttersDev( @@ -75,49 +76,53 @@ sub RainProcessing { $FHEM::Automation::ShuttersControl::shutters->getRainProtection eq 'off' ); - if ( $val > $triggerMax + if ( + $val > $triggerMax && $FHEM::Automation::ShuttersControl::shutters->getStatus != $rainClosedPos && $FHEM::Automation::ShuttersControl::shutters - ->getRainProtectionStatus eq 'unprotected' + ->getRainProtectionStatus eq 'unprotected' || ( $FHEM::Automation::ShuttersControl::shutters - ->getRainProtectionStatus eq 'unprotected' - && $FHEM::Automation::ShuttersControl::shutters - ->getRainUnprotectionDelayObj ne 'none') + ->getRainProtectionStatus eq 'unprotected' + && $FHEM::Automation::ShuttersControl::shutters + ->getRainUnprotectionDelayObj ne 'none' ) ) { _RainProtected(); } elsif ( ( $val == 0 || $val < $triggerMin ) && $FHEM::Automation::ShuttersControl::shutters->getStatus == - $rainClosedPos + $rainClosedPos && IsAfterShuttersManualBlocking($shuttersDev) && $FHEM::Automation::ShuttersControl::shutters - ->getRainProtectionStatus eq 'protected' ) + ->getRainProtectionStatus eq 'protected' ) { - my %funcHash = ( - shuttersdevice => $shuttersDev, + my %funcHash = ( shuttersdevice => $shuttersDev, ); + + $FHEM::Automation::ShuttersControl::shutters + ->setRainUnprotectionDelayObj( \%funcHash ); + ::InternalTimer( + ::gettimeofday() + + $FHEM::Automation::ShuttersControl::ascDev + ->getRainWaitingTime, + \&_RainUnprotected, \%funcHash ); - $FHEM::Automation::ShuttersControl::shutters->setRainUnprotectionDelayObj(\%funcHash); - ::InternalTimer( ::gettimeofday() + $FHEM::Automation::ShuttersControl::ascDev->getRainWaitingTime - , \&_RainUnprotected - , \%funcHash ); - $FHEM::Automation::ShuttersControl::shutters - ->setRainProtectionStatus('unprotected'); + ->setRainProtectionStatus('unprotected'); } else { - if ( $FHEM::Automation::ShuttersControl::shutters->getStatus != $rainClosedPos - && ($val == 0 || $val < $triggerMin) ) + if ( $FHEM::Automation::ShuttersControl::shutters->getStatus != + $rainClosedPos + && ( $val == 0 || $val < $triggerMin ) ) { $FHEM::Automation::ShuttersControl::shutters ->setRainProtectionStatus('unprotected'); } - elsif ($val > $triggerMax) { + elsif ( $val > $triggerMax ) { $FHEM::Automation::ShuttersControl::shutters ->setRainProtectionStatus('protected'); - } + } } } @@ -126,58 +131,69 @@ sub RainProcessing { ### es muss noch beobachtet werden ob die Auswahl des Rollos welches bearbeitet werden soll bestehen bleibt oder mit in die neuen Funktionen übergeben werden muss sub _RainProtected { - ::RemoveInternalTimer($FHEM::Automation::ShuttersControl::shutters->getRainUnprotectionDelayObj) - if($FHEM::Automation::ShuttersControl::shutters->getRainUnprotectionDelayObj ne 'none'); - - $FHEM::Automation::ShuttersControl::shutters->setRainUnprotectionDelayObj('none'); + ::RemoveInternalTimer( $FHEM::Automation::ShuttersControl::shutters + ->getRainUnprotectionDelayObj ) + if ( $FHEM::Automation::ShuttersControl::shutters + ->getRainUnprotectionDelayObj ne 'none' ); + + $FHEM::Automation::ShuttersControl::shutters->setRainUnprotectionDelayObj( + 'none'); $FHEM::Automation::ShuttersControl::shutters->setLastDrive( - 'rain protected'); + 'rain protected'); $FHEM::Automation::ShuttersControl::shutters->setDriveCmd( $FHEM::Automation::ShuttersControl::ascDev - ->getRainSensorShuttersClosedPos); + ->getRainSensorShuttersClosedPos ); - $FHEM::Automation::ShuttersControl::shutters - ->setRainProtectionStatus('protected'); + $FHEM::Automation::ShuttersControl::shutters->setRainProtectionStatus( + 'protected'); + + return; } sub _RainUnprotected { my $h = shift; - + my $shuttersDev = $h->{shuttersdevice}; - $FHEM::Automation::ShuttersControl::shutters->setShuttersDev( - $shuttersDev); + $FHEM::Automation::ShuttersControl::shutters->setShuttersDev($shuttersDev); $FHEM::Automation::ShuttersControl::shutters->setLastDrive( - 'rain un-protected'); + 'rain un-protected'); - if ( $FHEM::Automation::ShuttersControl::shutters->getRainUnprotectionDelayObj ne 'none' ) { - ::RemoveInternalTimer($FHEM::Automation::ShuttersControl::shutters->getRainUnprotectionDelayObj); - $FHEM::Automation::ShuttersControl::shutters->setRainUnprotectionDelayObj('none'); + if ( $FHEM::Automation::ShuttersControl::shutters + ->getRainUnprotectionDelayObj ne 'none' ) + { + ::RemoveInternalTimer( $FHEM::Automation::ShuttersControl::shutters + ->getRainUnprotectionDelayObj ); + $FHEM::Automation::ShuttersControl::shutters + ->setRainUnprotectionDelayObj('none'); } $FHEM::Automation::ShuttersControl::shutters->setDriveCmd( ( - $FHEM::Automation::ShuttersControl::shutters->getIsDay + $FHEM::Automation::ShuttersControl::shutters->getIsDay ? $FHEM::Automation::ShuttersControl::shutters->getLastPos : ( - $FHEM::Automation::ShuttersControl::shutters - ->getPrivacyDownStatus == 2 - ? $FHEM::Automation::ShuttersControl::shutters - ->getPrivacyDownPos - : $FHEM::Automation::ShuttersControl::shutters - ->getClosedPos + $FHEM::Automation::ShuttersControl::shutters->getShuttersPlace + eq 'awning' + ? $FHEM::Automation::ShuttersControl::shutters->getOpenPos + : ( + $FHEM::Automation::ShuttersControl::shutters + ->getPrivacyDownStatus == 2 + ? $FHEM::Automation::ShuttersControl::shutters + ->getPrivacyDownPos + : $FHEM::Automation::ShuttersControl::shutters + ->getClosedPos + ) ) ) - ) - if (IsAfterShuttersTimeBlocking($shuttersDev)); + ) if ( IsAfterShuttersTimeBlocking($shuttersDev) ); - $FHEM::Automation::ShuttersControl::shutters - ->setRainProtectionStatus('unprotected'); + $FHEM::Automation::ShuttersControl::shutters->setRainProtectionStatus( + 'unprotected'); + + return; } - - - 1; diff --git a/fhem/lib/FHEM/Automation/ShuttersControl/Roommate.pm b/fhem/lib/FHEM/Automation/ShuttersControl/Roommate.pm index d4539de79..2a99cb615 100644 --- a/fhem/lib/FHEM/Automation/ShuttersControl/Roommate.pm +++ b/fhem/lib/FHEM/Automation/ShuttersControl/Roommate.pm @@ -1,8 +1,8 @@ ############################################################################### # -# Developed with Kate +# Developed with VSCodium and richterger perl plugin # -# (c) 2018-2021 Copyright: Marko Oldenburg (fhemdevelopment@cooltux.net) +# (c) 2018-2022 Copyright: Marko Oldenburg (fhemdevelopment at cooltux dot net) # All rights reserved # # Special thanks goes to: @@ -44,37 +44,41 @@ use strict; use warnings; use utf8; -use GPUtils qw(GP_Import); +require Exporter; +use base qw(Exporter); -## Import der FHEM Funktionen -BEGIN { - GP_Import( +# our @ISA = qw(Exporter); +our @EXPORT_OK = qw( + getRoommateStatus + getRoommateLastStatus +); +our %EXPORT_TAGS = ( + ALL => [ qw( - ReadingsVal) - ); -} + getRoommateStatus + getRoommateLastStatus + ) + ], +); -sub _getRoommateStatus { +sub getRoommateStatus { my $self = shift; my $roommate = $self->{roommate}; - return ReadingsVal( $roommate, + return ::ReadingsVal( $roommate, $FHEM::Automation::ShuttersControl::shutters->getRoommatesReading, 'none' ); } -sub _getRoommateLastStatus { +sub getRoommateLastStatus { my $self = shift; my $roommate = $self->{roommate}; my $default = $self->{defaultarg}; $default = 'none' if ( !defined($default) ); - return ReadingsVal( $roommate, 'lastState', $default ); + return ::ReadingsVal( $roommate, 'lastState', $default ); } - - - 1; diff --git a/fhem/lib/FHEM/Automation/ShuttersControl/Shading.pm b/fhem/lib/FHEM/Automation/ShuttersControl/Shading.pm index 7a0a9933a..207918715 100644 --- a/fhem/lib/FHEM/Automation/ShuttersControl/Shading.pm +++ b/fhem/lib/FHEM/Automation/ShuttersControl/Shading.pm @@ -1,8 +1,8 @@ ############################################################################### # -# Developed with Kate +# Developed with VSCodium and richterger perl plugin # -# (c) 2018-2021 Copyright: Marko Oldenburg (fhemdevelopment@cooltux.net) +# (c) 2018-2022 Copyright: Marko Oldenburg (fhemdevelopment at cooltux dot net) # All rights reserved # # Special thanks goes to: @@ -48,7 +48,9 @@ use utf8; use FHEM::Automation::ShuttersControl::Helper qw (IsInTime); require Exporter; -our @ISA = qw(Exporter); +use base qw(Exporter); + +# our @ISA = qw(Exporter); our @EXPORT_OK = qw( CheckASC_ConditionsForShadingFn ShadingProcessing @@ -64,27 +66,9 @@ our %EXPORT_TAGS = ( ], ); -use GPUtils qw(GP_Import); -## Import der FHEM Funktionen -BEGIN { - GP_Import( - qw( - Log3 - gettimeofday - InternalTimer - ReadingsVal - readingsBeginUpdate - readingsBulkUpdate - readingsBulkUpdateIfChanged - readingsEndUpdate - defs - ) - ); -} - sub CheckASC_ConditionsForShadingFn { - my $hash = shift; - my $value = shift; + my $hash = shift; + my $value = shift; my $error; @@ -98,14 +82,14 @@ sub CheckASC_ConditionsForShadingFn { my $count = 1; for my $shuttersDev ( @{ $hash->{helper}{shuttersList} } ) { my %funcHash = ( - hash => $hash, - shuttersdevice => $shuttersDev, - value => $value, - attrEvent => 0, + hash => $hash, + shuttersdevice => $shuttersDev, + value => $value, + attrEvent => 0, ); - InternalTimer( - gettimeofday() + $count, + ::InternalTimer( + ::gettimeofday() + $count, 'FHEM::Automation::ShuttersControl::Shading::_CheckShuttersConditionsForShadingFn', \%funcHash ); @@ -121,86 +105,93 @@ sub CheckASC_ConditionsForShadingFn { } sub _CheckShuttersConditionsForShadingFn { - my $funcHash = shift; - + my $funcHash = shift; + my $hash = $funcHash->{hash}; my $shuttersDev = $funcHash->{shuttersdevice}; my $value = $funcHash->{value}; $FHEM::Automation::ShuttersControl::shutters->setShuttersDev($shuttersDev); - my $shuttersDevHash = $defs{$shuttersDev}; + my $shuttersDevHash = $::defs{$shuttersDev}; my $message = ''; my $errorMessage; my $warnMessage; my $infoMessage; - + if ( $value eq 'off' ) { $FHEM::Automation::ShuttersControl::shutters->setShadingStatus('out'); - $infoMessage .= ' shading was deactivated ' . ($funcHash->{attrEvent} ? 'in the device' : 'globally'); - $errorMessage .= ''; + $infoMessage .= ' shading was deactivated ' + . ( $funcHash->{attrEvent} ? 'in the device' : 'globally' ); + $errorMessage .= ''; ShadingProcessingDriveCommand( $hash, $shuttersDev ); } else { $infoMessage .= ( - $FHEM::Automation::ShuttersControl::shutters->getShadingMode ne 'off' - && $FHEM::Automation::ShuttersControl::ascDev - ->getAutoShuttersControlShading eq 'on' - && $FHEM::Automation::ShuttersControl::shutters->getOutTemp == -100 + $FHEM::Automation::ShuttersControl::shutters->getShadingMode ne + 'off' + && $FHEM::Automation::ShuttersControl::ascDev + ->getAutoShuttersControlShading eq 'on' + && $FHEM::Automation::ShuttersControl::shutters->getOutTemp == + -100 ? ' shading active, global temp sensor is set, but shutters temperature sensor is not set' : '' ); $warnMessage .= ( - $FHEM::Automation::ShuttersControl::shutters->getShadingMode eq 'off' - && $FHEM::Automation::ShuttersControl::ascDev - ->getAutoShuttersControlShading eq 'on' + $FHEM::Automation::ShuttersControl::shutters->getShadingMode eq + 'off' + && $FHEM::Automation::ShuttersControl::ascDev + ->getAutoShuttersControlShading eq 'on' ? ' global shading active but ASC_Shading_Mode attribut is not set or off' : '' ); $errorMessage .= ( - $FHEM::Automation::ShuttersControl::shutters->getShadingMode ne 'off' - && $FHEM::Automation::ShuttersControl::ascDev - ->getAutoShuttersControlShading ne 'on' - && $FHEM::Automation::ShuttersControl::ascDev - ->getAutoShuttersControlShading ne 'off' + $FHEM::Automation::ShuttersControl::shutters->getShadingMode ne + 'off' + && $FHEM::Automation::ShuttersControl::ascDev + ->getAutoShuttersControlShading ne 'on' + && $FHEM::Automation::ShuttersControl::ascDev + ->getAutoShuttersControlShading ne 'off' ? ' ASC_Shading_Mode attribut is set but global shading has errors, look at ASC device ' - . '' - . ReadingsVal( $shuttersDev, 'associatedWith', 'ASC device' ) - . '' + . '' + . ::ReadingsVal( $shuttersDev, 'associatedWith', 'ASC device' ) + . '' : '' ); $errorMessage .= ( $FHEM::Automation::ShuttersControl::shutters->getBrightness == -1 - && $FHEM::Automation::ShuttersControl::shutters->getShadingMode ne - 'off' + && $FHEM::Automation::ShuttersControl::shutters->getShadingMode + ne 'off' ? ' no brightness sensor found, please set ASC_BrightnessSensor attribut' : '' ); } $message .= ' ERROR: ' . $errorMessage - if ( defined($errorMessage) + if ( defined($errorMessage) && $errorMessage ne '' ); $message .= ' WARN: ' . $warnMessage - if ( defined($warnMessage) + if ( defined($warnMessage) && $warnMessage ne '' && $errorMessage eq '' ); $message .= ' INFO: ' . $infoMessage - if ( defined($infoMessage) + if ( defined($infoMessage) && $infoMessage ne '' && $errorMessage eq '' ); - readingsBeginUpdate($shuttersDevHash); - readingsBulkUpdateIfChanged( $shuttersDevHash, 'ASC_ShadingMessage', + ::readingsBeginUpdate($shuttersDevHash); + ::readingsBulkUpdateIfChanged( $shuttersDevHash, 'ASC_ShadingMessage', '' . $message . ' ' ); - readingsEndUpdate( $shuttersDevHash, 1 ); + ::readingsEndUpdate( $shuttersDevHash, 1 ); + + return; } sub ShadingProcessing { @@ -215,12 +206,18 @@ sub ShadingProcessing { $FHEM::Automation::ShuttersControl::shutters->setShuttersDev($shuttersDev); my $brightness = $FHEM::Automation::ShuttersControl::shutters->getBrightnessAverage; - - $FHEM::Automation::ShuttersControl::shutters->setShadingBetweenTheTimeSuspend( - ( IsInTime($FHEM::Automation::ShuttersControl::shutters->getShadingBetweenTheTime) - ? 0 - : 1 ) - ); + + $FHEM::Automation::ShuttersControl::shutters + ->setShadingBetweenTheTimeSuspend( + ( + IsInTime( + $FHEM::Automation::ShuttersControl::shutters + ->getShadingBetweenTheTime + ) + ? 0 + : 1 + ) + ); FHEM::Automation::ShuttersControl::ASC_Debug( 'ShadingProcessing: ' @@ -250,7 +247,7 @@ sub ShadingProcessing { . ', Ist es nach der Hälfte der Beschattungswartezeit: ' . ( ( - int( gettimeofday() ) - + int( ::gettimeofday() ) - $FHEM::Automation::ShuttersControl::shutters ->getShadingStatusTimestamp ) < ( @@ -260,7 +257,7 @@ sub ShadingProcessing { ) ); - Log3( $name, 4, + ::Log3( $name, 4, "AutoShuttersControl ($name) - Shading Processing, Rollladen: " . $shuttersDev . " Azimuth: " @@ -279,18 +276,20 @@ sub ShadingProcessing { || $brightness == -1 || $outTemp == -100 || ( - int( gettimeofday() ) - + int( ::gettimeofday() ) - $FHEM::Automation::ShuttersControl::shutters ->getShadingStatusTimestamp ) < ( $FHEM::Automation::ShuttersControl::shutters ->getShadingWaitingPeriod / 2 ) + || $FHEM::Automation::ShuttersControl::shutters + ->getExternalTriggerStatus || $FHEM::Automation::ShuttersControl::shutters->getShadingMode eq 'off' || $FHEM::Automation::ShuttersControl::ascDev - ->getAutoShuttersControlShading eq 'off' + ->getAutoShuttersControlShading eq 'off' ); - Log3( $name, 4, + ::Log3( $name, 4, "AutoShuttersControl ($name) - Shading Processing, Rollladen: " . $shuttersDev . " Nach dem return" ); @@ -300,7 +299,7 @@ sub ShadingProcessing { my $getStatus = $FHEM::Automation::ShuttersControl::shutters->getStatus; my $oldShadingStatus = $FHEM::Automation::ShuttersControl::shutters->getShadingStatus; - my $shuttersDevHash = $defs{$shuttersDev}; + my $shuttersDevHash = $::defs{$shuttersDev}; my $getModeUp = $FHEM::Automation::ShuttersControl::shutters->getModeUp; my $homemode = $FHEM::Automation::ShuttersControl::shutters->getHomemode; @@ -316,9 +315,9 @@ sub ShadingProcessing { ->getShadingMinOutsideTemperature - 4 || $azimuth < $azimuthLeft || $azimuth > $azimuthRight - || ( !$FHEM::Automation::ShuttersControl::shutters->getIsDay - && $FHEM::Automation::ShuttersControl::shutters->getSunriseUnixTime - - ( int( gettimeofday() ) ) > 7200 ) + || ( !$FHEM::Automation::ShuttersControl::shutters->getIsDay + && $FHEM::Automation::ShuttersControl::shutters + ->getSunriseUnixTime - ( int( ::gettimeofday() ) ) > 7200 ) ) && $FHEM::Automation::ShuttersControl::shutters->getShadingStatus ne 'out' @@ -331,7 +330,7 @@ sub ShadingProcessing { . ' - Es ist Nacht oder die Aussentemperatur unterhalb der Shading Temperatur. Die Beschattung wird Zwangsbeendet' ); - Log3( $name, 4, + ::Log3( $name, 4, "AutoShuttersControl ($name) - Shading Processing - Der Sonnenstand ist ausserhalb der Winkelangaben oder die Aussentemperatur unterhalb der Shading Temperatur " ); } @@ -358,7 +357,7 @@ sub ShadingProcessing { $FHEM::Automation::ShuttersControl::shutters->getShadingStatus eq 'out reserved' and ( - int( gettimeofday() ) - + int( ::gettimeofday() ) - $FHEM::Automation::ShuttersControl::shutters ->getShadingStatusTimestamp ) ) > $FHEM::Automation::ShuttersControl::shutters @@ -369,7 +368,7 @@ sub ShadingProcessing { 'out'); } - Log3( $name, 4, + ::Log3( $name, 4, "AutoShuttersControl ($name) - Shading Processing, Rollladen: " . $shuttersDev . " In der Out Abfrage, Shadingwert: " @@ -411,7 +410,7 @@ sub ShadingProcessing { $FHEM::Automation::ShuttersControl::shutters->getShadingStatus eq 'in reserved' and ( - int( gettimeofday() ) - + int( ::gettimeofday() ) - $FHEM::Automation::ShuttersControl::shutters ->getShadingStatusTimestamp ) > ( $FHEM::Automation::ShuttersControl::shutters @@ -423,7 +422,7 @@ sub ShadingProcessing { 'in'); } - Log3( $name, 4, + ::Log3( $name, 4, "AutoShuttersControl ($name) - Shading Processing, Rollladen: " . $shuttersDev . " In der In Abfrage, Shadingwert: " @@ -468,22 +467,18 @@ sub ShadingProcessing { || $FHEM::Automation::ShuttersControl::shutters->getShadingMode eq $homemode ) && ( - $getModeUp eq 'always' - || $getModeUp eq - $homemode + $getModeUp eq 'always' + || $getModeUp eq $homemode || $getModeUp eq 'off' - || $getModeUp eq - 'absent' - || $getModeUp eq - 'gone' - || ( $getModeUp eq - 'home' + || $getModeUp eq 'absent' + || $getModeUp eq 'gone' + || ( $getModeUp eq 'home' && $homemode ne 'asleep' ) ) && ( ( ( - int( gettimeofday() ) - + int( ::gettimeofday() ) - $FHEM::Automation::ShuttersControl::shutters ->getShadingStatusTimestamp ) < 2 @@ -497,18 +492,18 @@ sub ShadingProcessing { ) && $FHEM::Automation::ShuttersControl::shutters->getIfInShading ) - || ( !$FHEM::Automation::ShuttersControl::shutters->getIfInShading + || ( !$FHEM::Automation::ShuttersControl::shutters->getIfInShading && $FHEM::Automation::ShuttersControl::shutters->getStatus == - $FHEM::Automation::ShuttersControl::shutters->getShadingPos - ) - || ( !$FHEM::Automation::ShuttersControl::shutters->getShadingBetweenTheTimeSuspend + $FHEM::Automation::ShuttersControl::shutters->getShadingPos ) + || ( !$FHEM::Automation::ShuttersControl::shutters + ->getShadingBetweenTheTimeSuspend && $FHEM::Automation::ShuttersControl::shutters->getStatus != $FHEM::Automation::ShuttersControl::shutters->getShadingPos ) ) ); - readingsBeginUpdate($shuttersDevHash); - readingsBulkUpdate( + ::readingsBeginUpdate($shuttersDevHash); + ::readingsBulkUpdate( $shuttersDevHash, 'ASC_ShadingMessage', 'INFO: current shading status is \'' @@ -531,7 +526,7 @@ sub ShadingProcessing { ) / 60 . 'm' ); - readingsEndUpdate( $shuttersDevHash, 1 ); + ::readingsEndUpdate( $shuttersDevHash, 1 ); return; } @@ -551,19 +546,28 @@ sub ShadingProcessingDriveCommand { $FHEM::Automation::ShuttersControl::shutters->setShadingStatus( $FHEM::Automation::ShuttersControl::shutters->getShadingStatus ); - if ( IsInTime($FHEM::Automation::ShuttersControl::shutters->getShadingBetweenTheTime) - && $FHEM::Automation::ShuttersControl::shutters->getShadingStatus eq 'in' + if ( + IsInTime( + $FHEM::Automation::ShuttersControl::shutters + ->getShadingBetweenTheTime + ) + && $FHEM::Automation::ShuttersControl::shutters->getShadingStatus eq + 'in' && $getShadingPos != $getStatus - && ( $getStatus != $FHEM::Automation::ShuttersControl::shutters->getClosedPos - || ( $getStatus == $FHEM::Automation::ShuttersControl::shutters->getClosedPos - && $marker - ) - ) - && ( $getStatus != $FHEM::Automation::ShuttersControl::shutters->getSleepPos - || ( $getStatus == $FHEM::Automation::ShuttersControl::shutters->getSleepPos - && $marker - ) - ) + && ( + $getStatus != + $FHEM::Automation::ShuttersControl::shutters->getClosedPos + || ( $getStatus == + $FHEM::Automation::ShuttersControl::shutters->getClosedPos + && $marker ) + ) + && ( + $getStatus != + $FHEM::Automation::ShuttersControl::shutters->getSleepPos + || ( $getStatus == + $FHEM::Automation::ShuttersControl::shutters->getSleepPos + && $marker ) + ) && ( FHEM::Automation::ShuttersControl::CheckIfShuttersWindowRecOpen( $shuttersDev) != 2 @@ -602,10 +606,10 @@ sub ShadingProcessingDriveCommand { ( ( $getShadingPos == - $FHEM::Automation::ShuttersControl::shutters->getLastPos + $FHEM::Automation::ShuttersControl::shutters->getLastPos || $getShadingPos == - $FHEM::Automation::ShuttersControl::shutters - ->getShadingLastPos + $FHEM::Automation::ShuttersControl::shutters + ->getShadingLastPos ) ? $FHEM::Automation::ShuttersControl::shutters->getOpenPos : ( @@ -626,8 +630,10 @@ sub ShadingProcessingDriveCommand { : $FHEM::Automation::ShuttersControl::shutters->getOpenPos ) ) - ) if ( $FHEM::Automation::ShuttersControl::shutters->getIsDay - || $FHEM::Automation::ShuttersControl::shutters->getShuttersPlace eq 'awning' ); + ) + if ( $FHEM::Automation::ShuttersControl::shutters->getIsDay + || $FHEM::Automation::ShuttersControl::shutters->getShuttersPlace + eq 'awning' ); FHEM::Automation::ShuttersControl::ASC_Debug( 'ShadingProcessingDriveCommand: ' @@ -639,7 +645,7 @@ sub ShadingProcessingDriveCommand { . ' zum beenden der Beschattung gefahren' ); } - Log3( $name, 4, + ::Log3( $name, 4, "AutoShuttersControl ($name) - Shading Processing - In der Routine zum fahren der Rollläden, Shading Wert: " . $FHEM::Automation::ShuttersControl::shutters->getShadingStatus ); diff --git a/fhem/lib/FHEM/Automation/ShuttersControl/Shutters.pm b/fhem/lib/FHEM/Automation/ShuttersControl/Shutters.pm index ec88ea750..150586c3b 100644 --- a/fhem/lib/FHEM/Automation/ShuttersControl/Shutters.pm +++ b/fhem/lib/FHEM/Automation/ShuttersControl/Shutters.pm @@ -1,8 +1,8 @@ ############################################################################### # -# Developed with Kate +# Developed with VSCodium and richterger perl plugin # -# (c) 2018-2021 Copyright: Marko Oldenburg (fhemdevelopment@cooltux.net) +# (c) 2018-2022 Copyright: Marko Oldenburg (fhemdevelopment at cooltux dot net) # All rights reserved # # Special thanks goes to: @@ -45,18 +45,18 @@ package FHEM::Automation::ShuttersControl::Shutters; -use FHEM::Automation::ShuttersControl::Shutters::Readings; -use FHEM::Automation::ShuttersControl::Shutters::Attr; -use FHEM::Automation::ShuttersControl::Roommate; -use FHEM::Automation::ShuttersControl::Window; - -our @ISA = - qw(FHEM::Automation::ShuttersControl::Shutters::Readings FHEM::Automation::ShuttersControl::Shutters::Attr FHEM::Automation::ShuttersControl::Roommate FHEM::Automation::ShuttersControl::Window); - use strict; use warnings; use utf8; +use FHEM::Automation::ShuttersControl::Shutters::Readings; +use FHEM::Automation::ShuttersControl::Shutters::Attr; +use FHEM::Automation::ShuttersControl::Roommate qw (:ALL); +use FHEM::Automation::ShuttersControl::Window; + +use base + qw(FHEM::Automation::ShuttersControl::Shutters::Readings FHEM::Automation::ShuttersControl::Shutters::Attr FHEM::Automation::ShuttersControl::Roommate FHEM::Automation::ShuttersControl::Window); + sub new { my $class = shift; my $self = { @@ -161,6 +161,7 @@ sub setDriveCmd { $FHEM::Automation::ShuttersControl::shutters->setDelayCmd($posValue); $FHEM::Automation::ShuttersControl::ascDev->setDelayCmdReading; $FHEM::Automation::ShuttersControl::shutters->setNoDelay(0); + # $FHEM::Automation::ShuttersControl::shutters->setExternalTriggerStatus(0) # if ( $FHEM::Automation::ShuttersControl::shutters # ->getExternalTriggerStatus ); @@ -177,7 +178,8 @@ sub setDriveCmd { if ( $FHEM::Automation::ShuttersControl::shutters->getDelayCmd ne 'none' ) ; # setzt den Wert auf none da der Rolladen nun gesteuert werden kann. - $FHEM::Automation::ShuttersControl::shutters->setExternalTriggerStatus(0) + $FHEM::Automation::ShuttersControl::shutters->setExternalTriggerStatus( + 0) if ( $FHEM::Automation::ShuttersControl::shutters ->getExternalTriggerStatus ); @@ -233,7 +235,7 @@ sub setDriveCmd { ::gettimeofday() + $FHEM::Automation::ShuttersControl::shutters ->getSelfDefenseAbsentDelay, - \&FHEM::Automation::ShuttersControl::_SetCmdFn, \%h + \&FHEM::Automation::ShuttersControl::SetCmdFn, \%h ); $FHEM::Automation::ShuttersControl::shutters->setSelfDefenseAbsent( 1, 0, \%h ); @@ -247,7 +249,7 @@ sub setDriveCmd { $FHEM::Automation::ShuttersControl::shutters ->getDelayStart ), - \&FHEM::Automation::ShuttersControl::_SetCmdFn, + \&FHEM::Automation::ShuttersControl::SetCmdFn, \%h ); @@ -258,7 +260,7 @@ sub setDriveCmd { elsif ($offSetStart < 1 || $FHEM::Automation::ShuttersControl::shutters->getNoDelay ) { - FHEM::Automation::ShuttersControl::_SetCmdFn( \%h ); + FHEM::Automation::ShuttersControl::SetCmdFn( \%h ); FHEM::Automation::ShuttersControl::ASC_Debug( 'FnSetDriveCmd: ' . $FHEM::Automation::ShuttersControl::shutters->getShuttersDev . ' - NICHT versetztes fahren' ); @@ -346,8 +348,7 @@ sub setLastDriveReading { ); ::InternalTimer( ::gettimeofday() + 0.1, - \&FHEM::Automation::ShuttersControl::_setShuttersLastDriveDelayed, - \%h ); + \&FHEM::Automation::ShuttersControl::setShuttersLastDriveDelayed, \%h ); return; } @@ -460,7 +461,8 @@ sub setRainUnprotectionDelayObj { my $self = shift; my $value = shift; - $self->{ $self->{shuttersDev} }->{RainProtection}->{UNPROTECTIONDELAYOBJVAL} = $value + $self->{ $self->{shuttersDev} }->{RainProtection}->{UNPROTECTIONDELAYOBJVAL} + = $value if ( defined($value) ); return; } @@ -545,12 +547,13 @@ sub getAttrUpdateChanges { sub getIsDay { my $self = shift; - return FHEM::Automation::ShuttersControl::Helper::_IsDay( $self->{shuttersDev} ); + return FHEM::Automation::ShuttersControl::Helper::_IsDay( + $self->{shuttersDev} ); } sub getAntiFreezeStatus { use POSIX qw(strftime); - my $self = shift; + my $self = shift; my $daytime = strftime( "%P", localtime() ); $daytime = ( defined($daytime) && $daytime @@ -756,10 +759,12 @@ sub getRainUnprotectionDelayObj { ( defined( $self->{ $self->{shuttersDev} }->{RainProtection} ) && defined( - $self->{ $self->{shuttersDev} }->{RainProtection}->{UNPROTECTIONDELAYOBJVAL} + $self->{ $self->{shuttersDev} }->{RainProtection} + ->{UNPROTECTIONDELAYOBJVAL} ) ) - ? $self->{ $self->{shuttersDev} }->{RainProtection}->{UNPROTECTIONDELAYOBJVAL} + ? $self->{ $self->{shuttersDev} }->{RainProtection} + ->{UNPROTECTIONDELAYOBJVAL} : 'none' ); } @@ -821,7 +826,7 @@ sub getRoommatesStatus { $FHEM::Automation::ShuttersControl::shutters->setRoommate($ro); my $currentPrio = $statePrio{ $FHEM::Automation::ShuttersControl::shutters - ->_getRoommateStatus }; + ->getRoommateStatus }; $minPrio = $currentPrio if ( $minPrio > $currentPrio ); } @@ -854,7 +859,7 @@ sub getRoommatesLastStatus { $FHEM::Automation::ShuttersControl::shutters->setRoommate($ro); my $currentPrio = $statePrio{ $FHEM::Automation::ShuttersControl::shutters - ->_getRoommateLastStatus }; + ->getRoommateLastStatus }; $minPrio = $currentPrio if ( $minPrio > $currentPrio ); } @@ -899,7 +904,8 @@ sub setShadingStatus { $self->{ $self->{shuttersDev} }{ShadingStatus}{VAL} = $value if ( defined($value) ); - $self->{ $self->{shuttersDev} }{ShadingStatus}{TIME} = int( ::gettimeofday() ) + $self->{ $self->{shuttersDev} }{ShadingStatus}{TIME} = + int( ::gettimeofday() ) if ( defined( $self->{ $self->{shuttersDev} }{ShadingStatus} ) ); return; @@ -945,7 +951,7 @@ sub setShadingLastPos { return; } -sub setShadingBetweenTheTimeSuspend { # Werte für value = 0, 1 +sub setShadingBetweenTheTimeSuspend { # Werte für value = 0, 1 my $self = shift; my $value = shift; @@ -1007,12 +1013,16 @@ sub getShadingStatus { # Werte für value = in, out, in reserved, out reserved ); } -sub getShadingBetweenTheTimeSuspend { # Werte für value = 0, 1 +sub getShadingBetweenTheTimeSuspend { # Werte für value = 0, 1 my $self = shift; return ( - defined( $self->{ $self->{shuttersDev} }{ShadingBetweenTheTimeSuspend} ) - && defined( $self->{ $self->{shuttersDev} }{ShadingBetweenTheTimeSuspend}{VAL} ) + defined( + $self->{ $self->{shuttersDev} }{ShadingBetweenTheTimeSuspend} + ) + && defined( + $self->{ $self->{shuttersDev} }{ShadingBetweenTheTimeSuspend}{VAL} + ) ? $self->{ $self->{shuttersDev} }{ShadingBetweenTheTimeSuspend}{VAL} : 0 ); @@ -1084,9 +1094,7 @@ sub getShadingLastPos { return ( defined( $self->{ $self->{shuttersDev} }{ShadingLastPos} ) - && defined( - $self->{ $self->{shuttersDev} }{ShadingLastPos}{VAL} - ) + && defined( $self->{ $self->{shuttersDev} }{ShadingLastPos}{VAL} ) ? $self->{ $self->{shuttersDev} }{ShadingLastPos}{VAL} : $FHEM::Automation::ShuttersControl::shutters->getShadingPos ); @@ -1094,7 +1102,4 @@ sub getShadingLastPos { ### Ende Beschattung - - - 1; diff --git a/fhem/lib/FHEM/Automation/ShuttersControl/Shutters/Attr.pm b/fhem/lib/FHEM/Automation/ShuttersControl/Shutters/Attr.pm index 46c4b12b6..46cd03f21 100644 --- a/fhem/lib/FHEM/Automation/ShuttersControl/Shutters/Attr.pm +++ b/fhem/lib/FHEM/Automation/ShuttersControl/Shutters/Attr.pm @@ -1,8 +1,8 @@ ############################################################################### # -# Developed with Kate +# Developed with VSCodium and richterger perl plugin # -# (c) 2018-2021 Copyright: Marko Oldenburg (fhemdevelopment@cooltux.net) +# (c) 2018-2022 Copyright: Marko Oldenburg (fhemdevelopment at cooltux dot net) # All rights reserved # # Special thanks goes to: @@ -46,24 +46,12 @@ use utf8; use FHEM::Automation::ShuttersControl::Helper qw (IsAdv PerlCodeCheck); -use GPUtils qw(GP_Import); - -## Import der FHEM Funktionen -BEGIN { - GP_Import( - qw( - AttrVal - CommandAttr - gettimeofday) - ); -} - sub _setAttributs { my $shuttersDev = shift; my $attr = shift; my $attrVal = shift; - CommandAttr( undef, $shuttersDev . ' ' . $attr . ' ' . $attrVal ); + ::CommandAttr( undef, $shuttersDev . ' ' . $attr . ' ' . $attrVal ); return; } @@ -77,28 +65,28 @@ sub _getPosition { return $self->{ $self->{shuttersDev} }->{$attr}->{position} if ( exists( $self->{ $self->{shuttersDev} }->{$attr}->{LASTGETTIME} ) - && ( gettimeofday() - + && ( ::gettimeofday() - $self->{ $self->{shuttersDev} }->{$attr}->{LASTGETTIME} ) < 2 ); $self->{ $self->{shuttersDev} }->{$attr}->{LASTGETTIME} = - int( gettimeofday() ); + int( ::gettimeofday() ); my $position; my $posAssignment; if ( - AttrVal( $self->{shuttersDev}, $attr, + ::AttrVal( $self->{shuttersDev}, $attr, $FHEM::Automation::ShuttersControl::userAttrList{$userAttrList} - [ AttrVal( $self->{shuttersDev}, 'ASC', 2 ) ] ) =~ + [ ::AttrVal( $self->{shuttersDev}, 'ASC', 2 ) ] ) =~ m{\A\{.+\}\z}xms ) { my $response = PerlCodeCheck( - AttrVal( + ::AttrVal( $self->{shuttersDev}, $attr, $FHEM::Automation::ShuttersControl::userAttrList{$userAttrList} - [ AttrVal( $self->{shuttersDev}, 'ASC', 2 ) ] + [ ::AttrVal( $self->{shuttersDev}, 'ASC', 2 ) ] ) ); @@ -108,14 +96,14 @@ sub _getPosition { $position =~ m{\A\d+(\.\d+)?\z}xms ? $position : $FHEM::Automation::ShuttersControl::userAttrList{$userAttrList} - [ AttrVal( $self->{shuttersDev}, 'ASC', 2 ) ] + [ ::AttrVal( $self->{shuttersDev}, 'ASC', 2 ) ] ); $posAssignment = ( - defined($posAssignment) - && $posAssignment =~ m{\A\d+(\.\d+)?\z}xms - ? $posAssignment - : 'none' + defined($posAssignment) + && $posAssignment =~ m{\A\d+(\.\d+)?\z}xms + ? $posAssignment + : 'none' ); } else { @@ -124,7 +112,7 @@ sub _getPosition { $self->{shuttersDev}, $attr, $FHEM::Automation::ShuttersControl::userAttrList{$userAttrList} - [ AttrVal( $self->{shuttersDev}, 'ASC', 2 ) ] + [ ::AttrVal( $self->{shuttersDev}, 'ASC', 2 ) ] ); } @@ -145,8 +133,7 @@ sub _getPosition { ) { $self->{ $self->{shuttersDev} }->{$attr}->{position} = - PerlCodeCheck( - $self->{ $self->{shuttersDev} }->{$attr}->{position} ); + PerlCodeCheck( $self->{ $self->{shuttersDev} }->{$attr}->{position} ); } return ( @@ -154,7 +141,7 @@ sub _getPosition { m{^\d+(\.\d+)?$}xms ? $self->{ $self->{shuttersDev} }->{$attr}->{position} : $FHEM::Automation::ShuttersControl::userAttrList{$userAttrList} - [ AttrVal( $self->{shuttersDev}, 'ASC', 2 ) ] + [ ::AttrVal( $self->{shuttersDev}, 'ASC', 2 ) ] ); } @@ -167,7 +154,7 @@ sub _getPositionAssignment { return $self->{ $self->{shuttersDev} }->{$attr}->{posAssignment} if ( exists( $self->{ $self->{shuttersDev} }->{$attr}->{LASTGETTIME} ) - && ( gettimeofday() - + && ( ::gettimeofday() - $self->{ $self->{shuttersDev} }->{$attr}->{LASTGETTIME} ) < 2 ); $FHEM::Automation::ShuttersControl::shutters->$getFn; @@ -213,7 +200,7 @@ sub setShuttersPlace { sub getShuttersPlace { my $self = shift; - return AttrVal( $self->{shuttersDev}, 'ASC_ShuttersPlace', 'window' ); + return ::AttrVal( $self->{shuttersDev}, 'ASC_ShuttersPlace', 'window' ); } sub setSlatPosCmd { @@ -236,15 +223,15 @@ sub getSlatPosCmd { $self->{ $self->{shuttersDev} }->{ASC_SlatPosCmd_SlatDevice} ->{LASTGETTIME} ) - && ( gettimeofday() - + && ( ::gettimeofday() - $self->{ $self->{shuttersDev} }->{ASC_SlatPosCmd_SlatDevice} ->{LASTGETTIME} ) < 2 ); $self->{ $self->{shuttersDev} }->{ASC_SlatPosCmd_SlatDevice}->{LASTGETTIME} - = int( gettimeofday() ); + = int( ::gettimeofday() ); my ( $slatPosCmd, $slatDevice ) = - FHEM::Automation::ShuttersControl::Helper::GetAttrValues( $self->{shuttersDev}, - 'ASC_SlatPosCmd_SlatDevice', 'none:none' ); + FHEM::Automation::ShuttersControl::Helper::GetAttrValues( + $self->{shuttersDev}, 'ASC_SlatPosCmd_SlatDevice', 'none:none' ); ## Erwartetes Ergebnis # upTime:upBrightnessVal @@ -268,7 +255,7 @@ sub getSlatDevice { $self->{ $self->{shuttersDev} }->{ASC_SlatPosCmd_SlatDevice} ->{LASTGETTIME} ) - && ( gettimeofday() - + && ( ::gettimeofday() - $self->{ $self->{shuttersDev} }->{ASC_SlatPosCmd_SlatDevice} ->{LASTGETTIME} ) < 2 ); @@ -299,15 +286,15 @@ sub getPrivacyUpTime { $self->{ $self->{shuttersDev} }->{ASC_PrivacyUpValue_beforeDayOpen} ->{LASTGETTIME} ) - && ( gettimeofday() - + && ( ::gettimeofday() - $self->{ $self->{shuttersDev} }->{ASC_PrivacyUpValue_beforeDayOpen} ->{LASTGETTIME} ) < 2 ); $self->{ $self->{shuttersDev} }->{ASC_PrivacyUpValue_beforeDayOpen} - ->{LASTGETTIME} = int( gettimeofday() ); + ->{LASTGETTIME} = int( ::gettimeofday() ); my ( $upTime, $upBrightnessVal ) = - FHEM::Automation::ShuttersControl::Helper::GetAttrValues( $self->{shuttersDev}, - 'ASC_PrivacyUpValue_beforeDayOpen', '-1:-1' ); + FHEM::Automation::ShuttersControl::Helper::GetAttrValues( + $self->{shuttersDev}, 'ASC_PrivacyUpValue_beforeDayOpen', '-1:-1' ); ## Erwartetes Ergebnis # upTime:upBrightnessVal @@ -341,7 +328,7 @@ sub getPrivacyUpBrightnessVal { $self->{ $self->{shuttersDev} }->{ASC_PrivacyUpValue_beforeDayOpen} ->{LASTGETTIME} ) - && ( gettimeofday() - + && ( ::gettimeofday() - $self->{ $self->{shuttersDev} }->{ASC_PrivacyUpValue_beforeDayOpen} ->{LASTGETTIME} ) < 2 ); @@ -378,14 +365,15 @@ sub getPrivacyDownTime { $self->{ $self->{shuttersDev} } ->{ASC_PrivacyDownValue_beforeNightClose}->{LASTGETTIME} ) - && ( gettimeofday() - + && ( ::gettimeofday() - $self->{ $self->{shuttersDev} } ->{ASC_PrivacyDownValue_beforeNightClose}->{LASTGETTIME} ) < 2 ); $self->{ $self->{shuttersDev} }->{ASC_PrivacyDownValue_beforeNightClose} - ->{LASTGETTIME} = int( gettimeofday() ); + ->{LASTGETTIME} = int( ::gettimeofday() ); my ( $downTime, $downBrightnessVal ) = - FHEM::Automation::ShuttersControl::Helper::GetAttrValues( $self->{shuttersDev}, + FHEM::Automation::ShuttersControl::Helper::GetAttrValues( + $self->{shuttersDev}, 'ASC_PrivacyDownValue_beforeNightClose', '-1:-1' ); ## Erwartetes Ergebnis @@ -420,7 +408,7 @@ sub getPrivacyDownBrightnessVal { $self->{ $self->{shuttersDev} } ->{ASC_PrivacyDownValue_beforeNightClose}->{LASTGETTIME} ) - && ( gettimeofday() - + && ( ::gettimeofday() - $self->{ $self->{shuttersDev} } ->{ASC_PrivacyDownValue_beforeNightClose}->{LASTGETTIME} ) < 2 ); @@ -497,7 +485,7 @@ sub setSelfDefenseMode { sub getSelfDefenseMode { my $self = shift; - return AttrVal( $self->{shuttersDev}, 'ASC_Self_Defense_Mode', 'gone' ); + return ::AttrVal( $self->{shuttersDev}, 'ASC_Self_Defense_Mode', 'gone' ); } sub setSelfDefenseAbsentDelay { @@ -513,13 +501,14 @@ sub setSelfDefenseAbsentDelay { sub getSelfDefenseAbsentDelay { my $self = shift; - return AttrVal( $self->{shuttersDev}, 'ASC_Self_Defense_AbsentDelay', 300 ); + return ::AttrVal( $self->{shuttersDev}, 'ASC_Self_Defense_AbsentDelay', + 300 ); } sub getCommandTemplate { my $self = shift; - return AttrVal( $self->{shuttersDev}, 'ASC_CommandTemplate', 'none' ); + return ::AttrVal( $self->{shuttersDev}, 'ASC_CommandTemplate', 'none' ); } sub setWiggleValue { @@ -534,7 +523,7 @@ sub setWiggleValue { sub getWiggleValue { my $self = shift; - return AttrVal( $self->{shuttersDev}, 'ASC_WiggleValue', 5 ); + return ::AttrVal( $self->{shuttersDev}, 'ASC_WiggleValue', 5 ); } sub setAdv { @@ -550,7 +539,7 @@ sub getAdv { my $self = shift; return ( - AttrVal( $self->{shuttersDev}, 'ASC_Adv', 'off' ) eq 'on' + ::AttrVal( $self->{shuttersDev}, 'ASC_Adv', 'off' ) eq 'on' ? ( IsAdv == 1 ? 1 : 0 ) : 0 ); @@ -593,7 +582,7 @@ sub setShadingMode { sub getShadingMode { my $self = shift; - return AttrVal( $self->{shuttersDev}, 'ASC_Shading_Mode', 'off' ); + return ::AttrVal( $self->{shuttersDev}, 'ASC_Shading_Mode', 'off' ); } sub _getTempSensor { @@ -604,15 +593,15 @@ sub _getTempSensor { exists( $self->{ $self->{shuttersDev} }->{ASC_TempSensor}->{LASTGETTIME} ) - && ( gettimeofday() - + && ( ::gettimeofday() - $self->{ $self->{shuttersDev} }->{ASC_TempSensor}->{LASTGETTIME} ) < 2 ); $self->{ $self->{shuttersDev} }->{ASC_TempSensor}->{LASTGETTIME} = - int( gettimeofday() ); + int( ::gettimeofday() ); my ( $device, $reading ) = - FHEM::Automation::ShuttersControl::Helper::GetAttrValues( $self->{shuttersDev}, - 'ASC_TempSensor', 'none' ); + FHEM::Automation::ShuttersControl::Helper::GetAttrValues( + $self->{shuttersDev}, 'ASC_TempSensor', 'none' ); ### erwartetes Ergebnis # DEVICE:READING @@ -631,7 +620,7 @@ sub getTempSensorReading { exists( $self->{ $self->{shuttersDev} }->{ASC_TempSensor}->{LASTGETTIME} ) - && ( gettimeofday() - + && ( ::gettimeofday() - $self->{ $self->{shuttersDev} }->{ASC_TempSensor}->{LASTGETTIME} ) < 2 ); @@ -664,15 +653,15 @@ sub _getIdleDetectionReading { $self->{ $self->{shuttersDev} }->{ASC_Shutter_IdleDetection} ->{LASTGETTIME} ) - && ( gettimeofday() - + && ( ::gettimeofday() - $self->{ $self->{shuttersDev} }->{ASC_Shutter_IdleDetection} ->{LASTGETTIME} ) < 2 ); $self->{ $self->{shuttersDev} }->{ASC_Shutter_IdleDetection}->{LASTGETTIME} - = int( gettimeofday() ); + = int( ::gettimeofday() ); my ( $reading, $value ) = - FHEM::Automation::ShuttersControl::Helper::GetAttrValues( $self->{shuttersDev}, - 'ASC_Shutter_IdleDetection', 'none' ); + FHEM::Automation::ShuttersControl::Helper::GetAttrValues( + $self->{shuttersDev}, 'ASC_Shutter_IdleDetection', 'none' ); ### erwartetes Ergebnis # READING:VALUE @@ -694,7 +683,7 @@ sub getIdleDetectionValue { $self->{ $self->{shuttersDev} }->{ASC_Shutter_IdleDetection} ->{LASTGETTIME} ) - && ( gettimeofday() - + && ( ::gettimeofday() - $self->{ $self->{shuttersDev} }->{ASC_Shutter_IdleDetection} ->{LASTGETTIME} ) < 2 ); @@ -728,15 +717,15 @@ sub _getBrightnessSensor { $self->{ $self->{shuttersDev} }->{ASC_BrightnessSensor} ->{LASTGETTIME} ) - && ( gettimeofday() - + && ( ::gettimeofday() - $self->{ $self->{shuttersDev} }->{ASC_BrightnessSensor} ->{LASTGETTIME} ) < 2 ); $self->{ $self->{shuttersDev} }->{ASC_BrightnessSensor}->{LASTGETTIME} = - int( gettimeofday() ); + int( ::gettimeofday() ); my ( $device, $reading, $max, $min ) = - FHEM::Automation::ShuttersControl::Helper::GetAttrValues( $self->{shuttersDev}, - 'ASC_BrightnessSensor', 'none' ); + FHEM::Automation::ShuttersControl::Helper::GetAttrValues( + $self->{shuttersDev}, 'ASC_BrightnessSensor', 'none' ); ### erwartetes Ergebnis # DEVICE:READING MAX:MIN @@ -760,7 +749,7 @@ sub getBrightnessReading { $self->{ $self->{shuttersDev} }->{ASC_BrightnessSensor} ->{LASTGETTIME} ) - && ( gettimeofday() - + && ( ::gettimeofday() - $self->{ $self->{shuttersDev} }->{ASC_BrightnessSensor} ->{LASTGETTIME} ) < 2 ); @@ -785,7 +774,7 @@ sub getShadingAzimuthLeft { $self->{ $self->{shuttersDev} }->{ASC_Shading_InOutAzimuth} ->{LASTGETTIME} ) - && ( gettimeofday() - + && ( ::gettimeofday() - $self->{ $self->{shuttersDev} }->{ASC_Shading_InOutAzimuth} ->{LASTGETTIME} ) < 2 ); @@ -814,15 +803,15 @@ sub getShadingAzimuthRight { $self->{ $self->{shuttersDev} }->{ASC_Shading_InOutAzimuth} ->{LASTGETTIME} ) - && ( gettimeofday() - + && ( ::gettimeofday() - $self->{ $self->{shuttersDev} }->{ASC_Shading_InOutAzimuth} ->{LASTGETTIME} ) < 2 ); $self->{ $self->{shuttersDev} }->{ASC_Shading_InOutAzimuth}->{LASTGETTIME} - = int( gettimeofday() ); + = int( ::gettimeofday() ); my ( $left, $right ) = - FHEM::Automation::ShuttersControl::Helper::GetAttrValues( $self->{shuttersDev}, - 'ASC_Shading_InOutAzimuth', '95:265' ); + FHEM::Automation::ShuttersControl::Helper::GetAttrValues( + $self->{shuttersDev}, 'ASC_Shading_InOutAzimuth', '95:265' ); ### erwartetes Ergebnis # MIN:MAX @@ -849,8 +838,8 @@ sub setShadingMinOutsideTemperature { sub getShadingMinOutsideTemperature { my $self = shift; - return AttrVal( $self->{shuttersDev}, 'ASC_Shading_Min_OutsideTemperature', - 18 ); + return ::AttrVal( $self->{shuttersDev}, + 'ASC_Shading_Min_OutsideTemperature', 18 ); } sub setShadingMinMaxElevation { @@ -873,15 +862,15 @@ sub getShadingMinElevation { $self->{ $self->{shuttersDev} }->{ASC_Shading_MinMax_Elevation} ->{LASTGETTIME} ) - && ( gettimeofday() - + && ( ::gettimeofday() - $self->{ $self->{shuttersDev} }->{ASC_Shading_MinMax_Elevation} ->{LASTGETTIME} ) < 2 ); $self->{ $self->{shuttersDev} }->{ASC_Shading_MinMax_Elevation} - ->{LASTGETTIME} = int( gettimeofday() ); + ->{LASTGETTIME} = int( ::gettimeofday() ); my ( $min, $max ) = - FHEM::Automation::ShuttersControl::Helper::GetAttrValues( $self->{shuttersDev}, - 'ASC_Shading_MinMax_Elevation', '25.0:100.0' ); + FHEM::Automation::ShuttersControl::Helper::GetAttrValues( + $self->{shuttersDev}, 'ASC_Shading_MinMax_Elevation', '25.0:100.0' ); ### erwartetes Ergebnis # MIN:MAX @@ -905,7 +894,7 @@ sub getShadingMaxElevation { $self->{ $self->{shuttersDev} }->{ASC_Shading_MinMax_Elevation} ->{LASTGETTIME} ) - && ( gettimeofday() - + && ( ::gettimeofday() - $self->{ $self->{shuttersDev} }->{ASC_Shading_MinMax_Elevation} ->{LASTGETTIME} ) < 2 ); @@ -943,15 +932,15 @@ sub getShadingStateChangeSunny { $self->{ $self->{shuttersDev} } ->{ASC_Shading_StateChange_SunnyCloudy}->{LASTGETTIME} ) - && ( gettimeofday() - + && ( ::gettimeofday() - $self->{ $self->{shuttersDev} } ->{ASC_Shading_StateChange_SunnyCloudy}->{LASTGETTIME} ) < 2 ); $self->{ $self->{shuttersDev} }->{ASC_Shading_StateChange_SunnyCloudy} - ->{LASTGETTIME} = int( gettimeofday() ); + ->{LASTGETTIME} = int( ::gettimeofday() ); my ( $sunny, $cloudy, $maxBrightnessAverageArrayObjects ) = - FHEM::Automation::ShuttersControl::Helper::GetAttrValues( $self->{shuttersDev}, - 'ASC_Shading_StateChange_SunnyCloudy', + FHEM::Automation::ShuttersControl::Helper::GetAttrValues( + $self->{shuttersDev}, 'ASC_Shading_StateChange_SunnyCloudy', '35000:20000' ); ### erwartetes Ergebnis @@ -982,7 +971,7 @@ sub getShadingStateChangeCloudy { $self->{ $self->{shuttersDev} } ->{ASC_Shading_StateChange_SunnyCloudy}->{LASTGETTIME} ) - && ( gettimeofday() - + && ( ::gettimeofday() - $self->{ $self->{shuttersDev} } ->{ASC_Shading_StateChange_SunnyCloudy}->{LASTGETTIME} ) < 2 ); @@ -1002,7 +991,7 @@ sub getMaxBrightnessAverageArrayObjects { $self->{ $self->{shuttersDev} } ->{ASC_Shading_StateChange_SunnyCloudy}->{LASTGETTIME} ) - && ( gettimeofday() - + && ( ::gettimeofday() - $self->{ $self->{shuttersDev} } ->{ASC_Shading_StateChange_SunnyCloudy}->{LASTGETTIME} ) < 2 ); @@ -1025,7 +1014,7 @@ sub setShadingWaitingPeriod { sub getShadingWaitingPeriod { my $self = shift; - return AttrVal( $self->{shuttersDev}, 'ASC_Shading_WaitingPeriod', 1200 ); + return ::AttrVal( $self->{shuttersDev}, 'ASC_Shading_WaitingPeriod', 1200 ); } ### Ende Beschattung sub setExternalTrigger { @@ -1046,16 +1035,16 @@ sub getExternalTriggerDevice { $self->{ $self->{shuttersDev} }->{ASC_ExternalTrigger} ->{LASTGETTIME} ) - && ( gettimeofday() - + && ( ::gettimeofday() - $self->{ $self->{shuttersDev} }->{ASC_ExternalTrigger} ->{LASTGETTIME} ) < 2 ); $self->{ $self->{shuttersDev} }->{ASC_ExternalTrigger}->{LASTGETTIME} = - int( gettimeofday() ); + int( ::gettimeofday() ); my ( $device, $reading, $valueActive, $valueInactive, $posActive, $posInactive, $valueActive2, $posActive2 ) - = FHEM::Automation::ShuttersControl::Helper::GetAttrValues( $self->{shuttersDev}, - 'ASC_ExternalTrigger', 'none' ); + = FHEM::Automation::ShuttersControl::Helper::GetAttrValues( + $self->{shuttersDev}, 'ASC_ExternalTrigger', 'none' ); ### erwartetes Ergebnis # DEVICE:READING VALUEACTIVE:VALUEINACTIVE POSACTIVE:POSINACTIVE VALUEACTIVE2:POSACTIVE2 @@ -1070,10 +1059,11 @@ sub getExternalTriggerDevice { $valueInactive; $self->{ $self->{shuttersDev} }->{ASC_ExternalTrigger}->{posactive} = $posActive; - $self->{ $self->{shuttersDev} }->{ASC_ExternalTrigger}->{posinactive} = - ( $posInactive ne 'none' + $self->{ $self->{shuttersDev} }->{ASC_ExternalTrigger}->{posinactive} = ( + $posInactive ne 'none' ? $posInactive - : $FHEM::Automation::ShuttersControl::shutters->getLastPos ); + : $FHEM::Automation::ShuttersControl::shutters->getLastPos + ); $self->{ $self->{shuttersDev} }->{ASC_ExternalTrigger}->{valueactive2} = $valueActive2; $self->{ $self->{shuttersDev} }->{ASC_ExternalTrigger}->{posactive2} = @@ -1092,7 +1082,7 @@ sub getExternalTriggerReading { $self->{ $self->{shuttersDev} }->{ASC_ExternalTrigger} ->{LASTGETTIME} ) - && ( gettimeofday() - + && ( ::gettimeofday() - $self->{ $self->{shuttersDev} }->{ASC_ExternalTrigger} ->{LASTGETTIME} ) < 2 ); @@ -1110,7 +1100,7 @@ sub getExternalTriggerValueActive { $self->{ $self->{shuttersDev} }->{ASC_ExternalTrigger} ->{LASTGETTIME} ) - && ( gettimeofday() - + && ( ::gettimeofday() - $self->{ $self->{shuttersDev} }->{ASC_ExternalTrigger} ->{LASTGETTIME} ) < 2 ); @@ -1130,7 +1120,7 @@ sub getExternalTriggerValueActive2 { $self->{ $self->{shuttersDev} }->{ASC_ExternalTrigger} ->{LASTGETTIME} ) - && ( gettimeofday() - + && ( ::gettimeofday() - $self->{ $self->{shuttersDev} }->{ASC_ExternalTrigger} ->{LASTGETTIME} ) < 2 ); @@ -1150,7 +1140,7 @@ sub getExternalTriggerValueInactive { $self->{ $self->{shuttersDev} }->{ASC_ExternalTrigger} ->{LASTGETTIME} ) - && ( gettimeofday() - + && ( ::gettimeofday() - $self->{ $self->{shuttersDev} }->{ASC_ExternalTrigger} ->{LASTGETTIME} ) < 2 ); @@ -1169,7 +1159,7 @@ sub getExternalTriggerPosActive { $self->{ $self->{shuttersDev} }->{ASC_ExternalTrigger} ->{LASTGETTIME} ) - && ( gettimeofday() - + && ( ::gettimeofday() - $self->{ $self->{shuttersDev} }->{ASC_ExternalTrigger} ->{LASTGETTIME} ) < 2 ); @@ -1187,7 +1177,7 @@ sub getExternalTriggerPosActive2 { $self->{ $self->{shuttersDev} }->{ASC_ExternalTrigger} ->{LASTGETTIME} ) - && ( gettimeofday() - + && ( ::gettimeofday() - $self->{ $self->{shuttersDev} }->{ASC_ExternalTrigger} ->{LASTGETTIME} ) < 2 ); @@ -1205,7 +1195,7 @@ sub getExternalTriggerPosInactive { $self->{ $self->{shuttersDev} }->{ASC_ExternalTrigger} ->{LASTGETTIME} ) - && ( gettimeofday() - + && ( ::gettimeofday() - $self->{ $self->{shuttersDev} }->{ASC_ExternalTrigger} ->{LASTGETTIME} ) < 2 ); @@ -1227,7 +1217,7 @@ sub setDelay { sub getDelay { my $self = shift; - my $val = AttrVal( $self->{shuttersDev}, 'ASC_Drive_Delay', -1 ); + my $val = ::AttrVal( $self->{shuttersDev}, 'ASC_Drive_Delay', -1 ); return ( $val =~ m{^\d+$}xms ? $val : -1 ); } @@ -1243,7 +1233,7 @@ sub setDelayStart { sub getDelayStart { my $self = shift; - my $val = AttrVal( $self->{shuttersDev}, 'ASC_Drive_DelayStart', -1 ); + my $val = ::AttrVal( $self->{shuttersDev}, 'ASC_Drive_DelayStart', -1 ); return ( ( $val > 0 && $val =~ m{^\d+$}xms ) ? $val : -1 ); } @@ -1260,7 +1250,7 @@ sub setBlockingTimeAfterManual { sub getBlockingTimeAfterManual { my $self = shift; - return AttrVal( $self->{shuttersDev}, 'ASC_BlockingTime_afterManual', + return ::AttrVal( $self->{shuttersDev}, 'ASC_BlockingTime_afterManual', 1200 ); } @@ -1277,7 +1267,7 @@ sub setBlockingTimeBeforNightClose { sub getBlockingTimeBeforNightClose { my $self = shift; - return AttrVal( $self->{shuttersDev}, 'ASC_BlockingTime_beforNightClose', + return ::AttrVal( $self->{shuttersDev}, 'ASC_BlockingTime_beforNightClose', 3600 ); } @@ -1294,7 +1284,7 @@ sub setBlockingTimeBeforDayOpen { sub getBlockingTimeBeforDayOpen { my $self = shift; - return AttrVal( $self->{shuttersDev}, 'ASC_BlockingTime_beforDayOpen', + return ::AttrVal( $self->{shuttersDev}, 'ASC_BlockingTime_beforDayOpen', 3600 ); } @@ -1310,9 +1300,9 @@ sub setPosCmd { sub getPosCmd { my $self = shift; - return AttrVal( $self->{shuttersDev}, 'ASC_Pos_Reading', + return ::AttrVal( $self->{shuttersDev}, 'ASC_Pos_Reading', $FHEM::Automation::ShuttersControl::userAttrList{'ASC_Pos_Reading'} - [ AttrVal( $self->{shuttersDev}, 'ASC', 1 ) ] ); + [ ::AttrVal( $self->{shuttersDev}, 'ASC', 1 ) ] ); } sub setOpenPos { @@ -1377,7 +1367,7 @@ sub setVentilatePosAfterDayClosed { sub getVentilatePosAfterDayClosed { my $self = shift; - return AttrVal( $self->{shuttersDev}, 'ASC_WindowRec_PosAfterDayClosed', + return ::AttrVal( $self->{shuttersDev}, 'ASC_WindowRec_PosAfterDayClosed', 'open' ); } @@ -1442,7 +1432,7 @@ sub setVentilateOpen { sub getVentilateOpen { my $self = shift; - return AttrVal( $self->{shuttersDev}, 'ASC_Ventilate_Window_Open', 'on' ); + return ::AttrVal( $self->{shuttersDev}, 'ASC_Ventilate_Window_Open', 'on' ); } sub setComfortOpenPos { @@ -1482,7 +1472,7 @@ sub setPartyMode { sub getPartyMode { my $self = shift; - return AttrVal( $self->{shuttersDev}, 'ASC_Partymode', 'off' ); + return ::AttrVal( $self->{shuttersDev}, 'ASC_Partymode', 'off' ); } sub setRoommates { @@ -1497,7 +1487,7 @@ sub setRoommates { sub getRoommates { my $self = shift; - return AttrVal( $self->{shuttersDev}, 'ASC_Roommate_Device', 'none' ); + return ::AttrVal( $self->{shuttersDev}, 'ASC_Roommate_Device', 'none' ); } sub setRoommatesReading { @@ -1512,7 +1502,7 @@ sub setRoommatesReading { sub getRoommatesReading { my $self = shift; - return AttrVal( $self->{shuttersDev}, 'ASC_Roommate_Reading', 'state' ); + return ::AttrVal( $self->{shuttersDev}, 'ASC_Roommate_Reading', 'state' ); } sub getWindPos { @@ -1525,7 +1515,7 @@ sub getWindPos { exists( $self->{ $self->{shuttersDev} }->{ASC_WindParameters}->{LASTGETTIME} ) - && ( gettimeofday() - + && ( ::gettimeofday() - $self->{ $self->{shuttersDev} }->{ASC_WindParameters}->{LASTGETTIME} ) < 2 ); @@ -1544,15 +1534,15 @@ sub getWindMax { exists( $self->{ $self->{shuttersDev} }->{ASC_WindParameters}->{LASTGETTIME} ) - && ( gettimeofday() - + && ( ::gettimeofday() - $self->{ $self->{shuttersDev} }->{ASC_WindParameters}->{LASTGETTIME} ) < 2 ); $self->{ $self->{shuttersDev} }->{ASC_WindParameters}->{LASTGETTIME} = - int( gettimeofday() ); + int( ::gettimeofday() ); my ( $max, $hyst, $pos ) = - FHEM::Automation::ShuttersControl::Helper::GetAttrValues( $self->{shuttersDev}, - 'ASC_WindParameters', '50:20' ); + FHEM::Automation::ShuttersControl::Helper::GetAttrValues( + $self->{shuttersDev}, 'ASC_WindParameters', '50:20' ); ## Erwartetes Ergebnis # max:hyst pos @@ -1560,10 +1550,11 @@ sub getWindMax { $self->{ $self->{shuttersDev} }->{ASC_WindParameters}->{triggermax} = $max; $self->{ $self->{shuttersDev} }->{ASC_WindParameters}->{triggerhyst} = ( $hyst ne 'none' ? $max - $hyst : $max - 20 ); - $self->{ $self->{shuttersDev} }->{ASC_WindParameters}->{closedPos} = - ( $pos ne 'none' + $self->{ $self->{shuttersDev} }->{ASC_WindParameters}->{closedPos} = ( + $pos ne 'none' ? $pos - : $FHEM::Automation::ShuttersControl::shutters->getOpenPos ); + : $FHEM::Automation::ShuttersControl::shutters->getOpenPos + ); return $self->{ $self->{shuttersDev} }->{ASC_WindParameters}->{triggermax}; } @@ -1587,7 +1578,7 @@ sub getWindMin { exists( $self->{ $self->{shuttersDev} }->{ASC_WindParameters}->{LASTGETTIME} ) - && ( gettimeofday() - + && ( ::gettimeofday() - $self->{ $self->{shuttersDev} }->{ASC_WindParameters}->{LASTGETTIME} ) < 2 ); @@ -1608,7 +1599,7 @@ sub setWindProtection { sub getWindProtection { my $self = shift; - return AttrVal( $self->{shuttersDev}, 'ASC_WindProtection', 'off' ); + return ::AttrVal( $self->{shuttersDev}, 'ASC_WindProtection', 'off' ); } sub setRainProtection { @@ -1623,7 +1614,7 @@ sub setRainProtection { sub getRainProtection { my $self = shift; - return AttrVal( $self->{shuttersDev}, 'ASC_RainProtection', 'off' ); + return ::AttrVal( $self->{shuttersDev}, 'ASC_RainProtection', 'off' ); } sub setModeUp { @@ -1638,7 +1629,7 @@ sub setModeUp { sub getModeUp { my $self = shift; - return AttrVal( $self->{shuttersDev}, 'ASC_Mode_Up', 'always' ); + return ::AttrVal( $self->{shuttersDev}, 'ASC_Mode_Up', 'always' ); } sub setModeDown { @@ -1653,7 +1644,7 @@ sub setModeDown { sub getModeDown { my $self = shift; - return AttrVal( $self->{shuttersDev}, 'ASC_Mode_Down', 'always' ); + return ::AttrVal( $self->{shuttersDev}, 'ASC_Mode_Down', 'always' ); } sub setLockOut { @@ -1668,7 +1659,7 @@ sub setLockOut { sub getLockOut { my $self = shift; - return AttrVal( $self->{shuttersDev}, 'ASC_LockOut', 'off' ); + return ::AttrVal( $self->{shuttersDev}, 'ASC_LockOut', 'off' ); } sub setLockOutCmd { @@ -1683,7 +1674,7 @@ sub setLockOutCmd { sub getLockOutCmd { my $self = shift; - return AttrVal( $self->{shuttersDev}, 'ASC_LockOut_Cmd', 'none' ); + return ::AttrVal( $self->{shuttersDev}, 'ASC_LockOut_Cmd', 'none' ); } sub setAntiFreeze { @@ -1698,7 +1689,7 @@ sub setAntiFreeze { sub getAntiFreeze { my $self = shift; - return AttrVal( $self->{shuttersDev}, 'ASC_Antifreeze', 'off' ); + return ::AttrVal( $self->{shuttersDev}, 'ASC_Antifreeze', 'off' ); } sub setAutoAstroModeMorning { @@ -1713,7 +1704,8 @@ sub setAutoAstroModeMorning { sub getAutoAstroModeMorning { my $self = shift; - return AttrVal( $self->{shuttersDev}, 'ASC_AutoAstroModeMorning', 'none' ); + return ::AttrVal( $self->{shuttersDev}, 'ASC_AutoAstroModeMorning', + 'none' ); } sub setAutoAstroModeEvening { @@ -1728,7 +1720,8 @@ sub setAutoAstroModeEvening { sub getAutoAstroModeEvening { my $self = shift; - return AttrVal( $self->{shuttersDev}, 'ASC_AutoAstroModeEvening', 'none' ); + return ::AttrVal( $self->{shuttersDev}, 'ASC_AutoAstroModeEvening', + 'none' ); } sub setAutoAstroModeMorningHorizon { @@ -1744,7 +1737,7 @@ sub setAutoAstroModeMorningHorizon { sub getAutoAstroModeMorningHorizon { my $self = shift; - return AttrVal( $self->{shuttersDev}, 'ASC_AutoAstroModeMorningHorizon', + return ::AttrVal( $self->{shuttersDev}, 'ASC_AutoAstroModeMorningHorizon', 0 ); } @@ -1761,7 +1754,7 @@ sub setAutoAstroModeEveningHorizon { sub getAutoAstroModeEveningHorizon { my $self = shift; - return AttrVal( $self->{shuttersDev}, 'ASC_AutoAstroModeEveningHorizon', + return ::AttrVal( $self->{shuttersDev}, 'ASC_AutoAstroModeEveningHorizon', 0 ); } @@ -1777,7 +1770,7 @@ sub setUp { sub getUp { my $self = shift; - return AttrVal( $self->{shuttersDev}, 'ASC_Up', 'astro' ); + return ::AttrVal( $self->{shuttersDev}, 'ASC_Up', 'astro' ); } sub setDown { @@ -1792,14 +1785,15 @@ sub setDown { sub getDown { my $self = shift; - return AttrVal( $self->{shuttersDev}, 'ASC_Down', 'astro' ); + return ::AttrVal( $self->{shuttersDev}, 'ASC_Down', 'astro' ); } sub setShadingBetweenTheTime { my $self = shift; my $attrVal = shift; - _setAttributs( $self->{shuttersDev}, 'ASC_Shading_BetweenTheTime', $attrVal ); + _setAttributs( $self->{shuttersDev}, 'ASC_Shading_BetweenTheTime', + $attrVal ); return; } @@ -1807,7 +1801,8 @@ sub setShadingBetweenTheTime { sub getShadingBetweenTheTime { my $self = shift; - return AttrVal( $self->{shuttersDev}, 'ASC_Shading_BetweenTheTime', '00:00-24:00' ); + return ::AttrVal( $self->{shuttersDev}, 'ASC_Shading_BetweenTheTime', + '00:00-24:00' ); } sub setTimeUpEarly { @@ -1822,7 +1817,7 @@ sub setTimeUpEarly { sub getTimeUpEarly { my $self = shift; - my $val = AttrVal( $self->{shuttersDev}, 'ASC_Time_Up_Early', '05:00' ); + my $val = ::AttrVal( $self->{shuttersDev}, 'ASC_Time_Up_Early', '05:00' ); if ( defined( PerlCodeCheck($val) ) ) { $val = PerlCodeCheck($val); @@ -1847,7 +1842,7 @@ sub setTimeUpLate { sub getTimeUpLate { my $self = shift; - my $val = AttrVal( $self->{shuttersDev}, 'ASC_Time_Up_Late', '08:30' ); + my $val = ::AttrVal( $self->{shuttersDev}, 'ASC_Time_Up_Late', '08:30' ); if ( defined( PerlCodeCheck($val) ) ) { $val = PerlCodeCheck($val); @@ -1872,7 +1867,7 @@ sub setTimeDownEarly { sub getTimeDownEarly { my $self = shift; - my $val = AttrVal( $self->{shuttersDev}, 'ASC_Time_Down_Early', '16:00' ); + my $val = ::AttrVal( $self->{shuttersDev}, 'ASC_Time_Down_Early', '16:00' ); if ( defined( PerlCodeCheck($val) ) ) { $val = PerlCodeCheck($val); @@ -1897,7 +1892,7 @@ sub setTimeDownLate { sub getTimeDownLate { my $self = shift; - my $val = AttrVal( $self->{shuttersDev}, 'ASC_Time_Down_Late', '22:00' ); + my $val = ::AttrVal( $self->{shuttersDev}, 'ASC_Time_Down_Late', '22:00' ); if ( defined( PerlCodeCheck($val) ) ) { $val = PerlCodeCheck($val); @@ -1923,7 +1918,7 @@ sub getTimeUpWeHoliday { my $self = shift; my $val = - AttrVal( $self->{shuttersDev}, 'ASC_Time_Up_WE_Holiday', '01:25' ); + ::AttrVal( $self->{shuttersDev}, 'ASC_Time_Up_WE_Holiday', '01:25' ); if ( defined( PerlCodeCheck($val) ) ) { $val = PerlCodeCheck($val); @@ -1945,7 +1940,7 @@ sub getBrightnessMinVal { $self->{ $self->{shuttersDev} }->{ASC_BrightnessSensor} ->{LASTGETTIME} ) - && ( gettimeofday() - + && ( ::gettimeofday() - $self->{ $self->{shuttersDev} }->{ASC_BrightnessSensor} ->{LASTGETTIME} ) < 2 ); @@ -1964,7 +1959,7 @@ sub getBrightnessMaxVal { $self->{ $self->{shuttersDev} }->{ASC_BrightnessSensor} ->{LASTGETTIME} ) - && ( gettimeofday() - + && ( ::gettimeofday() - $self->{ $self->{shuttersDev} }->{ASC_BrightnessSensor} ->{LASTGETTIME} ) < 2 ); @@ -1986,7 +1981,7 @@ sub setDriveUpMaxDuration { sub getDriveUpMaxDuration { my $self = shift; - return AttrVal( $self->{shuttersDev}, 'ASC_DriveUpMaxDuration', 60 ); + return ::AttrVal( $self->{shuttersDev}, 'ASC_DriveUpMaxDuration', 60 ); } 1; diff --git a/fhem/lib/FHEM/Automation/ShuttersControl/Shutters/Readings.pm b/fhem/lib/FHEM/Automation/ShuttersControl/Shutters/Readings.pm index 722ee2603..c6fe86f8c 100644 --- a/fhem/lib/FHEM/Automation/ShuttersControl/Shutters/Readings.pm +++ b/fhem/lib/FHEM/Automation/ShuttersControl/Shutters/Readings.pm @@ -1,8 +1,8 @@ ############################################################################### # -# Developed with Kate +# Developed with VSCodium and richterger perl plugin # -# (c) 2018-2021 Copyright: Marko Oldenburg (fhemdevelopment@cooltux.net) +# (c) 2018-2022 Copyright: Marko Oldenburg (fhemdevelopment at cooltux dot net) # All rights reserved # # Special thanks goes to: @@ -44,21 +44,10 @@ use strict; use warnings; use utf8; -use GPUtils qw(GP_Import); - -## Import der FHEM Funktionen -BEGIN { - GP_Import( - qw( - ReadingsVal - ReadingsNum) - ); -} - sub getBrightness { my $self = shift; - return ReadingsNum( + return ::ReadingsNum( $FHEM::Automation::ShuttersControl::shutters->_getBrightnessSensor, $FHEM::Automation::ShuttersControl::shutters->getBrightnessReading, -1 ); @@ -67,7 +56,7 @@ sub getBrightness { sub getWindStatus { my $self = shift; - return ReadingsVal( + return ::ReadingsVal( $FHEM::Automation::ShuttersControl::ascDev->_getWindSensor, $FHEM::Automation::ShuttersControl::ascDev->getWindSensorReading, -1 ); } @@ -75,7 +64,7 @@ sub getWindStatus { sub getStatus { my $self = shift; - return ReadingsNum( $self->{shuttersDev}, + return ::ReadingsNum( $self->{shuttersDev}, $FHEM::Automation::ShuttersControl::shutters->getPosCmd, 0 ); } @@ -88,7 +77,7 @@ sub getDelayCmd { sub getASCenable { my $self = shift; - return ReadingsVal( $self->{shuttersDev}, 'ASC_Enable', 'on' ); + return ::ReadingsVal( $self->{shuttersDev}, 'ASC_Enable', 'on' ); } 1; diff --git a/fhem/lib/FHEM/Automation/ShuttersControl/Window.pm b/fhem/lib/FHEM/Automation/ShuttersControl/Window.pm index 20edad1d3..595353bbb 100644 --- a/fhem/lib/FHEM/Automation/ShuttersControl/Window.pm +++ b/fhem/lib/FHEM/Automation/ShuttersControl/Window.pm @@ -1,8 +1,8 @@ ############################################################################### # -# Developed with Kate +# Developed with VSCodium and richterger perl plugin # -# (c) 2018-2021 Copyright: Marko Oldenburg (fhemdevelopment@cooltux.net) +# (c) 2018-2022 Copyright: Marko Oldenburg (fhemdevelopment at cooltux dot net) # All rights reserved # # Special thanks goes to: @@ -47,7 +47,7 @@ use utf8; use FHEM::Automation::ShuttersControl::Window::Attr; use FHEM::Automation::ShuttersControl::Window::Readings; -our @ISA = +use base qw(FHEM::Automation::ShuttersControl::Window::Attr FHEM::Automation::ShuttersControl::Window::Readings); 1; diff --git a/fhem/lib/FHEM/Automation/ShuttersControl/Window/Attr.pm b/fhem/lib/FHEM/Automation/ShuttersControl/Window/Attr.pm index ab4001b3d..6c727be58 100644 --- a/fhem/lib/FHEM/Automation/ShuttersControl/Window/Attr.pm +++ b/fhem/lib/FHEM/Automation/ShuttersControl/Window/Attr.pm @@ -1,8 +1,8 @@ ############################################################################### # -# Developed with Kate +# Developed with VSCodium and richterger perl plugin # -# (c) 2018-2021 Copyright: Marko Oldenburg (fhemdevelopment@cooltux.net) +# (c) 2018-2022 Copyright: Marko Oldenburg (fhemdevelopment at cooltux dot net) # All rights reserved # # Special thanks goes to: @@ -44,17 +44,6 @@ use strict; use warnings; use utf8; -use GPUtils qw(GP_Import); - -## Import der FHEM Funktionen -BEGIN { - GP_Import( - qw( - AttrVal - gettimeofday) - ); -} - sub setSubTyp { my $self = shift; my $attrVal = shift; @@ -67,7 +56,8 @@ sub setSubTyp { sub getSubTyp { my $self = shift; - return AttrVal( $self->{shuttersDev}, 'ASC_WindowRec_subType', 'twostate' ); + return ::AttrVal( $self->{shuttersDev}, 'ASC_WindowRec_subType', + 'twostate' ); } sub setWinDev { @@ -87,15 +77,15 @@ sub _getWinDev { exists( $self->{ $self->{shuttersDev} }->{ASC_WindowRec}->{LASTGETTIME} ) - && ( gettimeofday() - + && ( ::gettimeofday() - $self->{ $self->{shuttersDev} }->{ASC_WindowRec}->{LASTGETTIME} ) < 2 ); $self->{ $self->{shuttersDev} }->{ASC_WindowRec}->{LASTGETTIME} = - int( gettimeofday() ); + int( ::gettimeofday() ); my ( $device, $reading ) = - FHEM::Automation::ShuttersControl::Helper::GetAttrValues( $self->{shuttersDev}, - 'ASC_WindowRec', 'none' ); + FHEM::Automation::ShuttersControl::Helper::GetAttrValues( + $self->{shuttersDev}, 'ASC_WindowRec', 'none' ); ### erwartetes Ergebnis # DEVICE:READING VALUEACTIVE:VALUEINACTIVE POSACTIVE:POSINACTIVE @@ -116,7 +106,7 @@ sub getWinDevReading { exists( $self->{ $self->{shuttersDev} }->{ASC_WindowRec}->{LASTGETTIME} ) - && ( gettimeofday() - + && ( ::gettimeofday() - $self->{ $self->{shuttersDev} }->{ASC_WindowRec}->{LASTGETTIME} ) < 2 ); diff --git a/fhem/lib/FHEM/Automation/ShuttersControl/Window/Readings.pm b/fhem/lib/FHEM/Automation/ShuttersControl/Window/Readings.pm index b75d1c049..8a619c67c 100644 --- a/fhem/lib/FHEM/Automation/ShuttersControl/Window/Readings.pm +++ b/fhem/lib/FHEM/Automation/ShuttersControl/Window/Readings.pm @@ -1,8 +1,8 @@ ############################################################################### # -# Developed with Kate +# Developed with VSCodium and richterger perl plugin # -# (c) 2018-2021 Copyright: Marko Oldenburg (fhemdevelopment@cooltux.net) +# (c) 2018-2022 Copyright: Marko Oldenburg (fhemdevelopment at cooltux dot net) # All rights reserved # # Special thanks goes to: @@ -44,20 +44,10 @@ use strict; use warnings; use utf8; -use GPUtils qw(GP_Import); - -## Import der FHEM Funktionen -BEGIN { - GP_Import( - qw( - ReadingsVal) - ); -} - sub getWinStatus { my $self = shift; - return ReadingsVal( + return ::ReadingsVal( $FHEM::Automation::ShuttersControl::shutters->_getWinDev, $FHEM::Automation::ShuttersControl::shutters->getWinDevReading, 'closed' );