mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-03-10 03:06:37 +00:00
73_GardenaSmartBridge: try to use JSON::MaybeXS wrapper for chance of better performance + open code
git-svn-id: https://svn.fhem.de/fhem/trunk@19629 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
6abe964792
commit
13d4a450a3
@ -1,5 +1,7 @@
|
|||||||
# 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.
|
||||||
|
- bugfix: 73_GardenaSmartBridge: fix undefined value
|
||||||
|
as an ARRAY reference bug
|
||||||
- update: 59_Weather.pm: API Files try to use JSON::MaybeXS wrapper for chance
|
- update: 59_Weather.pm: API Files try to use JSON::MaybeXS wrapper for chance
|
||||||
of better performance + open code, more log entry
|
of better performance + open code, more log entry
|
||||||
- update: 98_Siro.pm: V1.3 fix perlwarnings
|
- update: 98_Siro.pm: V1.3 fix perlwarnings
|
||||||
|
@ -59,7 +59,7 @@ use strict;
|
|||||||
use warnings;
|
use warnings;
|
||||||
use FHEM::Meta;
|
use FHEM::Meta;
|
||||||
|
|
||||||
my $version = '1.6.5';
|
my $version = '1.6.6';
|
||||||
|
|
||||||
sub GardenaSmartBridge_Initialize($) {
|
sub GardenaSmartBridge_Initialize($) {
|
||||||
|
|
||||||
@ -112,9 +112,80 @@ use HttpUtils;
|
|||||||
|
|
||||||
eval "use Encode qw(encode encode_utf8 decode_utf8);1"
|
eval "use Encode qw(encode encode_utf8 decode_utf8);1"
|
||||||
or $missingModul .= "Encode ";
|
or $missingModul .= "Encode ";
|
||||||
eval "use JSON;1" or $missingModul .= 'JSON ';
|
# eval "use JSON;1" or $missingModul .= 'JSON ';
|
||||||
eval "use IO::Socket::SSL;1" or $missingModul .= 'IO::Socket::SSL ';
|
eval "use IO::Socket::SSL;1" or $missingModul .= 'IO::Socket::SSL ';
|
||||||
|
|
||||||
|
# try to use JSON::MaybeXS wrapper
|
||||||
|
# for chance of better performance + open code
|
||||||
|
eval {
|
||||||
|
require JSON::MaybeXS;
|
||||||
|
import JSON::MaybeXS qw( decode_json encode_json );
|
||||||
|
1;
|
||||||
|
};
|
||||||
|
|
||||||
|
if ($@) {
|
||||||
|
$@ = undef;
|
||||||
|
|
||||||
|
# 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'
|
||||||
|
unless ( defined( $ENV{PERL_JSON_BACKEND} ) );
|
||||||
|
|
||||||
|
require JSON;
|
||||||
|
import JSON qw( decode_json encode_json );
|
||||||
|
1;
|
||||||
|
};
|
||||||
|
|
||||||
|
if ($@) {
|
||||||
|
$@ = undef;
|
||||||
|
|
||||||
|
# In rare cases, Cpanel::JSON::XS may
|
||||||
|
# be installed but JSON|JSON::MaybeXS not ...
|
||||||
|
eval {
|
||||||
|
require Cpanel::JSON::XS;
|
||||||
|
import Cpanel::JSON::XS qw(decode_json encode_json);
|
||||||
|
1;
|
||||||
|
};
|
||||||
|
|
||||||
|
if ($@) {
|
||||||
|
$@ = undef;
|
||||||
|
|
||||||
|
# In rare cases, JSON::XS may
|
||||||
|
# be installed but JSON not ...
|
||||||
|
eval {
|
||||||
|
require JSON::XS;
|
||||||
|
import JSON::XS qw(decode_json encode_json);
|
||||||
|
1;
|
||||||
|
};
|
||||||
|
|
||||||
|
if ($@) {
|
||||||
|
$@ = undef;
|
||||||
|
|
||||||
|
# Fallback to built-in JSON which SHOULD
|
||||||
|
# be available since 5.014 ...
|
||||||
|
eval {
|
||||||
|
require JSON::PP;
|
||||||
|
import JSON::PP qw(decode_json encode_json);
|
||||||
|
1;
|
||||||
|
};
|
||||||
|
|
||||||
|
if ($@) {
|
||||||
|
$@ = undef;
|
||||||
|
|
||||||
|
# Fallback to JSON::backportPP in really rare cases
|
||||||
|
require JSON::backportPP;
|
||||||
|
import JSON::backportPP qw(decode_json encode_json);
|
||||||
|
1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
BEGIN {
|
BEGIN {
|
||||||
GP_Import(
|
GP_Import(
|
||||||
qw(readingsSingleUpdate
|
qw(readingsSingleUpdate
|
||||||
@ -753,7 +824,8 @@ sub WriteReadings($$) {
|
|||||||
scalar( @{ $decode_json->{zones} } ) );
|
scalar( @{ $decode_json->{zones} } ) );
|
||||||
}
|
}
|
||||||
elsif ( $decode_json->{id} ne $hash->{helper}{locations_id}
|
elsif ( $decode_json->{id} ne $hash->{helper}{locations_id}
|
||||||
and ref( $decode_json->{abilities} ) eq 'ARRAY' )
|
and ref( $decode_json->{abilities} ) eq 'ARRAY'
|
||||||
|
and ref( $decode_json->{abilities}[0]{properties} ) eq 'ARRAY' )
|
||||||
{
|
{
|
||||||
my $properties =
|
my $properties =
|
||||||
scalar( @{ $decode_json->{abilities}[0]{properties} } );
|
scalar( @{ $decode_json->{abilities}[0]{properties} } );
|
||||||
|
@ -59,7 +59,7 @@ use strict;
|
|||||||
use warnings;
|
use warnings;
|
||||||
use FHEM::Meta;
|
use FHEM::Meta;
|
||||||
|
|
||||||
my $version = "1.6.3";
|
my $version = '1.6.4';
|
||||||
|
|
||||||
sub GardenaSmartDevice_Initialize($) {
|
sub GardenaSmartDevice_Initialize($) {
|
||||||
|
|
||||||
@ -103,7 +103,78 @@ use FHEM::Meta;
|
|||||||
|
|
||||||
use Time::Local;
|
use Time::Local;
|
||||||
|
|
||||||
eval "use JSON;1" or $missingModul .= "JSON ";
|
# eval "use JSON;1" or $missingModul .= "JSON ";
|
||||||
|
|
||||||
|
# try to use JSON::MaybeXS wrapper
|
||||||
|
# for chance of better performance + open code
|
||||||
|
eval {
|
||||||
|
require JSON::MaybeXS;
|
||||||
|
import JSON::MaybeXS qw( decode_json encode_json );
|
||||||
|
1;
|
||||||
|
};
|
||||||
|
|
||||||
|
if ($@) {
|
||||||
|
$@ = undef;
|
||||||
|
|
||||||
|
# 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'
|
||||||
|
unless ( defined( $ENV{PERL_JSON_BACKEND} ) );
|
||||||
|
|
||||||
|
require JSON;
|
||||||
|
import JSON qw( decode_json encode_json );
|
||||||
|
1;
|
||||||
|
};
|
||||||
|
|
||||||
|
if ($@) {
|
||||||
|
$@ = undef;
|
||||||
|
|
||||||
|
# In rare cases, Cpanel::JSON::XS may
|
||||||
|
# be installed but JSON|JSON::MaybeXS not ...
|
||||||
|
eval {
|
||||||
|
require Cpanel::JSON::XS;
|
||||||
|
import Cpanel::JSON::XS qw(decode_json encode_json);
|
||||||
|
1;
|
||||||
|
};
|
||||||
|
|
||||||
|
if ($@) {
|
||||||
|
$@ = undef;
|
||||||
|
|
||||||
|
# In rare cases, JSON::XS may
|
||||||
|
# be installed but JSON not ...
|
||||||
|
eval {
|
||||||
|
require JSON::XS;
|
||||||
|
import JSON::XS qw(decode_json encode_json);
|
||||||
|
1;
|
||||||
|
};
|
||||||
|
|
||||||
|
if ($@) {
|
||||||
|
$@ = undef;
|
||||||
|
|
||||||
|
# Fallback to built-in JSON which SHOULD
|
||||||
|
# be available since 5.014 ...
|
||||||
|
eval {
|
||||||
|
require JSON::PP;
|
||||||
|
import JSON::PP qw(decode_json encode_json);
|
||||||
|
1;
|
||||||
|
};
|
||||||
|
|
||||||
|
if ($@) {
|
||||||
|
$@ = undef;
|
||||||
|
|
||||||
|
# Fallback to JSON::backportPP in really rare cases
|
||||||
|
require JSON::backportPP;
|
||||||
|
import JSON::backportPP qw(decode_json encode_json);
|
||||||
|
1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
## Import der FHEM Funktionen
|
## Import der FHEM Funktionen
|
||||||
BEGIN {
|
BEGIN {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user