diff --git a/FHEM/73_AutoShuttersControl.pm b/FHEM/73_AutoShuttersControl.pm index c8c716f..9468319 100644 --- a/FHEM/73_AutoShuttersControl.pm +++ b/FHEM/73_AutoShuttersControl.pm @@ -54,6 +54,13 @@ use GPUtils qw(GP_Import GP_Export); ## 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( @@ -67,11 +74,11 @@ sub Initialize { ## Da ich mit package arbeite müssen in die Initialize für die jeweiligen hash Fn Funktionen der Funktionsname # und davor mit :: getrennt der eigentliche package Name des Modules - $hash->{SetFn} = \&Set; - $hash->{GetFn} = \&Get; - $hash->{DefFn} = \&Define; - $hash->{NotifyFn} = \&Notify; - $hash->{UndefFn} = \&Undef; + $hash->{SetFn} = \&FHEM::Automation::ShuttersControl::Set; + $hash->{GetFn} = \&FHEM::Automation::ShuttersControl::Get; + $hash->{DefFn} = \&FHEM::Automation::ShuttersControl::Define; + $hash->{NotifyFn} = \&FHEM::Automation::ShuttersControl::Notify; + $hash->{UndefFn} = \&FHEM::Automation::ShuttersControl::Undef; $hash->{AttrList} = 'ASC_tempSensor ' . 'ASC_brightnessDriveUpDown ' @@ -94,7 +101,7 @@ sub Initialize { . 'ASC_slatDriveCmdInverse:0,1 ' . $readingFnAttributes; $hash->{NotifyOrderPrefix} = '51-'; # Order Nummer für NotifyFn - $hash->{FW_detailFn} = \&ShuttersInformation; + $hash->{FW_detailFn} = \&FHEM::Automation::ShuttersControl::ShuttersInformation; $hash->{parseParams} = 1; return FHEM::Meta::InitMod( __FILE__, $hash ); diff --git a/lib/FHEM/Automation/ShuttersControl.pm b/lib/FHEM/Automation/ShuttersControl.pm index e9d29f0..6711034 100644 --- a/lib/FHEM/Automation/ShuttersControl.pm +++ b/lib/FHEM/Automation/ShuttersControl.pm @@ -76,6 +76,10 @@ use Date::Parse; use FHEM::Automation::ShuttersControl::Shutters; use FHEM::Automation::ShuttersControl::Dev; +require Exporter; +our @ISA = qw(Exporter); +our @Export = qw($shutters $ascDev %userAttrList); + # try to use JSON::MaybeXS wrapper # for chance of better performance + open code eval { @@ -202,7 +206,7 @@ BEGIN { ## Die Attributsliste welche an die Rolläden verteilt wird. Zusammen mit Default Werten -my %userAttrList = ( +our %userAttrList = ( 'ASC_Mode_Up:absent,always,off,home' => '-', 'ASC_Mode_Down:absent,always,off,home' => '-', 'ASC_Up:time,astro,brightness,roommate' => '-', @@ -285,8 +289,8 @@ my %posSetCmds = ( ); ## 2 Objekte werden erstellt -my $shutters = ASC_Shutters->new(); -my $ascDev = ASC_Dev->new(); +our $shutters = FHEM::Automation::ShuttersControl::Shutters->new(); +our $ascDev = FHEM::Automation::ShuttersControl::Dev->new(); sub ascAPIget { my ( $getCommand, $shutterDev, $value ) = @_; @@ -325,44 +329,6 @@ sub ascAPIset { return; } -sub Initialize { - my $hash = shift; - -## Da ich mit package arbeite müssen in die Initialize für die jeweiligen hash Fn Funktionen der Funktionsname - # und davor mit :: getrennt der eigentliche package Name des Modules - $hash->{SetFn} = \&Set; - $hash->{GetFn} = \&Get; - $hash->{DefFn} = \&Define; - $hash->{NotifyFn} = \&Notify; - $hash->{UndefFn} = \&Undef; - $hash->{AttrList} = - 'ASC_tempSensor ' - . 'ASC_brightnessDriveUpDown ' - . 'ASC_autoShuttersControlMorning:on,off ' - . 'ASC_autoShuttersControlEvening:on,off ' - . 'ASC_autoShuttersControlComfort:on,off ' - . 'ASC_residentsDev ' - . 'ASC_rainSensor ' - . 'ASC_autoAstroModeMorning:REAL,CIVIL,NAUTIC,ASTRONOMIC,HORIZON ' - . 'ASC_autoAstroModeMorningHorizon:-9,-8,-7,-6,-5,-4,-3,-2,-1,0,1,2,3,4,5,6,7,8,9 ' - . 'ASC_autoAstroModeEvening:REAL,CIVIL,NAUTIC,ASTRONOMIC,HORIZON ' - . 'ASC_autoAstroModeEveningHorizon:-9,-8,-7,-6,-5,-4,-3,-2,-1,0,1,2,3,4,5,6,7,8,9 ' - . 'ASC_freezeTemp:-5,-4,-3,-2,-1,0,1,2,3,4,5 ' - . 'ASC_shuttersDriveDelay ' - . 'ASC_twilightDevice ' - . 'ASC_windSensor ' - . 'ASC_expert:1 ' - . 'ASC_blockAscDrivesAfterManual:0,1 ' - . 'ASC_debug:1 ' - . 'ASC_slatDriveCmdInverse:0,1 ' - . $readingFnAttributes; - $hash->{NotifyOrderPrefix} = '51-'; # Order Nummer für NotifyFn - $hash->{FW_detailFn} = \&ShuttersInformation; - $hash->{parseParams} = 1; - - return FHEM::Meta::InitMod( __FILE__, $hash ); -} - sub Define { my $hash = shift // return; my $aArg = shift // return; @@ -398,7 +364,7 @@ sub Define { CommandAttr( undef, $name . ' icon fts_shutter_automatic' ) if ( AttrVal( $name, 'icon', 'none' ) eq 'none' ); CommandAttr( undef, - $name . ' devStateIcon { AutoShuttersControl_DevStateIcon($name) }' ) + $name . ' devStateIcon { ShuttersControl_DevStateIcon($name) }' ) if ( AttrVal( $name, 'devStateIcon', 'none' ) eq 'none' ); addToAttrList('ASC:0,1,2'); diff --git a/lib/FHEM/Automation/ShuttersControl/Dev.pm b/lib/FHEM/Automation/ShuttersControl/Dev.pm index 71a92bb..a426d96 100644 --- a/lib/FHEM/Automation/ShuttersControl/Dev.pm +++ b/lib/FHEM/Automation/ShuttersControl/Dev.pm @@ -39,6 +39,10 @@ ## Klasse ASC_Dev plus Subklassen ASC_Attr_Dev und ASC_Readings_Dev## package FHEM::Automation::ShuttersControl::Dev; + +use FHEM::Automation::ShuttersControl::Dev::Readings; +use FHEM::Automation::ShuttersControl::Dev::Attr; + our @ISA = qw(FHEM::Automation::ShuttersControl::Dev::Readings FHEM::Automation::ShuttersControl::Dev::Attr); use strict; diff --git a/lib/FHEM/Automation/ShuttersControl/Dev/Attr.pm b/lib/FHEM/Automation/ShuttersControl/Dev/Attr.pm index 3825771..fbfe5af 100644 --- a/lib/FHEM/Automation/ShuttersControl/Dev/Attr.pm +++ b/lib/FHEM/Automation/ShuttersControl/Dev/Attr.pm @@ -38,7 +38,7 @@ ############################################################################### ## Subklasse Attr ## -package ASC_Dev::Attr; +package FHEM::Automation::ShuttersControl::Dev::Attr; use strict; use warnings; @@ -46,6 +46,9 @@ use utf8; use GPUtils qw(GP_Import); +my $shutters = $FHEM::Automation::ShuttersControl::shutters; +my $ascDev = $FHEM::Automation::ShuttersControl::ascDev; + ## Import der FHEM Funktionen BEGIN { GP_Import( diff --git a/lib/FHEM/Automation/ShuttersControl/Dev/Readings.pm b/lib/FHEM/Automation/ShuttersControl/Dev/Readings.pm index c433750..c893a16 100644 --- a/lib/FHEM/Automation/ShuttersControl/Dev/Readings.pm +++ b/lib/FHEM/Automation/ShuttersControl/Dev/Readings.pm @@ -46,6 +46,9 @@ use utf8; use GPUtils qw(GP_Import); +my $shutters = $FHEM::Automation::ShuttersControl::shutters; +my $ascDev = $FHEM::Automation::ShuttersControl::ascDev; + ## Import der FHEM Funktionen BEGIN { GP_Import( diff --git a/lib/FHEM/Automation/ShuttersControl/Roommate.pm b/lib/FHEM/Automation/ShuttersControl/Roommate.pm index 071da3f..43f1f1f 100644 --- a/lib/FHEM/Automation/ShuttersControl/Roommate.pm +++ b/lib/FHEM/Automation/ShuttersControl/Roommate.pm @@ -46,6 +46,8 @@ use utf8; use GPUtils qw(GP_Import); +my $shutters = $FHEM::Automation::ShuttersControl::shutters; + ## Import der FHEM Funktionen BEGIN { GP_Import( diff --git a/lib/FHEM/Automation/ShuttersControl/Shutters.pm b/lib/FHEM/Automation/ShuttersControl/Shutters.pm index 058a1fa..37dd0d3 100644 --- a/lib/FHEM/Automation/ShuttersControl/Shutters.pm +++ b/lib/FHEM/Automation/ShuttersControl/Shutters.pm @@ -44,6 +44,12 @@ ## desweiteren wird noch die Klasse ASC_Roommate mit eingebunden 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); @@ -53,6 +59,9 @@ use utf8; use GPUtils qw(GP_Import); +my $shutters = $FHEM::Automation::ShuttersControl::shutters; +my $ascDev = $FHEM::Automation::ShuttersControl::ascDev; + ## Import der FHEM Funktionen BEGIN { GP_Import( diff --git a/lib/FHEM/Automation/ShuttersControl/Shutters/Attr.pm b/lib/FHEM/Automation/ShuttersControl/Shutters/Attr.pm index d132347..a60a1f5 100644 --- a/lib/FHEM/Automation/ShuttersControl/Shutters/Attr.pm +++ b/lib/FHEM/Automation/ShuttersControl/Shutters/Attr.pm @@ -46,6 +46,9 @@ use utf8; use GPUtils qw(GP_Import); +my $shutters = $FHEM::Automation::ShuttersControl::shutters; +my %userAttrList = %FHEM::Automation::ShuttersControl::userAttrList; + ## Import der FHEM Funktionen BEGIN { GP_Import( @@ -67,10 +70,10 @@ sub _setAttributs { } sub _getPosition { - my $self = shift; + my $self = shift; - my $attr = shift; - my $userAttrList = shift; + my $attr = shift; + my $userAttrList = shift; return $self->{ $self->{shuttersDev} }->{$attr}->{position} if ( @@ -529,7 +532,7 @@ sub getAdv { return ( AttrVal( $self->{shuttersDev}, 'ASC_Adv', 'off' ) eq 'on' - ? ( FHEM::Automation::ShuttersControl::_IsAdv == 1 ? 1 : 0 ) + ? ( \&FHEM::Automation::ShuttersControl::_IsAdv == 1 ? 1 : 0 ) : 0 ); } diff --git a/lib/FHEM/Automation/ShuttersControl/Shutters/Readings.pm b/lib/FHEM/Automation/ShuttersControl/Shutters/Readings.pm index 00d7e16..8ce109e 100644 --- a/lib/FHEM/Automation/ShuttersControl/Shutters/Readings.pm +++ b/lib/FHEM/Automation/ShuttersControl/Shutters/Readings.pm @@ -47,6 +47,9 @@ use utf8; use GPUtils qw(GP_Import); +my $shutters = $FHEM::Automation::ShuttersControl::shutters; +my $ascDev = $FHEM::Automation::ShuttersControl::ascDev; + ## Import der FHEM Funktionen BEGIN { GP_Import( diff --git a/lib/FHEM/Automation/ShuttersControl/Window.pm b/lib/FHEM/Automation/ShuttersControl/Window.pm index 9b4caae..a927849 100644 --- a/lib/FHEM/Automation/ShuttersControl/Window.pm +++ b/lib/FHEM/Automation/ShuttersControl/Window.pm @@ -44,6 +44,9 @@ use strict; use warnings; use utf8; +use FHEM::Automation::ShuttersControl::Window::Attr; +use FHEM::Automation::ShuttersControl::Window::Readings; + our @ISA = qw(FHEM::Automation::ShuttersControl::Window::Attr FHEM::Automation::ShuttersControl::Window::Readings); diff --git a/lib/FHEM/Automation/ShuttersControl/Window/Attr.pm b/lib/FHEM/Automation/ShuttersControl/Window/Attr.pm index 9e08d62..c388748 100644 --- a/lib/FHEM/Automation/ShuttersControl/Window/Attr.pm +++ b/lib/FHEM/Automation/ShuttersControl/Window/Attr.pm @@ -46,6 +46,8 @@ use utf8; use GPUtils qw(GP_Import); +my $shutters = $FHEM::Automation::ShuttersControl::shutters; + ## Import der FHEM Funktionen BEGIN { GP_Import( diff --git a/lib/FHEM/Automation/ShuttersControl/Window/Readings.pm b/lib/FHEM/Automation/ShuttersControl/Window/Readings.pm index 5e8ff5f..5789314 100644 --- a/lib/FHEM/Automation/ShuttersControl/Window/Readings.pm +++ b/lib/FHEM/Automation/ShuttersControl/Window/Readings.pm @@ -46,6 +46,8 @@ use utf8; use GPUtils qw(GP_Import); +my $shutters = $FHEM::Automation::ShuttersControl::shutters; + ## Import der FHEM Funktionen BEGIN { GP_Import(