This commit is contained in:
+150
-15
@@ -41,7 +41,13 @@ class LadestationGateway extends IPSModule implements VerbraucherSchnittstelle
|
||||
'Stoertext',
|
||||
'GatewayVerbunden',
|
||||
'ApiMaximalstrom',
|
||||
'EaseeAktiviert',
|
||||
'AutorisierungErforderlich',
|
||||
'RemoteStartErforderlich',
|
||||
'SmartCharging',
|
||||
'GrundKeinLadestrom',
|
||||
'LetzterGeraetebefehl',
|
||||
'LetzterStartbefehl',
|
||||
'LeistungsangebotDiagnose',
|
||||
];
|
||||
|
||||
@@ -82,6 +88,11 @@ class LadestationGateway extends IPSModule implements VerbraucherSchnittstelle
|
||||
$this->RegisterAttributeString('EaseeBeobachtungen', '{}');
|
||||
$this->RegisterAttributeInteger('LetzteBeobachtung', 0);
|
||||
$this->RegisterAttributeInteger('ApiMaximalstrom', 16);
|
||||
$this->RegisterAttributeBoolean('ZustandEaseeAktiviert', true);
|
||||
$this->RegisterAttributeBoolean('ZustandAutorisierungErforderlich', false);
|
||||
$this->RegisterAttributeBoolean('ZustandRemoteStartErforderlich', false);
|
||||
$this->RegisterAttributeBoolean('ZustandSmartCharging', false);
|
||||
$this->RegisterAttributeInteger('ZustandGrundKeinLadestrom', 0);
|
||||
$this->RegisterAttributeBoolean('ZustandFahrzeugVerbunden', false);
|
||||
$this->RegisterAttributeBoolean('ZustandFahrzeugGeladen', false);
|
||||
$this->RegisterAttributeInteger('ZustandFahrzeugstatus', 0);
|
||||
@@ -99,7 +110,9 @@ class LadestationGateway extends IPSModule implements VerbraucherSchnittstelle
|
||||
$this->RegisterAttributeInteger('LetzteManagerID', 0);
|
||||
$this->RegisterAttributeInteger('LetzteVorgabeZeit', 0);
|
||||
$this->RegisterAttributeInteger('LetzterGesetzterStrom', -1);
|
||||
$this->RegisterAttributeBoolean('LadestartFuerVerbindungGesendet', false);
|
||||
$this->RegisterAttributeString('LetzterGeraetebefehl', '');
|
||||
$this->RegisterAttributeString('LetzterStartbefehl', '');
|
||||
|
||||
$this->RegisterTimer(
|
||||
'Meldezyklus',
|
||||
@@ -128,6 +141,7 @@ class LadestationGateway extends IPSModule implements VerbraucherSchnittstelle
|
||||
$this->aktualisiereVariablen();
|
||||
$this->WriteAttributeBoolean('GatewayVerbunden', false);
|
||||
$this->WriteAttributeInteger('LetzterGesetzterStrom', -1);
|
||||
$this->WriteAttributeBoolean('LadestartFuerVerbindungGesendet', false);
|
||||
|
||||
try {
|
||||
$this->pruefeKonfiguration();
|
||||
@@ -405,6 +419,11 @@ class LadestationGateway extends IPSModule implements VerbraucherSchnittstelle
|
||||
'Phasenzahl',
|
||||
'Istleistung_W',
|
||||
'Ladestrom_A',
|
||||
'EaseeAktiviert',
|
||||
'AutorisierungErforderlich',
|
||||
'RemoteStartErforderlich',
|
||||
'SmartCharging',
|
||||
'GrundKeinLadestrom',
|
||||
] as $feld) {
|
||||
$this->setzeZustand($feld, $status[$feld]);
|
||||
}
|
||||
@@ -416,6 +435,9 @@ class LadestationGateway extends IPSModule implements VerbraucherSchnittstelle
|
||||
'ApiMaximalstrom',
|
||||
$status['ApiMaximalstrom_A']
|
||||
);
|
||||
if (!$status['FahrzeugVerbunden']) {
|
||||
$this->WriteAttributeBoolean('LadestartFuerVerbindungGesendet', false);
|
||||
}
|
||||
|
||||
$gatewayVerbunden = $this->ReadAttributeBoolean('GatewayVerbunden');
|
||||
$phaseGueltig = in_array($status['Phasenzahl'], [1, 3], true);
|
||||
@@ -423,6 +445,7 @@ class LadestationGateway extends IPSModule implements VerbraucherSchnittstelle
|
||||
$phaseErforderlich = $status['Fahrzeugstatus'] === 3;
|
||||
$steuerbar = $gatewayVerbunden
|
||||
&& $status['StatusGueltig']
|
||||
&& $status['EaseeAktiviert']
|
||||
&& !$status['Stoerung']
|
||||
&& (!$phaseErforderlich || $phaseGueltig);
|
||||
|
||||
@@ -473,7 +496,8 @@ class LadestationGateway extends IPSModule implements VerbraucherSchnittstelle
|
||||
if ($gatewayVerbunden && $status['StatusGueltig']) {
|
||||
$this->setzeLadestrom(
|
||||
$this->bestimmeWirksameSollleistung($angebot),
|
||||
$regelPhasenzahl
|
||||
$regelPhasenzahl,
|
||||
$status['Fahrzeugstatus'] === 2
|
||||
);
|
||||
} else {
|
||||
$this->WriteAttributeInteger('LetzterGesetzterStrom', -1);
|
||||
@@ -512,34 +536,64 @@ class LadestationGateway extends IPSModule implements VerbraucherSchnittstelle
|
||||
return 0;
|
||||
}
|
||||
|
||||
private function setzeLadestrom(int $leistung, int $phasenzahl): void
|
||||
{
|
||||
private function setzeLadestrom(
|
||||
int $leistung,
|
||||
int $phasenzahl,
|
||||
bool $wartetAufStart
|
||||
): void {
|
||||
$strom = $leistung === 0
|
||||
? 0
|
||||
: LadestationRegler::stromFuerLeistung($leistung, $phasenzahl);
|
||||
if ($strom === $this->ReadAttributeInteger('LetzterGesetzterStrom')) {
|
||||
return;
|
||||
if ($strom !== $this->ReadAttributeInteger('LetzterGesetzterStrom')) {
|
||||
$antwort = $this->gatewayAnfrage([
|
||||
'action' => 'SetDynamicChargerCurrent',
|
||||
'serialNumber' => $this->seriennummer(),
|
||||
'amps' => $strom,
|
||||
]);
|
||||
if (!($antwort['success'] ?? false)) {
|
||||
throw new RuntimeException(
|
||||
(string) ($antwort['error'] ?? 'Easee-Stromvorgabe fehlgeschlagen.')
|
||||
);
|
||||
}
|
||||
|
||||
$befehl = json_encode([
|
||||
'Aktion' => 'SetDynamicChargerCurrent',
|
||||
'Seriennummer' => $this->seriennummer(),
|
||||
'Ampere' => $strom,
|
||||
], JSON_THROW_ON_ERROR);
|
||||
$this->WriteAttributeString('LetzterGeraetebefehl', $befehl);
|
||||
$this->setzeSichtbareVariable('LetzterGeraetebefehl', $befehl);
|
||||
$this->WriteAttributeInteger('LetzterGesetzterStrom', $strom);
|
||||
}
|
||||
|
||||
if (
|
||||
$strom > 0
|
||||
&& $wartetAufStart
|
||||
&& !$this->ReadAttributeBoolean('LadestartFuerVerbindungGesendet')
|
||||
) {
|
||||
$this->sendeLadestart();
|
||||
}
|
||||
}
|
||||
|
||||
private function sendeLadestart(): void
|
||||
{
|
||||
$antwort = $this->gatewayAnfrage([
|
||||
'action' => 'SetDynamicChargerCurrent',
|
||||
'action' => 'StartCharging',
|
||||
'serialNumber' => $this->seriennummer(),
|
||||
'amps' => $strom,
|
||||
]);
|
||||
if (!($antwort['success'] ?? false)) {
|
||||
throw new RuntimeException(
|
||||
(string) ($antwort['error'] ?? 'Easee-Stromvorgabe fehlgeschlagen.')
|
||||
(string) ($antwort['error'] ?? 'Easee-Ladestart fehlgeschlagen.')
|
||||
);
|
||||
}
|
||||
|
||||
$befehl = json_encode([
|
||||
'Aktion' => 'SetDynamicChargerCurrent',
|
||||
'Aktion' => 'StartCharging',
|
||||
'Seriennummer' => $this->seriennummer(),
|
||||
'Ampere' => $strom,
|
||||
], JSON_THROW_ON_ERROR);
|
||||
$this->WriteAttributeString('LetzterGeraetebefehl', $befehl);
|
||||
$this->setzeSichtbareVariable('LetzterGeraetebefehl', $befehl);
|
||||
$this->WriteAttributeInteger('LetzterGesetzterStrom', $strom);
|
||||
$this->WriteAttributeBoolean('LadestartFuerVerbindungGesendet', true);
|
||||
$this->WriteAttributeString('LetzterStartbefehl', $befehl);
|
||||
$this->setzeSichtbareVariable('LetzterStartbefehl', $befehl);
|
||||
}
|
||||
|
||||
private function seriennummer(): string
|
||||
@@ -650,6 +704,36 @@ class LadestationGateway extends IPSModule implements VerbraucherSchnittstelle
|
||||
'Wert' => $this->ReadAttributeBoolean('ZustandSolarladen'),
|
||||
'Einheit' => '',
|
||||
],
|
||||
[
|
||||
'Kennung' => 'EaseeAktiviert',
|
||||
'Art' => 'Status',
|
||||
'Wert' => (bool) $this->leseZustand('EaseeAktiviert'),
|
||||
'Einheit' => '',
|
||||
],
|
||||
[
|
||||
'Kennung' => 'AutorisierungErforderlich',
|
||||
'Art' => 'Status',
|
||||
'Wert' => (bool) $this->leseZustand('AutorisierungErforderlich'),
|
||||
'Einheit' => '',
|
||||
],
|
||||
[
|
||||
'Kennung' => 'RemoteStartErforderlich',
|
||||
'Art' => 'Status',
|
||||
'Wert' => (bool) $this->leseZustand('RemoteStartErforderlich'),
|
||||
'Einheit' => '',
|
||||
],
|
||||
[
|
||||
'Kennung' => 'SmartCharging',
|
||||
'Art' => 'Status',
|
||||
'Wert' => (bool) $this->leseZustand('SmartCharging'),
|
||||
'Einheit' => '',
|
||||
],
|
||||
[
|
||||
'Kennung' => 'GrundKeinLadestrom',
|
||||
'Art' => 'Status',
|
||||
'Wert' => (int) $this->leseZustand('GrundKeinLadestrom'),
|
||||
'Einheit' => '',
|
||||
],
|
||||
[
|
||||
'Kennung' => 'Ladefehler',
|
||||
'Art' => 'Stoerung',
|
||||
@@ -815,17 +899,53 @@ class LadestationGateway extends IPSModule implements VerbraucherSchnittstelle
|
||||
'',
|
||||
210
|
||||
);
|
||||
$this->RegisterVariableBoolean(
|
||||
'EaseeAktiviert',
|
||||
'Easee aktiviert',
|
||||
'~Switch',
|
||||
220
|
||||
);
|
||||
$this->RegisterVariableBoolean(
|
||||
'AutorisierungErforderlich',
|
||||
'Autorisierung erforderlich',
|
||||
'~Switch',
|
||||
230
|
||||
);
|
||||
$this->RegisterVariableBoolean(
|
||||
'RemoteStartErforderlich',
|
||||
'Remote-Start erforderlich',
|
||||
'~Switch',
|
||||
240
|
||||
);
|
||||
$this->RegisterVariableBoolean(
|
||||
'SmartCharging',
|
||||
'Easee Smart Charging',
|
||||
'~Switch',
|
||||
250
|
||||
);
|
||||
$this->RegisterVariableInteger(
|
||||
'GrundKeinLadestrom',
|
||||
'Grund kein Ladestrom',
|
||||
'',
|
||||
260
|
||||
);
|
||||
$this->RegisterVariableString(
|
||||
'LetzterGeraetebefehl',
|
||||
'Letzter Geraetebefehl',
|
||||
'',
|
||||
220
|
||||
270
|
||||
);
|
||||
$this->RegisterVariableString(
|
||||
'LetzterStartbefehl',
|
||||
'Letzter Startbefehl',
|
||||
'',
|
||||
280
|
||||
);
|
||||
$this->RegisterVariableString(
|
||||
'LeistungsangebotDiagnose',
|
||||
'Leistungsangebot',
|
||||
'',
|
||||
230
|
||||
290
|
||||
);
|
||||
$this->SetValue(
|
||||
'LeistungsangebotDiagnose',
|
||||
@@ -835,11 +955,16 @@ class LadestationGateway extends IPSModule implements VerbraucherSchnittstelle
|
||||
'LetzterGeraetebefehl',
|
||||
$this->ReadAttributeString('LetzterGeraetebefehl')
|
||||
);
|
||||
$this->SetValue(
|
||||
'LetzterStartbefehl',
|
||||
$this->ReadAttributeString('LetzterStartbefehl')
|
||||
);
|
||||
foreach (self::DIAGNOSE_VARIABLEN as $ident) {
|
||||
if (!in_array($ident, [
|
||||
'GatewayVerbunden',
|
||||
'ApiMaximalstrom',
|
||||
'LetzterGeraetebefehl',
|
||||
'LetzterStartbefehl',
|
||||
'LeistungsangebotDiagnose',
|
||||
], true)) {
|
||||
$this->setzeSichtbareVariable($ident, $this->leseZustand($ident));
|
||||
@@ -874,6 +999,10 @@ class LadestationGateway extends IPSModule implements VerbraucherSchnittstelle
|
||||
switch ($ident) {
|
||||
case 'FahrzeugVerbunden':
|
||||
case 'FahrzeugGeladen':
|
||||
case 'EaseeAktiviert':
|
||||
case 'AutorisierungErforderlich':
|
||||
case 'RemoteStartErforderlich':
|
||||
case 'SmartCharging':
|
||||
case 'SollwertGueltig':
|
||||
case 'Verfuegbar':
|
||||
case 'AenderungMoeglich':
|
||||
@@ -882,6 +1011,7 @@ class LadestationGateway extends IPSModule implements VerbraucherSchnittstelle
|
||||
break;
|
||||
case 'Fahrzeugstatus':
|
||||
case 'Phasenzahl':
|
||||
case 'GrundKeinLadestrom':
|
||||
case 'Sollleistung':
|
||||
$this->WriteAttributeInteger('Zustand' . $ident, (int) $wert);
|
||||
break;
|
||||
@@ -917,6 +1047,10 @@ class LadestationGateway extends IPSModule implements VerbraucherSchnittstelle
|
||||
if (in_array($ident, [
|
||||
'FahrzeugVerbunden',
|
||||
'FahrzeugGeladen',
|
||||
'EaseeAktiviert',
|
||||
'AutorisierungErforderlich',
|
||||
'RemoteStartErforderlich',
|
||||
'SmartCharging',
|
||||
'SollwertGueltig',
|
||||
'Verfuegbar',
|
||||
'AenderungMoeglich',
|
||||
@@ -927,6 +1061,7 @@ class LadestationGateway extends IPSModule implements VerbraucherSchnittstelle
|
||||
if (in_array($ident, [
|
||||
'Fahrzeugstatus',
|
||||
'Phasenzahl',
|
||||
'GrundKeinLadestrom',
|
||||
'Sollleistung',
|
||||
], true)) {
|
||||
return $this->ReadAttributeInteger('Zustand' . $ident);
|
||||
|
||||
Reference in New Issue
Block a user