2
0
mirror of https://github.com/fhem/fhem-mirror.git synced 2025-01-31 12:49:34 +00:00

21_HEOS: fix play_previous, change decode_json in a eval

git-svn-id: https://svn.fhem.de/fhem/trunk@16288 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
LeonGaultier 2018-02-28 09:11:34 +00:00
parent 41dc11f7f0
commit 6d8ff8f444
4 changed files with 29 additions and 9 deletions

View File

@ -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.
- bugfix: 21_HEOS: decode_json() in a eval, fix play_previous
- bugfix: 73_NUKIBridge/74_NUKIDevice: decode_json() in a eval - bugfix: 73_NUKIBridge/74_NUKIDevice: decode_json() in a eval
- Update: 73_AMADCommBridge/74AMADDevice: 4.2 new Version with Tasker Support - Update: 73_AMADCommBridge/74AMADDevice: 4.2 new Version with Tasker Support
- bugfix: 14_CUL_TCM97001: Fix temperature reading - bugfix: 14_CUL_TCM97001: Fix temperature reading

View File

@ -38,7 +38,7 @@ use JSON qw(decode_json);
use Encode qw(encode_utf8); use Encode qw(encode_utf8);
my $version = "1.0.0"; my $version = "1.0.3";
@ -434,7 +434,12 @@ sub HEOSGroup_Parse($$) {
my $code; my $code;
$decode_json = decode_json(encode_utf8($json)); $decode_json = eval{decode_json(encode_utf8($json))};
if($@){
Log3 $name, 3, "HEOSGroup ($name) - JSON error while request: $@";
return;
}
Log3 $name, 4, "HEOSGroup ($name) - ParseFn wurde aufgerufen"; Log3 $name, 4, "HEOSGroup ($name) - ParseFn wurde aufgerufen";
if( defined($decode_json->{gid}) ) { if( defined($decode_json->{gid}) ) {

View File

@ -65,7 +65,7 @@ eval "use Encode;1" or $missingModul .= "Encode ";
my $version = "1.0.2"; my $version = "1.0.3";
my %heosCmds = ( my %heosCmds = (
'enableChangeEvents' => 'system/register_for_change_events?enable=', 'enableChangeEvents' => 'system/register_for_change_events?enable=',
@ -94,7 +94,7 @@ my %heosCmds = (
'setMute' => 'player/set_mute?', 'setMute' => 'player/set_mute?',
'setGroupMute' => 'group/set_mute?', 'setGroupMute' => 'group/set_mute?',
'playNext' => 'player/play_next?', 'playNext' => 'player/play_next?',
'playPrev' => 'player/play_prev?', 'playPrev' => 'player/play_previous?',
'playPresetStation' => 'browse/play_preset?', 'playPresetStation' => 'browse/play_preset?',
'playInput' => 'browse/play_input?', 'playInput' => 'browse/play_input?',
'playStream' => 'browse/play_stream?', 'playStream' => 'browse/play_stream?',
@ -228,7 +228,7 @@ sub HEOSMaster_Undef($$) {
HEOSMaster_Close($hash); HEOSMaster_Close($hash);
delete $modules{HEOSMaster}{defptr}{$hash->{HOST}}; delete $modules{HEOSMaster}{defptr}{$hash->{HOST}};
Log3 $name, 3, "HEOSPlayer ($name) - device $name deleted"; Log3 $name, 3, "HEOSMaster ($name) - device $name deleted";
return undef; return undef;
} }
@ -514,7 +514,12 @@ sub HEOSMaster_ProcessRead($$) {
$hash->{LAST_RECV} = time(); $hash->{LAST_RECV} = time();
Log3 $name, 5, "HEOSMaster ($name) - Decoding JSON message. Length: " . length($json) . " Content: " . $json; Log3 $name, 5, "HEOSMaster ($name) - Decoding JSON message. Length: " . length($json) . " Content: " . $json;
my $obj = decode_json($json);
my $obj = eval{decode_json($json)};
if($@){
Log3 $name, 3, "HEOSMaster ($name) - JSON error while request: $@";
return;
}
if(defined($obj->{heos})) { if(defined($obj->{heos})) {
@ -548,7 +553,11 @@ sub HEOSMaster_ResponseProcessing($$) {
unless( defined($json)); unless( defined($json));
Log3 $name, 4, "HEOSMaster ($name) - JSON detected!"; Log3 $name, 4, "HEOSMaster ($name) - JSON detected!";
$decode_json = decode_json(encode_utf8($json)); $decode_json = eval{decode_json(encode_utf8($json))};
if($@){
Log3 $name, 3, "HEOSMaster ($name) - JSON error while request: $@";
return;
}
return Log3 $name, 3, "HEOSMaster ($name) - decode_json has no Hash" return Log3 $name, 3, "HEOSMaster ($name) - decode_json has no Hash"
unless(ref($decode_json) eq "HASH"); unless(ref($decode_json) eq "HASH");

View File

@ -39,7 +39,7 @@ use Encode qw(encode_utf8);
use URI::Escape; use URI::Escape;
#use Data::Dumper; #use Data::Dumper;
my $version = "1.0.2"; my $version = "1.0.3";
@ -791,7 +791,12 @@ sub HEOSPlayer_Parse($$) {
my $code; my $code;
$decode_json = decode_json(encode_utf8($json)); $decode_json = eval{decode_json(encode_utf8($json))};
if($@){
Log3 $name, 3, "HEOSPlayer ($name) - JSON error while request: $@";
return;
}
Log3 $name, 4, "HEOSPlayer - ParseFn wurde aufgerufen"; Log3 $name, 4, "HEOSPlayer - ParseFn wurde aufgerufen";
if( defined($decode_json->{pid}) ) { if( defined($decode_json->{pid}) ) {