From e8db5ece4095aedbe1a4df82152cb4c0562a0ccf Mon Sep 17 00:00:00 2001 From: nasseeder1 Date: Wed, 24 Jun 2020 17:12:14 +0000 Subject: [PATCH] 76_SMAPortal: get plantOid from cookie if not in JSON git-svn-id: https://svn.fhem.de/fhem/trunk@22255 2b470e98-0d58-463d-a4d8-8e2adae1ed80 --- fhem/CHANGED | 1 + fhem/FHEM/76_SMAPortal.pm | 15 ++++++++++++--- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/fhem/CHANGED b/fhem/CHANGED index c75426911..d3b2eebeb 100644 --- a/fhem/CHANGED +++ b/fhem/CHANGED @@ -1,5 +1,6 @@ # 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. + - changed: 76_SMAPortal: get plantOid from cookie if not in JSON - bugfix: 70_ZoneMinder: fix afterInitialized (thx GeberNehmer) - bugfix: 73_AutoShuttersControl: change shading reading message - feature: 76_SMAPortal: upgrade to V3. This version is not compatible to diff --git a/fhem/FHEM/76_SMAPortal.pm b/fhem/FHEM/76_SMAPortal.pm index 520b4ce8a..eac8ba0bd 100644 --- a/fhem/FHEM/76_SMAPortal.pm +++ b/fhem/FHEM/76_SMAPortal.pm @@ -136,6 +136,7 @@ BEGIN { # Versions History intern my %vNotesIntern = ( + "3.1.1" => "24.06.2020 change german Error regex, get plantOid from cookie if not in JSON ", "3.1.0" => "20.06.2020 language of SMA Portal messages depend on global language attribute, avoid order problems by ". "executing retrieve master data firstly every time", "3.0.0" => "18.06.2020 refactored readings and subroutines, detailLevel deleted, new attr providerLevel, integrate logbook data ", @@ -1501,7 +1502,7 @@ sub __dispatchGet { my @func = @$fnref; no strict "refs"; ## no critic 'NoStrict' for my $fn (@func) { - &{$fn} ($hash,$daref,$data_cont,$fnaddon); + &{$fn} ($hash,$daref,$data_cont,$fnaddon,$data); } use strict "refs"; } @@ -1658,7 +1659,7 @@ sub ___analyzeData { ## no critic 'complexity' my $wm2e = qq{The current consumption could not be determined. The current purchased electricity is unknown}; my $wm2d = qq{Der aktuelle Verbrauch konnte nicht ermittelt werden. Der aktuelle Netzbezug ist unbekannt}; my $em1e = qq{Communication with the Sunny Home Manager is currently not possible}; - my $em1d = qq{Kommunikation mit dem Sunny Home Manager derzeit nicht m}; + my $em1d = qq{Die Kommunikation mit dem Sunny Home Manager ist zurzeit nicht m}; my $em2e = qq{The current data cannot be retrieved from the PV system. Check the cabling and configuration}; my $em2d = qq{Die aktuellen Daten .*? nicht von der Anlage abgerufen werden.*? Sie die Verkabelung und Konfiguration}; @@ -2184,6 +2185,8 @@ sub extractPlantMasterData { my $hash = shift; my $daref = shift; my $forecast = shift; + my $addon = shift; + my $data = shift; # gelieferte Rohdaten my $name = $hash->{NAME}; my ($amount,$unit); @@ -2193,7 +2196,13 @@ sub extractPlantMasterData { return; }; my $lv = $stpl{plantMasterData}{level}; - my $plantOid = $forecast->{'ForecastTimeframes'}->{'PlantOid'}; + my $plantOid = $forecast->{'ForecastTimeframes'}->{'PlantOid'}; # Plant ID aus JSON filtern + + if(!$plantOid) { # Plant ID aus Cookie Header extrhieren wenn nicht mi JSON geliefert (kommt vor) + Log3 ($name, 4, "$name - Plant ID not set in data, get it from cookie ..."); + my $sc = $data->header('Set-Cookie') // ""; + ($plantOid) = $sc =~ /plantOid=([0-9a-z-]*);/x; + } if ($plantOid) { # wichtig für erweiterte Selektionen Log3 ($name, 4, "$name - Plant ID: ".$plantOid);