2
0
mirror of https://github.com/fhem/fhem-mirror.git synced 2025-03-10 09:16:53 +00:00

76_SMAPortal: update time in portalgraphics changed to last successful live data retrieval

git-svn-id: https://svn.fhem.de/fhem/trunk@21740 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
nasseeder1 2020-04-21 15:01:42 +00:00
parent 5bf1cf76d0
commit ed38f57c71
2 changed files with 74 additions and 77 deletions

View File

@ -1,5 +1,7 @@
# 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.
- change: 76_SMAPortal: update time in portalgraphics changed to last
successful live data retrieval
- change: 76_SMAPortal(SPG): change to package config, improve cookie
management, decouple switch consumers from
livedata retrieval, some improvements according

View File

@ -131,11 +131,9 @@ BEGIN {
}
# Standardvariablen und Forward-Deklaration
# use vars qw($FW_ME); # webname (default is fhem)
# Versions History intern
my %vNotesIntern = (
"2.6.1" => "21.04.2020 update time in portalgraphics changed to last successful live data retrieval, credentials are not shown in list device ",
"2.6.0" => "20.04.2020 change package config, improve cookie management, decouple switch consumers from livedata retrieval ".
"some improvements according to PBP ",
"2.5.0" => "25.08.2019 change switch consumer to on<->automatic only in graphic overview, Forum: https://forum.fhem.de/index.php/topic,102112.msg969002.html#msg969002",
@ -514,8 +512,7 @@ sub getcredentials {
my ($success, $username, $passwd, $index, $retcode, $credstr);
my (@key,$len,$i);
if ($boot) {
# mit $boot=1 Credentials von Platte lesen und als scrambled-String in RAM legen
if ($boot) { # mit $boot=1 Credentials von Platte lesen und als scrambled-String in RAM legen
$index = $hash->{TYPE}."_".$hash->{NAME}."_credentials";
($retcode, $credstr) = getKeyValue($index);
@ -524,17 +521,14 @@ sub getcredentials {
$success = 0;
}
if ($credstr) {
# beim Boot scrambled Credentials in den RAM laden
$hash->{HELPER}{CREDENTIALS} = $credstr;
if ($credstr) { # beim Boot scrambled Credentials in den RAM laden
$hash->{HELPER}{".CREDENTIALS"} = $credstr;
# "Credentials" wird als Statusbit ausgewertet. Wenn nicht gesetzt -> Warnmeldung und keine weitere Verarbeitung
$hash->{CREDENTIALS} = "Set";
$hash->{CREDENTIALS} = "Set"; # "Credentials" wird als Statusbit ausgewertet. Wenn nicht gesetzt -> Warnmeldung und keine weitere Verarbeitung
$success = 1;
}
} else {
# boot = 0 -> Credentials aus RAM lesen, decoden und zurückgeben
$credstr = $hash->{HELPER}{CREDENTIALS};
} else { # boot = 0 -> Credentials aus RAM lesen, decoden und zurückgeben
$credstr = $hash->{HELPER}{".CREDENTIALS"} // $hash->{HELPER}{CREDENTIALS}; # Kompatibilität zu Versionen vor 2.6.1
if($credstr) {
# Beginn Descramble-Routine
@ -678,10 +672,10 @@ sub GetSetData { ## no cri
my $useragent = AttrVal($name, "userAgent", "Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.2; Trident/6.0)");
my $cookieLocation = AttrVal($name, "cookieLocation", "./log/mycookies.txt");
my $v5d = AttrVal($name, "verbose5Data", "none");
my ($forecast_content,$weatherdata_content,$consumerlivedata_content,$ccdaydata_content,$ccmonthdata_content) = ("","","","","");
my ($ccyeardata_content) = ("");
my $state = "ok";
my ($reread,$retry) = (0,0);
my ($forecast_content,$weatherdata_content,$consumerlivedata_content,$ccdaydata_content,$ccmonthdata_content) = ("","","","","");
my ($livedata_content,$d,$op);
if($setp ne "none") {
@ -1082,6 +1076,8 @@ sub ParseData { ## no critic
# keine Anlagendaten vorhanden
$state = "Data can't be retrieved from SMA-Portal. Reread at next scheduled cycle.";
Log3 ($name, 2, "$name - $state");
} else {
$hash->{HELPER}{LASTLDSUCCTIME} = FmtDateTime(time()) if($getp ne "none");
}
readingsBeginUpdate($hash);
@ -1529,7 +1525,6 @@ sub extractConsumerLiveData {
$i = 0;
foreach my $c (@{$clivedata->{'ParameterData'}}) {
my $tkind = $c->{'Parameters'}[0]{'Timestamp'}{'Kind'}; # Zeitart: Unspecified, Utc
# Log3 ($name, 1, "$name - $tkind");
my $GriSwStt = $c->{'Parameters'}[0]{'Value'}; # on: 1, off: 0
my $GriSwAuto = $c->{'Parameters'}[1]{'Value'}; # automatic = 1
my $OperationAutoEna = $c->{'Parameters'}[2]{'Value'}; # Automatic Betrieb erlaubt ?
@ -1885,9 +1880,10 @@ sub PortalAsHtml {
$hash->{HELPER}{SPGROOM} = $FW_room?$FW_room:""; # Raum aus dem das SMAPortalSPG-Device die Funktion aufrief
$hash->{HELPER}{SPGDETAIL} = $FW_detail?$FW_detail:""; # Name des SMAPortalSPG-Devices (wenn Detailansicht)
my $dl = AttrVal($name, "detailLevel", 1);
my $pv0 = ReadingsNum($name,"L2_ThisHour_PvMeanPower", undef);
my $pv1 = ReadingsNum($name,"L4_NextHour01_PvMeanPower", undef);
my $dl = AttrVal ($name, "detailLevel", 1);
my $pv0 = ReadingsNum($name, "L2_ThisHour_PvMeanPower", undef);
my $pv1 = ReadingsNum($name, "L4_NextHour01_PvMeanPower", undef);
if(!$hash || !defined($defs{$wlname}) || $dl != 4 || !defined $pv0 || !defined $pv1) {
$height = AttrNum($wlname, 'beamHeight', 200);
$ret .= "<table class='roomoverview'>";
@ -1982,10 +1978,9 @@ sub PortalAsHtml {
# Beispiel mit Farbe: $icon = FW_makeImage('light_light_dim_100.svg@green');
$icon = FW_makeImage($icon) if (defined($icon));
my $co4h = ReadingsNum($name,"L2_Next04Hours_Consumption", 0);
my $coRe = ReadingsNum($name,"L2_RestOfDay_Consumption", 0);
my $coTo = ReadingsNum($name,"L2_Tomorrow_Consumption", 0);
my $co4h = ReadingsNum ($name,"L2_Next04Hours_Consumption", 0);
my $coRe = ReadingsNum ($name,"L2_RestOfDay_Consumption", 0);
my $coTo = ReadingsNum ($name,"L2_Tomorrow_Consumption", 0);
my $pv4h = ReadingsNum($name,"L2_Next04Hours_PV", 0);
my $pvRe = ReadingsNum($name,"L2_RestOfDay_PV", 0);
@ -2013,7 +2008,7 @@ sub PortalAsHtml {
my $lang = AttrVal("global","language","EN");
my $alias = AttrVal($name, "alias", "SMA Sunny Portal"); # Linktext als Aliasname oder "SMA Sunny Portal"
my $dlink = "<a href=\"/fhem?detail=$name\">$alias</a>";
my $lup = ReadingsTimestamp($name, "state", "0000-00-00 00:00:00"); # letzte Updatezeit
my $lup = $hash->{HELPER}{LASTLDSUCCTIME} // "0000-00-00 00:00:00"; # letzte erfolgreiche Updatezeit Live Daten
my $lupt = "last update:";
my $lblPv4h = "4h:";