add LICENS and change package code
This commit is contained in:
		@@ -58,65 +58,20 @@
 | 
			
		||||
##
 | 
			
		||||
##
 | 
			
		||||
 | 
			
		||||
package main;
 | 
			
		||||
 | 
			
		||||
use strict;
 | 
			
		||||
use warnings;
 | 
			
		||||
use FHEM::Meta;
 | 
			
		||||
 | 
			
		||||
my $modulversion   = '4.4.2';
 | 
			
		||||
my $flowsetversion = '4.4.1';
 | 
			
		||||
 | 
			
		||||
sub AMADCommBridge_Initialize($) {
 | 
			
		||||
 | 
			
		||||
    my ($hash) = @_;
 | 
			
		||||
 | 
			
		||||
    # Provider
 | 
			
		||||
    $hash->{ReadFn}    = 'FHEM::AMADCommBridge::Read';
 | 
			
		||||
    $hash->{WriteFn}   = 'FHEM::AMADCommBridge::Write';
 | 
			
		||||
    $hash->{Clients}   = ':AMADDevice:';
 | 
			
		||||
    $hash->{MatchList} = { "1:AMADDevice" => '{"amad": \{"amad_id":.+}}' };
 | 
			
		||||
 | 
			
		||||
    # Consumer
 | 
			
		||||
    $hash->{SetFn}   = 'FHEM::AMADCommBridge::Set';
 | 
			
		||||
    $hash->{DefFn}   = 'FHEM::AMADCommBridge::Define';
 | 
			
		||||
    $hash->{UndefFn} = 'FHEM::AMADCommBridge::Undef';
 | 
			
		||||
 | 
			
		||||
    $hash->{AttrFn} = 'FHEM::AMADCommBridge::Attr';
 | 
			
		||||
    $hash->{AttrList} =
 | 
			
		||||
        'fhemControlMode:trigger,setControl,thirdPartControl '
 | 
			
		||||
      . 'debugJSON:0,1 '
 | 
			
		||||
      . 'enableSubCalls:0,1 '
 | 
			
		||||
      . 'disable:1 '
 | 
			
		||||
      . 'allowfrom '
 | 
			
		||||
      . 'fhemServerIP '
 | 
			
		||||
      . $readingFnAttributes;
 | 
			
		||||
 | 
			
		||||
    foreach my $d ( sort keys %{ $modules{AMADCommBridge}{defptr} } ) {
 | 
			
		||||
 | 
			
		||||
        my $hash = $modules{AMADCommBridge}{defptr}{$d};
 | 
			
		||||
        $hash->{VERSIONMODUL}   = $modulversion;
 | 
			
		||||
        $hash->{VERSIONFLOWSET} = $flowsetversion;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    return FHEM::Meta::InitMod( __FILE__, $hash );
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
package FHEM::AMADCommBridge;
 | 
			
		||||
 | 
			
		||||
use strict;
 | 
			
		||||
use warnings;
 | 
			
		||||
use POSIX;
 | 
			
		||||
use FHEM::Meta;
 | 
			
		||||
 | 
			
		||||
use GPUtils qw(GP_Import)
 | 
			
		||||
  ;    # wird für den Import der FHEM Funktionen aus der fhem.pl benötigt
 | 
			
		||||
 | 
			
		||||
my $missingModul = '';
 | 
			
		||||
 | 
			
		||||
use HttpUtils;
 | 
			
		||||
use TcpServerUtils;
 | 
			
		||||
our $MODULVERSION   = 'v4.4.2';
 | 
			
		||||
our $FLOWSETVERSION = 'v4.4.1';
 | 
			
		||||
 | 
			
		||||
my $missingModul = '';
 | 
			
		||||
eval "use Encode qw(encode encode_utf8);1" or $missingModul .= 'Encode ';
 | 
			
		||||
 | 
			
		||||
# try to use JSON::MaybeXS wrapper
 | 
			
		||||
@@ -188,9 +143,13 @@ if ($@) {
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
## Import der FHEM Funktionen
 | 
			
		||||
#-- Run before package compilation
 | 
			
		||||
BEGIN {
 | 
			
		||||
 | 
			
		||||
    # Import from main context
 | 
			
		||||
    GP_Import(
 | 
			
		||||
        qw(readingsSingleUpdate
 | 
			
		||||
          readingsBulkUpdate
 | 
			
		||||
@@ -202,6 +161,7 @@ BEGIN {
 | 
			
		||||
          CommandAttr
 | 
			
		||||
          CommandDelete
 | 
			
		||||
          CommandSet
 | 
			
		||||
          readingFnAttributes
 | 
			
		||||
          attr
 | 
			
		||||
          AttrVal
 | 
			
		||||
          ReadingsVal
 | 
			
		||||
@@ -217,6 +177,59 @@ BEGIN {
 | 
			
		||||
    );
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
# _Export - Export references to main context using a different naming schema
 | 
			
		||||
sub _Export {
 | 
			
		||||
    no strict qw/refs/;    ## no critic
 | 
			
		||||
    my $pkg  = caller(0);
 | 
			
		||||
    my $main = $pkg;
 | 
			
		||||
    $main =~ s/^(?:.+::)?([^:]+)$/main::$1\_/g;
 | 
			
		||||
    foreach (@_) {
 | 
			
		||||
        *{ $main . $_ } = *{ $pkg . '::' . $_ };
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
#-- Export to main context with different name
 | 
			
		||||
_Export(
 | 
			
		||||
    qw(
 | 
			
		||||
      Initialize
 | 
			
		||||
      )
 | 
			
		||||
);
 | 
			
		||||
 | 
			
		||||
sub Initialize($) {
 | 
			
		||||
 | 
			
		||||
    my ($hash) = @_;
 | 
			
		||||
 | 
			
		||||
    # Provider
 | 
			
		||||
    $hash->{ReadFn}    = 'FHEM::AMADCommBridge::Read';
 | 
			
		||||
    $hash->{WriteFn}   = 'FHEM::AMADCommBridge::Write';
 | 
			
		||||
    $hash->{Clients}   = ':AMADDevice:';
 | 
			
		||||
    $hash->{MatchList} = { "1:AMADDevice" => '{"amad": \{"amad_id":.+}}' };
 | 
			
		||||
 | 
			
		||||
    # Consumer
 | 
			
		||||
    $hash->{SetFn}   = 'FHEM::AMADCommBridge::Set';
 | 
			
		||||
    $hash->{DefFn}   = 'FHEM::AMADCommBridge::Define';
 | 
			
		||||
    $hash->{UndefFn} = 'FHEM::AMADCommBridge::Undef';
 | 
			
		||||
 | 
			
		||||
    $hash->{AttrFn} = 'FHEM::AMADCommBridge::Attr';
 | 
			
		||||
    $hash->{AttrList} =
 | 
			
		||||
        'fhemControlMode:trigger,setControl,thirdPartControl '
 | 
			
		||||
      . 'debugJSON:0,1 '
 | 
			
		||||
      . 'enableSubCalls:0,1 '
 | 
			
		||||
      . 'disable:1 '
 | 
			
		||||
      . 'allowfrom '
 | 
			
		||||
      . 'fhemServerIP '
 | 
			
		||||
      . $readingFnAttributes;
 | 
			
		||||
 | 
			
		||||
    foreach my $d ( sort keys %{ $modules{AMADCommBridge}{defptr} } ) {
 | 
			
		||||
 | 
			
		||||
        my $hash = $modules{AMADCommBridge}{defptr}{$d};
 | 
			
		||||
        $hash->{VERSIONMODUL}   = $modulversion;
 | 
			
		||||
        $hash->{VERSIONFLOWSET} = $flowsetversion;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    return FHEM::Meta::InitMod( __FILE__, $hash );
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
sub Define($$) {
 | 
			
		||||
 | 
			
		||||
    my ( $hash, $def ) = @_;
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										146
									
								
								74_AMADDevice.pm
									
									
									
									
									
								
							
							
						
						
									
										146
									
								
								74_AMADDevice.pm
									
									
									
									
									
								
							@@ -44,68 +44,6 @@
 | 
			
		||||
#
 | 
			
		||||
#
 | 
			
		||||
 | 
			
		||||
package main;
 | 
			
		||||
 | 
			
		||||
use strict;
 | 
			
		||||
use warnings;
 | 
			
		||||
use FHEM::Meta;
 | 
			
		||||
 | 
			
		||||
my $modulversion   = '4.4.2';
 | 
			
		||||
my $flowsetversion = '4.4.1';
 | 
			
		||||
 | 
			
		||||
sub AMADDevice_Initialize($) {
 | 
			
		||||
 | 
			
		||||
    my ($hash) = @_;
 | 
			
		||||
 | 
			
		||||
    $hash->{Match} = '{"amad": \{"amad_id":.+}}';
 | 
			
		||||
 | 
			
		||||
    $hash->{SetFn}    = 'FHEM::AMADDevice::Set';
 | 
			
		||||
    $hash->{DefFn}    = 'FHEM::AMADDevice::Define';
 | 
			
		||||
    $hash->{UndefFn}  = 'FHEM::AMADDevice::Undef';
 | 
			
		||||
    $hash->{AttrFn}   = 'FHEM::AMADDevice::Attr';
 | 
			
		||||
    $hash->{NotifyFn} = 'FHEM::AMADDevice::Notify';
 | 
			
		||||
    $hash->{ParseFn}  = 'FHEM::AMADDevice::Parse';
 | 
			
		||||
 | 
			
		||||
    $hash->{AttrList} =
 | 
			
		||||
        'setOpenApp '
 | 
			
		||||
      . 'checkActiveTask '
 | 
			
		||||
      . 'setFullscreen:0,1 '
 | 
			
		||||
      . 'setScreenOrientation:0,1 '
 | 
			
		||||
      . 'setScreenBrightness:noArg '
 | 
			
		||||
      . 'setBluetoothDevice '
 | 
			
		||||
      . 'setScreenlockPIN '
 | 
			
		||||
      . 'setScreenOnForTimer '
 | 
			
		||||
      . 'setOpenUrlBrowser '
 | 
			
		||||
      . 'setNotifySndFilePath '
 | 
			
		||||
      . 'setTtsMsgSpeed '
 | 
			
		||||
      . 'setTtsMsgLang:de,en '
 | 
			
		||||
      . 'setTtsMsgVol '
 | 
			
		||||
      . 'setUserFlowState '
 | 
			
		||||
      . 'setVolUpDownStep:1,2,4,5 '
 | 
			
		||||
      . 'setVolMax '
 | 
			
		||||
      . 'setVolFactor:2,3,4,5 '
 | 
			
		||||
      . 'setNotifyVolMax '
 | 
			
		||||
      . 'setRingSoundVolMax '
 | 
			
		||||
      . 'setAPSSID '
 | 
			
		||||
      . 'root:0,1 '
 | 
			
		||||
      . 'disable:1 '
 | 
			
		||||
      . 'IODev '
 | 
			
		||||
      . 'remoteServer:Automagic,Autoremote,TNES,other '
 | 
			
		||||
      . 'setTakeScreenshotResolution:1280x720,1920x1080,1920x1200 '
 | 
			
		||||
      . 'setTakePictureResolution:800x600,1024x768,1280x720,1600x1200,1920x1080 '
 | 
			
		||||
      . 'setTakePictureCamera:Back,Front '
 | 
			
		||||
      . $readingFnAttributes;
 | 
			
		||||
 | 
			
		||||
    foreach my $d ( sort keys %{ $modules{AMADDevice}{defptr} } ) {
 | 
			
		||||
 | 
			
		||||
        my $hash = $modules{AMADDevice}{defptr}{$d};
 | 
			
		||||
        $hash->{VERSIONMODUL}   = $modulversion;
 | 
			
		||||
        $hash->{VERSIONFLOWSET} = $flowsetversion;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    return FHEM::Meta::InitMod( __FILE__, $hash );
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
## unserer packagename
 | 
			
		||||
package FHEM::AMADDevice;
 | 
			
		||||
 | 
			
		||||
@@ -115,12 +53,12 @@ use POSIX;
 | 
			
		||||
use FHEM::Meta;
 | 
			
		||||
 | 
			
		||||
use Data::Dumper;    #only for Debugging
 | 
			
		||||
 | 
			
		||||
use GPUtils qw(GP_Import)
 | 
			
		||||
  ;    # wird für den Import der FHEM Funktionen aus der fhem.pl benötigt
 | 
			
		||||
our $MODULVERSION   = 'v4.4.2';
 | 
			
		||||
our $FLOWSETVERSION = 'v4.4.1';
 | 
			
		||||
 | 
			
		||||
my $missingModul = '';
 | 
			
		||||
 | 
			
		||||
eval "use Encode qw(encode encode_utf8);1" or $missingModul .= 'Encode ';
 | 
			
		||||
 | 
			
		||||
# try to use JSON::MaybeXS wrapper
 | 
			
		||||
@@ -192,9 +130,13 @@ if ($@) {
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
## Import der FHEM Funktionen
 | 
			
		||||
#-- Run before package compilation
 | 
			
		||||
BEGIN {
 | 
			
		||||
 | 
			
		||||
    # Import from main context
 | 
			
		||||
    GP_Import(
 | 
			
		||||
        qw(readingsSingleUpdate
 | 
			
		||||
          readingsBulkUpdate
 | 
			
		||||
@@ -204,6 +146,7 @@ BEGIN {
 | 
			
		||||
          CommandDeleteReading
 | 
			
		||||
          defs
 | 
			
		||||
          modules
 | 
			
		||||
          readingFnAttributes
 | 
			
		||||
          Log3
 | 
			
		||||
          CommandAttr
 | 
			
		||||
          attr
 | 
			
		||||
@@ -223,6 +166,77 @@ BEGIN {
 | 
			
		||||
    );
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
# _Export - Export references to main context using a different naming schema
 | 
			
		||||
sub _Export {
 | 
			
		||||
    no strict qw/refs/;    ## no critic
 | 
			
		||||
    my $pkg  = caller(0);
 | 
			
		||||
    my $main = $pkg;
 | 
			
		||||
    $main =~ s/^(?:.+::)?([^:]+)$/main::$1\_/g;
 | 
			
		||||
    foreach (@_) {
 | 
			
		||||
        *{ $main . $_ } = *{ $pkg . '::' . $_ };
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
#-- Export to main context with different name
 | 
			
		||||
_Export(
 | 
			
		||||
    qw(
 | 
			
		||||
      Initialize
 | 
			
		||||
      )
 | 
			
		||||
);
 | 
			
		||||
 | 
			
		||||
sub Initialize($) {
 | 
			
		||||
 | 
			
		||||
    my ($hash) = @_;
 | 
			
		||||
 | 
			
		||||
    $hash->{Match} = '{"amad": \{"amad_id":.+}}';
 | 
			
		||||
 | 
			
		||||
    $hash->{SetFn}    = 'FHEM::AMADDevice::Set';
 | 
			
		||||
    $hash->{DefFn}    = 'FHEM::AMADDevice::Define';
 | 
			
		||||
    $hash->{UndefFn}  = 'FHEM::AMADDevice::Undef';
 | 
			
		||||
    $hash->{AttrFn}   = 'FHEM::AMADDevice::Attr';
 | 
			
		||||
    $hash->{NotifyFn} = 'FHEM::AMADDevice::Notify';
 | 
			
		||||
    $hash->{ParseFn}  = 'FHEM::AMADDevice::Parse';
 | 
			
		||||
 | 
			
		||||
    $hash->{AttrList} =
 | 
			
		||||
        'setOpenApp '
 | 
			
		||||
      . 'checkActiveTask '
 | 
			
		||||
      . 'setFullscreen:0,1 '
 | 
			
		||||
      . 'setScreenOrientation:0,1 '
 | 
			
		||||
      . 'setScreenBrightness:noArg '
 | 
			
		||||
      . 'setBluetoothDevice '
 | 
			
		||||
      . 'setScreenlockPIN '
 | 
			
		||||
      . 'setScreenOnForTimer '
 | 
			
		||||
      . 'setOpenUrlBrowser '
 | 
			
		||||
      . 'setNotifySndFilePath '
 | 
			
		||||
      . 'setTtsMsgSpeed '
 | 
			
		||||
      . 'setTtsMsgLang:de,en '
 | 
			
		||||
      . 'setTtsMsgVol '
 | 
			
		||||
      . 'setUserFlowState '
 | 
			
		||||
      . 'setVolUpDownStep:1,2,4,5 '
 | 
			
		||||
      . 'setVolMax '
 | 
			
		||||
      . 'setVolFactor:2,3,4,5 '
 | 
			
		||||
      . 'setNotifyVolMax '
 | 
			
		||||
      . 'setRingSoundVolMax '
 | 
			
		||||
      . 'setAPSSID '
 | 
			
		||||
      . 'root:0,1 '
 | 
			
		||||
      . 'disable:1 '
 | 
			
		||||
      . 'IODev '
 | 
			
		||||
      . 'remoteServer:Automagic,Autoremote,TNES,other '
 | 
			
		||||
      . 'setTakeScreenshotResolution:1280x720,1920x1080,1920x1200 '
 | 
			
		||||
      . 'setTakePictureResolution:800x600,1024x768,1280x720,1600x1200,1920x1080 '
 | 
			
		||||
      . 'setTakePictureCamera:Back,Front '
 | 
			
		||||
      . $readingFnAttributes;
 | 
			
		||||
 | 
			
		||||
    foreach my $d ( sort keys %{ $modules{AMADDevice}{defptr} } ) {
 | 
			
		||||
 | 
			
		||||
        my $hash = $modules{AMADDevice}{defptr}{$d};
 | 
			
		||||
        $hash->{VERSIONMODUL}   = $MODULVERSION;
 | 
			
		||||
        $hash->{VERSIONFLOWSET} = $FLOWSETVERSION;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    return FHEM::Meta::InitMod( __FILE__, $hash );
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
sub Define($$) {
 | 
			
		||||
 | 
			
		||||
    my ( $hash, $def ) = @_;
 | 
			
		||||
@@ -245,8 +259,8 @@ sub Define($$) {
 | 
			
		||||
 | 
			
		||||
    $hash->{HOST}           = $host;
 | 
			
		||||
    $hash->{AMAD_ID}        = $amad_id;
 | 
			
		||||
    $hash->{VERSIONMODUL}   = $modulversion;
 | 
			
		||||
    $hash->{VERSIONFLOWSET} = $flowsetversion;
 | 
			
		||||
    $hash->{VERSIONMODUL}   = $MODULVERSION;
 | 
			
		||||
    $hash->{VERSIONFLOWSET} = $FLOWSETVERSION;
 | 
			
		||||
    $hash->{NOTIFYDEV}      = 'global,' . $name;
 | 
			
		||||
    $hash->{MODEL}          = $remoteServer;
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user