From 0d8e0edfe40913a2adfce8ac29b6db656d99cef0 Mon Sep 17 00:00:00 2001 From: nasseeder1 Date: Thu, 2 Jul 2020 20:47:30 +0000 Subject: [PATCH] 76_SMAPortal: new attribute noHomeManager git-svn-id: https://svn.fhem.de/fhem/trunk@22332 2b470e98-0d58-463d-a4d8-8e2adae1ed80 --- fhem/CHANGED | 1 + fhem/FHEM/76_SMAPortal.pm | 99 ++++++++++++++++++++++++++------------- 2 files changed, 67 insertions(+), 33 deletions(-) diff --git a/fhem/CHANGED b/fhem/CHANGED index 669eff200..5d7dfa934 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. + - feature: 76_SMAPortal: new attribute noHomeManager - bugfix: 70_BRAVIA: check available service APIs if available only - change: 49_SSCam / 49_SSCamSTRM: switch to packages, changes according PBP - bugfix: 73_AutoShuttersControl: fix commandref and bug in shading function diff --git a/fhem/FHEM/76_SMAPortal.pm b/fhem/FHEM/76_SMAPortal.pm index b9120b4ef..43f20df77 100644 --- a/fhem/FHEM/76_SMAPortal.pm +++ b/fhem/FHEM/76_SMAPortal.pm @@ -136,6 +136,7 @@ BEGIN { # Versions History intern my %vNotesIntern = ( + "3.3.0" => "02.07.2020 fix typo, new attribute noHomeManager ", "3.2.0" => "30.06.2020 add data provider balanceCurrentData (experimental), balanceMonthData, balanceYearData ", "3.1.2" => "25.06.2020 don't delete cookie after every data retrieval, change login management ", "3.1.1" => "24.06.2020 change german Error regex, get plantOid from cookie if not in JSON ", @@ -223,23 +224,24 @@ my %statkeys = ( # Statistikdaten auszulesende Schlüs AutarkyRate => 1, ); -my %subs; # Arbeitskopie von %stpl -my %stpl = ( # Ausgangstemplate Subfunktionen der Datenprovider - consumerMasterdata => { doit => 1, level => 'L00', func => '_getConsumerMasterdata' }, # mandatory - plantMasterData => { doit => 1, level => 'L00', func => '_getPlantMasterData' }, # mandatory - liveData => { doit => 0, level => 'L01', func => '_getLiveData' }, - weatherData => { doit => 0, level => 'L02', func => '_getWeatherData' }, - forecastData => { doit => 0, level => 'L04', func => '_getForecastData' }, - consumerCurrentdata => { doit => 0, level => 'L05', func => '_getConsumerCurrData' }, - consumerDayData => { doit => 0, level => 'L06', func => '_getConsumerDayData' }, - consumerMonthData => { doit => 0, level => 'L07', func => '_getConsumerMonthData' }, - consumerYearData => { doit => 0, level => 'L08', func => '_getConsumerYearData' }, - plantLogbook => { doit => 0, level => 'L09', func => '_getPlantLogbook' }, - balanceCurrentData => { doit => 0, level => 'L10', func => '_getBalanceCurrentData' }, - balanceDayData => { doit => 0, level => 'L11', func => '_getBalanceDayData' }, - balanceMonthData => { doit => 0, level => 'L12', func => '_getBalanceMonthData' }, - balanceYearData => { doit => 0, level => 'L13', func => '_getBalanceYearData' }, - balanceTotalData => { doit => 0, level => 'L14', func => '_getBalanceTotalData' }, +my %mandatory; # Arbeitskopie von %stpl -> abzurufenden Datenprovider Stammdaten nach Login +my %subs; # Arbeitskopie von %stpl -> Festlegung abzurufenden Datenprovider +my %stpl = ( # Ausgangstemplate Subfunktionen der Datenprovider + consumerMasterdata => { doit => 1, nohm => 1, level => 'L00', func => '_getConsumerMasterdata' }, # mandatory (außer wenn kein SMA Home Manager vorhanden) + plantMasterData => { doit => 1, nohm => 1, level => 'L00', func => '_getPlantMasterData' }, # mandatory (außer wenn kein SMA Home Manager vorhanden) + liveData => { doit => 0, nohm => 0, level => 'L01', func => '_getLiveData' }, + weatherData => { doit => 0, nohm => 0, level => 'L02', func => '_getWeatherData' }, + forecastData => { doit => 0, nohm => 1, level => 'L04', func => '_getForecastData' }, + consumerCurrentdata => { doit => 0, nohm => 1, level => 'L05', func => '_getConsumerCurrData' }, + consumerDayData => { doit => 0, nohm => 1, level => 'L06', func => '_getConsumerDayData' }, + consumerMonthData => { doit => 0, nohm => 1, level => 'L07', func => '_getConsumerMonthData' }, + consumerYearData => { doit => 0, nohm => 1, level => 'L08', func => '_getConsumerYearData' }, + plantLogbook => { doit => 0, nohm => 0, level => 'L09', func => '_getPlantLogbook' }, + balanceCurrentData => { doit => 0, nohm => 0, level => 'L10', func => '_getBalanceCurrentData' }, + balanceDayData => { doit => 0, nohm => 0, level => 'L11', func => '_getBalanceDayData' }, + balanceMonthData => { doit => 0, nohm => 0, level => 'L12', func => '_getBalanceMonthData' }, + balanceYearData => { doit => 0, nohm => 0, level => 'L13', func => '_getBalanceYearData' }, + balanceTotalData => { doit => 0, nohm => 0, level => 'L14', func => '_getBalanceTotalData' }, ); # Tags der verfügbaren Datenquellen my @pd = qw( plantMasterData @@ -283,6 +285,7 @@ sub Initialize { $hash->{AttrList} = "cookieLocation ". "disable:0,1 ". "interval ". + "noHomeManager:1,0 ". "plantLogbookTypes:multiple-strict,Info,Warning,Disturbance,Error ". "plantLogbookApprovalState:Any,NotApproved ". "providerLevel:multiple-strict,".$prov." ". @@ -732,11 +735,17 @@ sub CallInfo { return if(IsDisabled($name)); for my $key (keys %stpl) { # festlegen welche Daten geliefert werden sollen - next if($stpl{$key}{doit}); # die default Provider nicht noch einmal ausführen + if($stpl{$key}{doit}) { # Datenprovider nach Login ausführen (mandatories) + $mandatory{$name}{$key}{doit} = $stpl{$key}{doit}; + $mandatory{$name}{$key}{level} = $stpl{$key}{level}; + $mandatory{$name}{$key}{func} = $stpl{$key}{func}; + next; + } $subs{$name}{$key}{doit} = $stpl{$key}{doit}; $subs{$name}{$key}{level} = $stpl{$key}{level}; $subs{$name}{$key}{func} = $stpl{$key}{func}; } + my @pl = split ",", AttrVal($name, "providerLevel", ""); for my $p (@pl) { $subs{$name}{$p}{doit} = 1; @@ -759,6 +768,16 @@ sub CallInfo { Log3 ($name, 4, "$name - calculated timeout: $timeout"); } + if(AttrVal($name, "noHomeManager", 0)) { # wenn kein Home Manager installiert ist keine mandatories ausführen + %mandatory = (); + for my $k (keys %stpl) { + if($stpl{$k}{nohm}) { + $subs{$name}{$k}{doit} = 0; + Log3 ($name, 3, qq{$name - ignore provider "$k" - SMA Home Manager is not installed}) if(!$nc && !$nr); + } + } + } + if(!$nc) { $hash->{HELPER}{ACTCYCLE} = 1; $hash->{HELPER}{CYCLEBTIME} = (gettimeofday())[0]; @@ -876,7 +895,7 @@ sub GetSetData { ## no cri ### Login ############## - my $paref = [ $name, $ua, $state, $errstate ]; + my $paref = [ $name, $ua, $state, $errstate ]; ($state, $errstate) = _doLogin ($paref); if($errstate) { @@ -884,16 +903,17 @@ sub GetSetData { ## no cri return "$name|0|0|$errstate|$getp|$setp|$st"; } - ### die Anlagen Asset Daten auslesen (Funktionen in Template %stpl default doit=1) + ### die Anlagen Asset Daten auslesen (Funktionen aus %mandatory mit doit=1) + ### (Hash %mandatory ist leer wenn kein SMA Home Manager eingesetzt) ################################################################################## - for my $k (keys %stpl) { - next if(!$stpl{$k}{doit}); - no strict "refs"; ## no critic 'NoStrict' - ($errstate,$state,$reread,$retry) = &{$stpl{$k}{func}} ({ name => $name, - ua => $ua, - state => $state, - daref => \@da - }); + for my $k (keys %{$mandatory{$name}}) { + next if(!$mandatory{$name}{$k}{doit}); + no strict "refs"; ## no critic 'NoStrict' + ($errstate,$state,$reread,$retry) = &{$mandatory{$name}{$k}{func}} ({ name => $name, + ua => $ua, + state => $state, + daref => \@da + }); use strict "refs"; if($errstate) { @@ -3000,7 +3020,7 @@ sub PortalAsHtml { } elsif (!defined $pv0) { $ret .= "Awaiting minor level forecast data ..."; } elsif (!defined $pv1) { - $ret .= "Awaiting level major level forecast data ..."; + $ret .= "Awaiting major level forecast data ..."; } $ret .= ""; @@ -3842,7 +3862,8 @@ return; After a successful login, only the asset master data are retrieved. The attribute providerLevel is used to set the data suppliers its data - the device should retrieve. + the device should retrieve. If no Sunny Home Manager is installed, the attribute + noHomeManager must be set.

@@ -3926,7 +3947,7 @@ return; Time interval for continuous data retrieval from the aus dem SMA Sunny Portal (default: 300 seconds).
if the interval is set to "0", no continuous data retrieval is executed and has to be triggered manually by the "get <name> data" command.

- +
+ +
  • noHomeManager
    + Must be set if no Sunny Home Manager is installed. +

  • +
  • plantLogbookApprovalState
    With this attribute the entries are filtered according to their status.
    @@ -4084,7 +4110,8 @@ return; Nach einem erfolgreichen Login werden nur die Anlagenstammdaten abgerufen. Mit dem Attribut providerLevel werden die Datenlieferanten eingestellt, die durch das - Device abgerufen werden sollen. + Device abgerufen werden sollen. Ist kein Sunny Home Manager installiert, muss das Attribut + noHomeManager gesetzt werden.

    @@ -4166,7 +4193,8 @@ return;
  • disable
    - Deaktiviert das Device.

  • + Deaktiviert das Device. +
  • interval <Sekunden>
    @@ -4181,6 +4209,11 @@ return;

  • + +
  • noHomeManager
    + Muss gesetzt werden wenn kein Sunny Home Manager installiert ist. +

  • +
  • plantLogbookApprovalState
    Mit diesem Attribut werden die Einträge entsprechend ihres Status gefiltert.