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

24_TPLinkHS110: Added eval around decode_json

git-svn-id: https://svn.fhem.de/fhem/trunk@13514 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
vk 2017-02-25 16:01:42 +00:00
parent 83a85a9903
commit 44be045253

View File

@ -105,7 +105,13 @@ sub TPLinkHS110_Get($$)
$socket->close();
unless( defined $retval) { return undef; }
$data = decrypt(substr($data,4));
my $json = decode_json($data);
my $json;
eval {
$json = decode_json($data);
} or do {
Log3 $hash, 2, "TPLinkHS110: $name json-decoding failed. Problem decoding getting statistical data";
return;
};
Log3 $hash, 3, "TPLinkHS110: $name Get called. Relay state: $json->{'system'}->{'get_sysinfo'}->{'relay_state'}, RSSI: $json->{'system'}->{'get_sysinfo'}->{'rssi'}";
readingsBeginUpdate($hash);
@ -220,7 +226,14 @@ sub TPLinkHS110_Set($$)
$socket->close();
unless( defined $retval) { return undef; }
$data = decrypt(substr($data,4));
my $json = decode_json($data);
my $json;
eval {
$json = decode_json($data);
} or do {
Log3 $hash, 2, "TPLinkHS110: $name json-decoding failed. Problem decoding getting statistical data";
return;
};
if ($json->{'system'}->{'set_relay_state'}->{'err_code'} eq "0") {
TPLinkHS110_Get($hash,"");
@ -302,9 +315,14 @@ sub TPLinkHS110_Attr {
$socket->close();
unless( defined $retval) { return undef; }
$data = decrypt(substr($data,4));
my $json = decode_json($data);
my $json;
eval {
$json = decode_json($data);
} or do {
Log3 $hash, 2, "TPLinkHS110: $name json-decoding failed. Problem decoding getting statistical data";
return;
};
}
return undef;
}