mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-02-07 16:59:18 +00:00
SMUtils.pm: fix evaljson return
git-svn-id: https://svn.fhem.de/fhem/trunk@26939 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
fba07cd689
commit
77f19ce876
@ -3,7 +3,7 @@
|
|||||||
#########################################################################################################################
|
#########################################################################################################################
|
||||||
# SMUtils.pm
|
# SMUtils.pm
|
||||||
#
|
#
|
||||||
# (c) 2020-2022 by Heiko Maaz
|
# (c) 2020-2023 by Heiko Maaz
|
||||||
# e-mail: Heiko dot Maaz at t-online dot de
|
# e-mail: Heiko dot Maaz at t-online dot de
|
||||||
#
|
#
|
||||||
# This Module provides routines for FHEM modules developed for Synology use cases.
|
# This Module provides routines for FHEM modules developed for Synology use cases.
|
||||||
@ -26,6 +26,7 @@
|
|||||||
#########################################################################################################################
|
#########################################################################################################################
|
||||||
|
|
||||||
# Version History
|
# Version History
|
||||||
|
# 1.24.2 fix evaljson return
|
||||||
# 1.24.1 extend moduleVersion by useCTZ
|
# 1.24.1 extend moduleVersion by useCTZ
|
||||||
# 1.24.0 new sub encodeSpecChars
|
# 1.24.0 new sub encodeSpecChars
|
||||||
# 1.23.1 correct version format
|
# 1.23.1 correct version format
|
||||||
@ -52,7 +53,7 @@ use FHEM::SynoModules::ErrCodes qw(:all); # Erro
|
|||||||
use GPUtils qw( GP_Import GP_Export );
|
use GPUtils qw( GP_Import GP_Export );
|
||||||
use Carp qw(croak carp);
|
use Carp qw(croak carp);
|
||||||
|
|
||||||
use version 0.77; our $VERSION = version->declare('1.24.1');
|
use version 0.77; our $VERSION = version->declare('1.24.2');
|
||||||
|
|
||||||
use Exporter ('import');
|
use Exporter ('import');
|
||||||
our @EXPORT_OK = qw(
|
our @EXPORT_OK = qw(
|
||||||
@ -1137,9 +1138,9 @@ return ($err,$sc,$credstr);
|
|||||||
# Test ob JSON-String vorliegt
|
# Test ob JSON-String vorliegt
|
||||||
###############################################################################
|
###############################################################################
|
||||||
sub evaljson {
|
sub evaljson {
|
||||||
my $hash = shift // carp $carpnohash && return;
|
my $hash = shift // carp $carpnohash && return;
|
||||||
my $myjson = shift // carp "got no string for JSON test" && return;
|
my $myjson = shift // carp "got no string for JSON test" && return;
|
||||||
my $OpMode = $hash->{OPMODE};
|
my $OpMode = $hash->{OPMODE} // q{};
|
||||||
my $name = $hash->{NAME};
|
my $name = $hash->{NAME};
|
||||||
|
|
||||||
my $success = 1;
|
my $success = 1;
|
||||||
@ -1150,25 +1151,31 @@ sub evaljson {
|
|||||||
return ($success,$myjson);
|
return ($success,$myjson);
|
||||||
}
|
}
|
||||||
|
|
||||||
eval {decode_json($myjson)} or do {
|
eval {decode_json($myjson)
|
||||||
if( ($hash->{HELPER}{RUNVIEW} && $hash->{HELPER}{RUNVIEW} =~ m/^live_.*hls$/x) ||
|
}
|
||||||
$OpMode =~ m/^.*_hls$/x ) { # SSCam: HLS aktivate/deaktivate bringt kein JSON wenn bereits aktiviert/deaktiviert
|
or do {
|
||||||
Log3($name, 5, "$name - HLS-activation data return: $myjson");
|
if( ($hash->{HELPER}{RUNVIEW} && $hash->{HELPER}{RUNVIEW} =~ m/^live_.*hls$/x) ||
|
||||||
|
$OpMode =~ m/^.*_hls$/x ) { # SSCam: HLS aktivate/deaktivate bringt kein JSON wenn bereits aktiviert/deaktiviert
|
||||||
if ($myjson =~ m/{"success":true}/x) {
|
Log3 ($name, 5, "$name - HLS-activation data return: $myjson");
|
||||||
$success = 1;
|
|
||||||
$myjson = '{"success":true}';
|
if ($myjson =~ m/{"success":true}/x) {
|
||||||
|
$success = 1;
|
||||||
|
$myjson = '{"success":true}';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$success = 0;
|
||||||
|
my $errorcode = "9000";
|
||||||
|
my $error = expErrors($hash, $errorcode); # Fehlertext zum Errorcode ermitteln
|
||||||
|
|
||||||
|
if($error) {
|
||||||
|
setReadingErrorState ($hash, $error, $errorcode);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
Log3 ($name, 1, "$name - ERROR while decode JSON: ".(split ' at', $@)[0]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
else {
|
|
||||||
$success = 0;
|
|
||||||
|
|
||||||
my $errorcode = "9000";
|
|
||||||
my $error = expErrors($hash,$errorcode); # Fehlertext zum Errorcode ermitteln
|
|
||||||
|
|
||||||
setReadingErrorState ($hash, $error, $errorcode);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
return ($success,$myjson);
|
return ($success,$myjson);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user