mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-04-21 20:06:18 +00:00
24_TPLinkHS110.pm: Improved stabiltiy
git-svn-id: https://svn.fhem.de/fhem/trunk@12183 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
8ed704a9be
commit
5b5e9354f8
@ -151,6 +151,7 @@ sub TPLinkHS110_Get($$)
|
||||
$socket->recv($data,1024);
|
||||
$socket->close();
|
||||
$data = decrypt(substr($data,4));
|
||||
eval {
|
||||
my $json = decode_json($data);
|
||||
my $total=0;
|
||||
foreach my $key (sort keys @{$json->{'emeter'}->{'get_daystat'}->{'day_list'}}) {
|
||||
@ -162,6 +163,10 @@ sub TPLinkHS110_Get($$)
|
||||
$count = @{$json->{'emeter'}->{'get_daystat'}->{'day_list'}};
|
||||
readingsBulkUpdate($hash, "monthly_total", $total);
|
||||
readingsBulkUpdate($hash, "daily_average", $total/$count);
|
||||
1;
|
||||
} or do {
|
||||
Log3 $hash, 3, "TPLinkHS110: $name json-decoding failed. Problem decoding getting statistical data";
|
||||
};
|
||||
}
|
||||
readingsEndUpdate($hash, 1);
|
||||
Log3 $hash, 3, "TPLinkHS110: $name Get end";
|
||||
|
Loading…
x
Reference in New Issue
Block a user