From 5f0f8a9ebac94332bd9d050652e5fcb8d33e420c Mon Sep 17 00:00:00 2001 From: nasseeder1 Date: Sun, 10 Mar 2019 07:34:29 +0000 Subject: [PATCH] 76_SMAPortal: contrib 1.2.1 git-svn-id: https://svn.fhem.de/fhem/trunk@18843 2b470e98-0d58-463d-a4d8-8e2adae1ed80 --- fhem/contrib/DS_Starter/76_SMAPortal.pm | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/fhem/contrib/DS_Starter/76_SMAPortal.pm b/fhem/contrib/DS_Starter/76_SMAPortal.pm index d2bec1758..e574bef1c 100644 --- a/fhem/contrib/DS_Starter/76_SMAPortal.pm +++ b/fhem/contrib/DS_Starter/76_SMAPortal.pm @@ -6,8 +6,7 @@ # (c) 2019 by Heiko Maaz # e-mail: Heiko dot Maaz at t-online dot de # -# This Module can be used to operate Cameras defined in Synology Surveillance Station 7.0 or higher. -# It's based on and uses Synology Surveillance Station API. +# This module can be used to get data from SMA Portal https://www.sunnyportal.com/Templates/Start.aspx . # # This script is part of fhem. # @@ -48,7 +47,8 @@ use HTTP::Cookies; use JSON qw(decode_json); # Versions History intern -our %SMAPortal_vNotesIntern = ( +our %SMAPortal_vNotesIntern = ( + "1.2.1" => "10.03.2019 behavior of state changed, commandref revised ", "1.2.0" => "09.03.2019 integrate weather data, minor fixes ", "1.1.0" => "09.03.2019 make get data more stable, new attribute \"getDataRetries\" ", "1.0.0" => "03.03.2019 initial " @@ -506,6 +506,8 @@ sub SMAPortal_ParseData($) { my $forecast_content = decode_json($fd_response) if($fd_response); my $weatherdata_content = decode_json($wd_response) if($wd_response); + my $state = "ok"; + my $timeout = AttrVal($name, "timeout", 30); if($reread) { # login war erfolgreich, aber Daten müssen jetzt noch gelesen werden @@ -588,12 +590,18 @@ sub SMAPortal_ParseData($) { my $pv = ReadingsVal($name, "L1_PV", 0); my $fi = ReadingsVal($name, "L1_FeedIn", 0); my $gc = ReadingsVal($name, "L1_GridConsumption", 0); - my $state = $fi-$gc; + my $sum = $fi-$gc; + + if(!$hash->{HELPER}{RETRIES} && !$pv && !$fi && !$gc) { + # keine Anlagendaten vorhanden + $state = "Data can't be retrieved from SMA-Portal. They will read again next scheduled cycle."; + Log3 $name, 2, "$name - $state"; + } readingsBeginUpdate($hash); if($login_state) { readingsBulkUpdate($hash, "state", $state); - readingsBulkUpdate($hash, "summary", $state); + readingsBulkUpdate($hash, "summary", $sum); } readingsEndUpdate($hash, 1); @@ -968,6 +976,7 @@ return; @@ -1070,8 +1079,8 @@ return;