fix(ladestation): Ladeanlauf und Easee-Verbindung stabilisieren
Tests / test (push) Successful in 1m23s

This commit is contained in:
dh
2026-09-29 12:25:35 +00:00
parent a74f14aa19
commit b3b868cd2a
5 changed files with 91 additions and 10 deletions
+29 -3
View File
@@ -16,6 +16,7 @@ class EaseeGateway extends IPSModule
private const SIGNALR_BASE_URL = 'https://streams.easee.com/hubs/chargers';
private const API_BASE_URL = 'https://api.easee.com';
private const RECORD_SEPARATOR = "\x1e";
private const CACHE_MAXIMALALTER_SEKUNDEN = 60;
public function Create(): void
{
@@ -112,7 +113,10 @@ class EaseeGateway extends IPSModule
return;
case 'RefreshToken':
if ($this->erneuereZugangsdaten(false)) {
if (
$this->erneuereZugangsdaten(false)
&& $this->GetBuffer('SignalRReady') !== '1'
) {
$this->verbindeSignalR();
}
return;
@@ -346,7 +350,7 @@ class EaseeGateway extends IPSModule
$this->SetBuffer('ReceiveBuffer', '');
$this->SetBuffer('SubscribedThisConnection', '{}');
$this->SetBuffer('PendingInvocations', '{}');
$this->WriteAttributeString('ObservationCache', '{}');
$this->markiereBeobachtungscacheVeraltet();
$this->setzeVerbunden(false);
if (!$this->konfiguriereWebSocketParent($url)) {
@@ -572,12 +576,30 @@ class EaseeGateway extends IPSModule
);
}
private function markiereBeobachtungscacheVeraltet(): void
{
$cache = $this->leseAttributArray('ObservationCache');
foreach ($cache as &$zustand) {
if (is_array($zustand)) {
$zustand['updated'] = 0;
}
}
unset($zustand);
$this->WriteAttributeString(
'ObservationCache',
json_encode($cache, JSON_THROW_ON_ERROR)
);
}
private function stelleAktuellenStatusSicher(string $seriennummer): void
{
$cache = $this->leseAttributArray('ObservationCache');
$zustand = $cache[$seriennummer] ?? [];
$cacheIstAktuell = is_array($zustand)
&& array_key_exists('109', $zustand)
&& (int) ($zustand['updated'] ?? 0) >= time() - self::CACHE_MAXIMALALTER_SEKUNDEN;
if (
(is_array($zustand) && array_key_exists('109', $zustand))
$cacheIstAktuell
|| $this->ReadPropertyBoolean('Testmodus')
|| $this->GetBuffer('SignalRReady') !== '1'
) {
@@ -848,7 +870,11 @@ class EaseeGateway extends IPSModule
private function setzeVerbunden(bool $verbunden): void
{
$warVerbunden = (bool) $this->GetValue('Connected');
$this->SetValue('Connected', $verbunden);
if ($warVerbunden === $verbunden) {
return;
}
$this->SendDataToChildren(json_encode([
'DataID' => self::CHILD_EVENT_DATA_ID,
'Buffer' => json_encode([