This commit is contained in:
+31
-13
@@ -266,8 +266,7 @@ class Manager extends IPSModule implements ManagerSchnittstelle
|
|||||||
}
|
}
|
||||||
$this->setzeDiagnosewert('Monatsgrenzen', $this->ReadPropertyString('Monatsgrenzen'));
|
$this->setzeDiagnosewert('Monatsgrenzen', $this->ReadPropertyString('Monatsgrenzen'));
|
||||||
$this->aktualisiereAnschlussstatus();
|
$this->aktualisiereAnschlussstatus();
|
||||||
$geraetezugangFehlt = ($this->ReadPropertyBoolean('PrognoseAktiv')
|
$geraetezugangFehlt = $this->geraetezugangBenoetigt()
|
||||||
|| $this->ReadPropertyBoolean('StoerueberwachungAktiv'))
|
|
||||||
&& $this->ReadAttributeString('PrognoseInstallationsToken') === '';
|
&& $this->ReadAttributeString('PrognoseInstallationsToken') === '';
|
||||||
if (!$this->aktualisiereLizenzfreigabe(
|
if (!$this->aktualisiereLizenzfreigabe(
|
||||||
$this->ReadPropertyString('Lizenzcode'),
|
$this->ReadPropertyString('Lizenzcode'),
|
||||||
@@ -500,7 +499,9 @@ class Manager extends IPSModule implements ManagerSchnittstelle
|
|||||||
if (!is_string($wert)) {
|
if (!is_string($wert)) {
|
||||||
throw new InvalidArgumentException('Der Lizenzcode muss als Text uebergeben werden.');
|
throw new InvalidArgumentException('Der Lizenzcode muss als Text uebergeben werden.');
|
||||||
}
|
}
|
||||||
$this->aktualisiereLizenzfreigabe($wert, true);
|
if ($this->aktualisiereLizenzfreigabe($wert, true)) {
|
||||||
|
$this->synchronisiereAnlagentopologie();
|
||||||
|
}
|
||||||
$this->UpdateFormField('LizenzInformation', 'caption', $this->lizenzStatustext($wert));
|
$this->UpdateFormField('LizenzInformation', 'caption', $this->lizenzStatustext($wert));
|
||||||
$this->aktualisiereLastspitzenformular($wert);
|
$this->aktualisiereLastspitzenformular($wert);
|
||||||
$this->aktualisierePrognoseformular($wert);
|
$this->aktualisierePrognoseformular($wert);
|
||||||
@@ -2123,8 +2124,7 @@ class Manager extends IPSModule implements ManagerSchnittstelle
|
|||||||
&& $this->lizenzBerechtigungenPassen($lease, $lastspitzenmodus);
|
&& $this->lizenzBerechtigungenPassen($lease, $lastspitzenmodus);
|
||||||
$gueltig = $leaseGueltig && $berechtigungenPassen;
|
$gueltig = $leaseGueltig && $berechtigungenPassen;
|
||||||
$berechtigungenVeraltet = $basisGueltig && !$berechtigungenPassen;
|
$berechtigungenVeraltet = $basisGueltig && !$berechtigungenPassen;
|
||||||
$geraetezugangFehlt = ($this->ReadPropertyBoolean('PrognoseAktiv')
|
$geraetezugangFehlt = $this->geraetezugangBenoetigt()
|
||||||
|| $this->ReadPropertyBoolean('StoerueberwachungAktiv'))
|
|
||||||
&& $this->ReadAttributeString('PrognoseInstallationsToken') === '';
|
&& $this->ReadAttributeString('PrognoseInstallationsToken') === '';
|
||||||
$routineFaellig = (!$gueltig && !$berechtigungenVeraltet)
|
$routineFaellig = (!$gueltig && !$berechtigungenVeraltet)
|
||||||
|| $geraetezugangFehlt
|
|| $geraetezugangFehlt
|
||||||
@@ -2475,8 +2475,7 @@ class Manager extends IPSModule implements ManagerSchnittstelle
|
|||||||
$nutzlast = json_encode([
|
$nutzlast = json_encode([
|
||||||
'code' => $lizenzcode,
|
'code' => $lizenzcode,
|
||||||
'installationId' => $installationID,
|
'installationId' => $installationID,
|
||||||
'issueDeviceToken' => ($this->ReadPropertyBoolean('PrognoseAktiv')
|
'issueDeviceToken' => $this->geraetezugangBenoetigt()
|
||||||
|| $this->ReadPropertyBoolean('StoerueberwachungAktiv'))
|
|
||||||
&& $this->ReadAttributeString('PrognoseInstallationsToken') === '',
|
&& $this->ReadAttributeString('PrognoseInstallationsToken') === '',
|
||||||
], JSON_THROW_ON_ERROR | JSON_UNESCAPED_SLASHES);
|
], JSON_THROW_ON_ERROR | JSON_UNESCAPED_SLASHES);
|
||||||
$curl = curl_init(self::LIZENZ_ENDPOINT);
|
$curl = curl_init(self::LIZENZ_ENDPOINT);
|
||||||
@@ -2646,6 +2645,25 @@ class Manager extends IPSModule implements ManagerSchnittstelle
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private function geraetezugangBenoetigt(): bool
|
||||||
|
{
|
||||||
|
if ($this->ReadPropertyBoolean('PrognoseAktiv')
|
||||||
|
|| $this->ReadPropertyBoolean('StoerueberwachungAktiv')
|
||||||
|
) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
$topologie = $this->leseAnlagentopologie();
|
||||||
|
} catch (Throwable $fehler) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $topologie['inverters'] !== []
|
||||||
|
|| $topologie['pvArrays'] !== []
|
||||||
|
|| $topologie['batteries'] !== [];
|
||||||
|
}
|
||||||
|
|
||||||
private function prognoseTelemetrieKonfiguriert(): bool
|
private function prognoseTelemetrieKonfiguriert(): bool
|
||||||
{
|
{
|
||||||
return $this->ReadPropertyBoolean('PrognoseAktiv')
|
return $this->ReadPropertyBoolean('PrognoseAktiv')
|
||||||
@@ -2697,11 +2715,6 @@ class Manager extends IPSModule implements ManagerSchnittstelle
|
|||||||
|
|
||||||
private function synchronisiereAnlagentopologie(): void
|
private function synchronisiereAnlagentopologie(): void
|
||||||
{
|
{
|
||||||
if (!$this->ReadPropertyBoolean('PrognoseAktiv')) {
|
|
||||||
$this->setzeDiagnosewert('Prognosestatus', 'NichtVerwendet');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$topologie = $this->leseAnlagentopologie();
|
$topologie = $this->leseAnlagentopologie();
|
||||||
if ($topologie['inverters'] === []
|
if ($topologie['inverters'] === []
|
||||||
@@ -2717,7 +2730,12 @@ class Manager extends IPSModule implements ManagerSchnittstelle
|
|||||||
throw new RuntimeException('Der Geraetezugang fuer die Prognose fehlt.');
|
throw new RuntimeException('Der Geraetezugang fuer die Prognose fehlt.');
|
||||||
}
|
}
|
||||||
$this->sendeAnlagentopologie($topologie, $token);
|
$this->sendeAnlagentopologie($topologie, $token);
|
||||||
$this->setzeDiagnosewert('Prognosestatus', 'Verbunden');
|
$this->setzeDiagnosewert(
|
||||||
|
'Prognosestatus',
|
||||||
|
$this->ReadPropertyBoolean('PrognoseAktiv')
|
||||||
|
? 'Verbunden'
|
||||||
|
: 'Topologie synchronisiert'
|
||||||
|
);
|
||||||
} catch (Throwable $fehler) {
|
} catch (Throwable $fehler) {
|
||||||
$meldung = substr($fehler->getMessage(), 0, 500);
|
$meldung = substr($fehler->getMessage(), 0, 500);
|
||||||
$this->setzeDiagnosewert('Prognosestatus', 'Fehler: ' . $meldung);
|
$this->setzeDiagnosewert('Prognosestatus', 'Fehler: ' . $meldung);
|
||||||
|
|||||||
@@ -226,6 +226,15 @@ final class ManagerModulstrukturTest extends TestCase
|
|||||||
$inhalt
|
$inhalt
|
||||||
);
|
);
|
||||||
self::assertStringContainsString('synchronisiereAnlagentopologie()', $inhalt);
|
self::assertStringContainsString('synchronisiereAnlagentopologie()', $inhalt);
|
||||||
|
self::assertStringContainsString('private function geraetezugangBenoetigt(): bool', $inhalt);
|
||||||
|
self::assertStringContainsString(
|
||||||
|
"if (\$this->aktualisiereLizenzfreigabe(\$wert, true)) {",
|
||||||
|
$inhalt
|
||||||
|
);
|
||||||
|
self::assertStringNotContainsString(
|
||||||
|
"if (!\$this->ReadPropertyBoolean('PrognoseAktiv')) {\n \$this->setzeDiagnosewert('Prognosestatus', 'NichtVerwendet');\n return;\n }\n\n try {",
|
||||||
|
$inhalt
|
||||||
|
);
|
||||||
self::assertStringContainsString(
|
self::assertStringContainsString(
|
||||||
'https://license.enelix.ch/api/v1/installations/%s/prognosis/telemetry',
|
'https://license.enelix.ch/api/v1/installations/%s/prognosis/telemetry',
|
||||||
$inhalt
|
$inhalt
|
||||||
|
|||||||
Reference in New Issue
Block a user