mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-03-03 16:56:54 +00:00
73_AMADCommBridge: change package code
git-svn-id: https://svn.fhem.de/fhem/trunk@19640 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
da6ca11533
commit
80c6225365
@ -1,5 +1,6 @@
|
|||||||
# Add changes at the top of the list. Keep it in ASCII, and 80-char wide.
|
# 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.
|
# Do not insert empty lines here, update check depends on it.
|
||||||
|
- feature: 73_AMADCommBridge: change package code
|
||||||
- feature: 42_AptToDate: change every package code
|
- feature: 42_AptToDate: change every package code
|
||||||
- feature: 73_AutoShuttersControl: change every package code
|
- feature: 73_AutoShuttersControl: change every package code
|
||||||
- feature: 73_AMADCommBridge: try to use JSON::MaybeXS wrapper for chance of
|
- feature: 73_AMADCommBridge: try to use JSON::MaybeXS wrapper for chance of
|
||||||
|
@ -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;
|
package FHEM::AMADCommBridge;
|
||||||
|
|
||||||
use strict;
|
use strict;
|
||||||
use warnings;
|
use warnings;
|
||||||
use POSIX;
|
use POSIX;
|
||||||
use FHEM::Meta;
|
use FHEM::Meta;
|
||||||
|
|
||||||
use GPUtils qw(GP_Import)
|
use GPUtils qw(GP_Import)
|
||||||
; # wird für den Import der FHEM Funktionen aus der fhem.pl benötigt
|
; # wird für den Import der FHEM Funktionen aus der fhem.pl benötigt
|
||||||
|
|
||||||
my $missingModul = '';
|
|
||||||
|
|
||||||
use HttpUtils;
|
use HttpUtils;
|
||||||
use TcpServerUtils;
|
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 ';
|
eval "use Encode qw(encode encode_utf8);1" or $missingModul .= 'Encode ';
|
||||||
|
|
||||||
# try to use JSON::MaybeXS wrapper
|
# try to use JSON::MaybeXS wrapper
|
||||||
@ -188,9 +143,13 @@ if ($@) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
## Import der FHEM Funktionen
|
## Import der FHEM Funktionen
|
||||||
|
#-- Run before package compilation
|
||||||
BEGIN {
|
BEGIN {
|
||||||
|
|
||||||
|
# Import from main context
|
||||||
GP_Import(
|
GP_Import(
|
||||||
qw(readingsSingleUpdate
|
qw(readingsSingleUpdate
|
||||||
readingsBulkUpdate
|
readingsBulkUpdate
|
||||||
@ -202,6 +161,7 @@ BEGIN {
|
|||||||
CommandAttr
|
CommandAttr
|
||||||
CommandDelete
|
CommandDelete
|
||||||
CommandSet
|
CommandSet
|
||||||
|
readingFnAttributes
|
||||||
attr
|
attr
|
||||||
AttrVal
|
AttrVal
|
||||||
ReadingsVal
|
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($$) {
|
sub Define($$) {
|
||||||
|
|
||||||
my ( $hash, $def ) = @_;
|
my ( $hash, $def ) = @_;
|
||||||
@ -240,8 +253,8 @@ sub Define($$) {
|
|||||||
|
|
||||||
$hash->{BRIDGE} = 1;
|
$hash->{BRIDGE} = 1;
|
||||||
$hash->{PORT} = $port;
|
$hash->{PORT} = $port;
|
||||||
$hash->{VERSIONMODUL} = $modulversion;
|
$hash->{VERSIONMODUL} = $MODULVERSION;
|
||||||
$hash->{VERSIONFLOWSET} = $flowsetversion;
|
$hash->{VERSIONFLOWSET} = $FLOWSETVERSION;
|
||||||
|
|
||||||
CommandAttr( undef, $name . ' room AMAD' )
|
CommandAttr( undef, $name . ' room AMAD' )
|
||||||
if ( AttrVal( $name, 'room', 'none' ) eq 'none' );
|
if ( AttrVal( $name, 'room', 'none' ) eq 'none' );
|
||||||
@ -898,7 +911,7 @@ sub ProcessRead($$) {
|
|||||||
if ( $data =~ /currentFlowsetUpdate.xml/ ) {
|
if ( $data =~ /currentFlowsetUpdate.xml/ ) {
|
||||||
|
|
||||||
$response =
|
$response =
|
||||||
qx(cat $fhempath/FHEM/lib/74_AMADautomagicFlowset_$flowsetversion.xml);
|
qx(cat $fhempath/FHEM/lib/74_AMADautomagicFlowset_$FLOWSETVERSION.xml);
|
||||||
$c = $hash->{CD};
|
$c = $hash->{CD};
|
||||||
print $c "HTTP/1.1 200 OK\r\n",
|
print $c "HTTP/1.1 200 OK\r\n",
|
||||||
"Content-Type: text/plain\r\n",
|
"Content-Type: text/plain\r\n",
|
||||||
@ -912,7 +925,7 @@ qx(cat $fhempath/FHEM/lib/74_AMADautomagicFlowset_$flowsetversion.xml);
|
|||||||
elsif ( $data =~ /currentTaskersetUpdate.prj.xml/ ) {
|
elsif ( $data =~ /currentTaskersetUpdate.prj.xml/ ) {
|
||||||
|
|
||||||
$response =
|
$response =
|
||||||
qx(cat $fhempath/FHEM/lib/74_AMADtaskerset_$flowsetversion.prj.xml);
|
qx(cat $fhempath/FHEM/lib/74_AMADtaskerset_$FLOWSETVERSION.prj.xml);
|
||||||
$c = $hash->{CD};
|
$c = $hash->{CD};
|
||||||
print $c "HTTP/1.1 200 OK\r\n",
|
print $c "HTTP/1.1 200 OK\r\n",
|
||||||
"Content-Type: text/plain\r\n",
|
"Content-Type: text/plain\r\n",
|
||||||
|
@ -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
|
## unserer packagename
|
||||||
package FHEM::AMADDevice;
|
package FHEM::AMADDevice;
|
||||||
|
|
||||||
@ -115,12 +53,12 @@ use POSIX;
|
|||||||
use FHEM::Meta;
|
use FHEM::Meta;
|
||||||
|
|
||||||
use Data::Dumper; #only for Debugging
|
use Data::Dumper; #only for Debugging
|
||||||
|
|
||||||
use GPUtils qw(GP_Import)
|
use GPUtils qw(GP_Import)
|
||||||
; # wird für den Import der FHEM Funktionen aus der fhem.pl benötigt
|
; # 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 = '';
|
my $missingModul = '';
|
||||||
|
|
||||||
eval "use Encode qw(encode encode_utf8);1" or $missingModul .= 'Encode ';
|
eval "use Encode qw(encode encode_utf8);1" or $missingModul .= 'Encode ';
|
||||||
|
|
||||||
# try to use JSON::MaybeXS wrapper
|
# try to use JSON::MaybeXS wrapper
|
||||||
@ -192,9 +130,13 @@ if ($@) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
## Import der FHEM Funktionen
|
## Import der FHEM Funktionen
|
||||||
|
#-- Run before package compilation
|
||||||
BEGIN {
|
BEGIN {
|
||||||
|
|
||||||
|
# Import from main context
|
||||||
GP_Import(
|
GP_Import(
|
||||||
qw(readingsSingleUpdate
|
qw(readingsSingleUpdate
|
||||||
readingsBulkUpdate
|
readingsBulkUpdate
|
||||||
@ -204,6 +146,7 @@ BEGIN {
|
|||||||
CommandDeleteReading
|
CommandDeleteReading
|
||||||
defs
|
defs
|
||||||
modules
|
modules
|
||||||
|
readingFnAttributes
|
||||||
Log3
|
Log3
|
||||||
CommandAttr
|
CommandAttr
|
||||||
attr
|
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($$) {
|
sub Define($$) {
|
||||||
|
|
||||||
my ( $hash, $def ) = @_;
|
my ( $hash, $def ) = @_;
|
||||||
@ -245,8 +259,8 @@ sub Define($$) {
|
|||||||
|
|
||||||
$hash->{HOST} = $host;
|
$hash->{HOST} = $host;
|
||||||
$hash->{AMAD_ID} = $amad_id;
|
$hash->{AMAD_ID} = $amad_id;
|
||||||
$hash->{VERSIONMODUL} = $modulversion;
|
$hash->{VERSIONMODUL} = $MODULVERSION;
|
||||||
$hash->{VERSIONFLOWSET} = $flowsetversion;
|
$hash->{VERSIONFLOWSET} = $FLOWSETVERSION;
|
||||||
$hash->{NOTIFYDEV} = 'global,' . $name;
|
$hash->{NOTIFYDEV} = 'global,' . $name;
|
||||||
$hash->{MODEL} = $remoteServer;
|
$hash->{MODEL} = $remoteServer;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user