diff --git a/fhem/lib/FHEM/SynoModules/SMUtils.pm b/fhem/lib/FHEM/SynoModules/SMUtils.pm index bf08ac078..7a6a8482d 100644 --- a/fhem/lib/FHEM/SynoModules/SMUtils.pm +++ b/fhem/lib/FHEM/SynoModules/SMUtils.pm @@ -3,7 +3,7 @@ ######################################################################################################################### # SMUtils.pm # -# (c) 2020-2022 by Heiko Maaz +# (c) 2020-2023 by Heiko Maaz # e-mail: Heiko dot Maaz at t-online dot de # # This Module provides routines for FHEM modules developed for Synology use cases. @@ -26,6 +26,7 @@ ######################################################################################################################### # Version History +# 1.24.2 fix evaljson return # 1.24.1 extend moduleVersion by useCTZ # 1.24.0 new sub encodeSpecChars # 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 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'); our @EXPORT_OK = qw( @@ -1137,9 +1138,9 @@ return ($err,$sc,$credstr); # Test ob JSON-String vorliegt ############################################################################### sub evaljson { - my $hash = shift // carp $carpnohash && return; - my $myjson = shift // carp "got no string for JSON test" && return; - my $OpMode = $hash->{OPMODE}; + my $hash = shift // carp $carpnohash && return; + my $myjson = shift // carp "got no string for JSON test" && return; + my $OpMode = $hash->{OPMODE} // q{}; my $name = $hash->{NAME}; my $success = 1; @@ -1150,25 +1151,31 @@ sub evaljson { return ($success,$myjson); } - eval {decode_json($myjson)} or do { - 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 - Log3($name, 5, "$name - HLS-activation data return: $myjson"); - - if ($myjson =~ m/{"success":true}/x) { - $success = 1; - $myjson = '{"success":true}'; + eval {decode_json($myjson) + } + or do { + 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 + Log3 ($name, 5, "$name - HLS-activation data return: $myjson"); + + 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); }