change code for versionflowset variable

This commit is contained in:
Marko Oldenburg 2019-06-20 11:22:10 +02:00
parent 9c0037d5db
commit abff40a4ec
2 changed files with 11 additions and 38 deletions

View File

@ -64,12 +64,10 @@ 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 GP_Export);
use HttpUtils; use HttpUtils;
use TcpServerUtils; use TcpServerUtils;
my $flowsetversion = '4.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 ';
@ -176,22 +174,10 @@ 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 to main context with different name
_Export( GP_Export(
qw( qw(
Initialize Initialize
Flowsetversion
) )
); );
@ -249,7 +235,7 @@ sub Define($$) {
$hash->{BRIDGE} = 1; $hash->{BRIDGE} = 1;
$hash->{PORT} = $port; $hash->{PORT} = $port;
$hash->{VERSION} = version->parse($VERSION)->normal; $hash->{VERSION} = version->parse($VERSION)->normal;
$hash->{VERSIONFLOWSET} = $flowsetversion; $hash->{VERSIONFLOWSET} = FHEM::Meta::Get( $hash, 'x_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' );
@ -906,7 +892,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_$hash->{VERSIONFLOWSET}.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",
@ -920,7 +906,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_$hash->{VERSIONFLOWSET}.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",
@ -1286,10 +1272,6 @@ sub ParseMsg($$) {
return ( $msg, $tail ); return ( $msg, $tail );
} }
sub Flowsetversion() {
return $flowsetversion;
}
##### bleibt zu Anschauungszwecken erhalten ##### bleibt zu Anschauungszwecken erhalten
#sub Header2Hash($) { #sub Header2Hash($) {
# #
@ -1479,6 +1461,7 @@ sub Flowsetversion() {
"release_status": "stable", "release_status": "stable",
"license": "GPL_2", "license": "GPL_2",
"version": "v4.4.2", "version": "v4.4.2",
"x_flowsetversion": "4.1.1",
"author": [ "author": [
"Marko Oldenburg <leongaultier@gmail.com>" "Marko Oldenburg <leongaultier@gmail.com>"
], ],

View File

@ -52,9 +52,9 @@ use warnings;
use POSIX; 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 GP_Export);
require FHEM::73_AMADCommBridge; require '73_AMADCommBridge.pm';
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 ';
@ -165,19 +165,8 @@ 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 to main context with different name
_Export( GP_Export(
qw( qw(
Initialize Initialize
) )
@ -254,7 +243,6 @@ sub Define($$) {
$hash->{HOST} = $host; $hash->{HOST} = $host;
$hash->{AMAD_ID} = $amad_id; $hash->{AMAD_ID} = $amad_id;
$hash->{VERSION} = version->parse($VERSION)->normal; $hash->{VERSION} = version->parse($VERSION)->normal;
$hash->{VERSIONFLOWSET} = AMADCommBridge_Flowsetversion();
$hash->{NOTIFYDEV} = 'global,' . $name; $hash->{NOTIFYDEV} = 'global,' . $name;
$hash->{MODEL} = $remoteServer; $hash->{MODEL} = $remoteServer;
@ -288,6 +276,8 @@ sub Define($$) {
} }
$iodev = $hash->{IODev}->{NAME}; $iodev = $hash->{IODev}->{NAME};
# $hash->{VERSIONFLOWSET} = FHEM::Meta::Get( $defs{$iodev}, 'x_flowsetversion' );
$hash->{VERSIONFLOWSET} = $defs{$iodev}->{VERSIONFLOWSET};
my $d = $modules{AMADDevice}{defptr}{$amad_id}; my $d = $modules{AMADDevice}{defptr}{$amad_id};