JSONMETER: improved robustness

git-svn-id: https://svn.fhem.de/fhem/trunk@12222 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
grompo
2016-09-29 18:35:21 +00:00
parent 0645fae775
commit ae1a25be60

View File

@@ -330,12 +330,13 @@ JSONMETER_Get($@)
} }
return $message; return $message;
} elsif ($cmd eq "jsonAnalysis") { }
elsif ($cmd eq "jsonAnalysis") {
my $time = gettimeofday(); my $time = gettimeofday();
$hash->{fhem}{jsonInterpreter} = ""; $hash->{fhem}{jsonInterpreter} = "";
$result = JSONMETER_GetJsonFile $name; $result = JSONMETER_GetJsonFile $name;
my @a = split /\|/, $result; my @a = split /\|/, $result;
if ($a[1]==0) { return $a[2]; } return $a[2] if $a[1]==0;
$result = JSONMETER_ParseJsonFile $result; $result = JSONMETER_ParseJsonFile $result;
# my @a = split /\|/, $result; # my @a = split /\|/, $result;
@@ -485,12 +486,15 @@ JSONMETER_ReadFromUrl($)
} # end JSONMETER_ReadFromUrl } # end JSONMETER_ReadFromUrl
sub ########################### ###########################
JSONMETER_ParseJsonFile($) sub JSONMETER_ParseJsonFile($)
{ {
my ($string) = @_; my ($string) = @_;
return unless(defined($string)); return unless(defined($string));
my (@a) = split("\\|", $string); my (@a) = split("\\|", $string);
return unless (defined $defs{$a[0]});
my $hash = $defs{$a[0]}; my $hash = $defs{$a[0]};
my $name = $hash->{NAME}; my $name = $hash->{NAME};
my $value; my $value;
@@ -912,6 +916,10 @@ JSONMETER_doStatisticDeltaSingle ($$$$$$)
=pod =pod
=begin html =begin html
=item device
=item summary reads OBIS data from measurement units
=item summary_DE liest OBIS Daten von Messgeräten
<a name="JSONMETER"></a> <a name="JSONMETER"></a>
<h3>JSONMETER</h3> <h3>JSONMETER</h3>
<div> <div>