From 6b8db1acecd624c9d76f6234e41e7060fef6d542 Mon Sep 17 00:00:00 2001 From: DanielHaefliger Date: Tue, 25 Aug 2026 16:59:15 +0200 Subject: [PATCH] no message --- Ladestation/module.php | 51 +++++++----------------------- Ladestation_v2/module.php | 66 ++++++++++----------------------------- 2 files changed, 28 insertions(+), 89 deletions(-) diff --git a/Ladestation/module.php b/Ladestation/module.php index 09549c8..e1a78ff 100644 --- a/Ladestation/module.php +++ b/Ladestation/module.php @@ -69,17 +69,6 @@ class Ladestation extends IPSModule IPS_SetHidden($this->GetIDForIdent("Is_Peak_Shaving") , true); $this->RegisterVariableInteger("Leistung_Delta", "Leistung_Delta", "", 0); IPS_SetHidden($this->GetIDForIdent("Leistung_Delta") , true); - $this->RegisterVariableBoolean( - "Easee_Gateway_Connected", - "Easee Gateway verbunden", - "~Switch", - false - ); - IPS_SetHidden( - $this->GetIDForIdent("Easee_Gateway_Connected"), - true - ); - $this->SetBuffer("EaseeGatewayState", "{}"); $this->RegisterVariableString("Token_Intern", "Internes Token Easee"); IPS_SetHidden($this->GetIDForIdent("Token_Intern") , true); // Hilfsvariabeln für Idle zustand @@ -97,34 +86,26 @@ $this->RegisterVariableString("Token_Intern", "Internes Token Easee"); public function ApplyChanges() { parent::ApplyChanges(); - - $this->RegisterVariableBoolean( - "Easee_Gateway_Connected", - "Easee Gateway verbunden", - "~Switch", - false - ); $this->SetTimerInterval( "Timer_Do_UserCalc_EVC", $this->ReadPropertyInteger("Interval") * 1000 ); - $this->SetTimerInterval("Timer_Refresh_Token", 0); $stationType = $this->ReadPropertyInteger("Ladestation"); - $usesEaseeGateway = $this->UsesEaseeGateway($stationType); - IPS_SetHidden( - $this->GetIDForIdent("Easee_Gateway_Connected"), - !$usesEaseeGateway - ); + if (!$this->UsesEaseeGateway($stationType)) { + return; + } - if ( - $usesEaseeGateway && - $this->GetConfiguredEaseeGatewayID() > 0 - ) { + $this->SetTimerInterval("Timer_Refresh_Token", 0); + if ($this->GetConfiguredEaseeGatewayID() <= 0) { + return; + } + + try { $this->SubscribeToEaseeGateway(); $this->GetEaseeStateFromGateway(); - } else { - $this->SetValue("Easee_Gateway_Connected", false); + } catch (Throwable $exception) { + return; } } @@ -957,7 +938,6 @@ $this->RegisterVariableString("Token_Intern", "Internes Token Easee"); $gatewayID <= 0 || !function_exists("EASEEGW_ProcessStationRequest") ) { - $this->SetValue("Easee_Gateway_Connected", false); return null; } @@ -985,17 +965,9 @@ $this->RegisterVariableString("Token_Intern", "Internes Token Easee"); private function ApplyEaseeGatewayResponse($response) { if (!is_array($response)) { - $this->SetValue("Easee_Gateway_Connected", false); return; } - if (array_key_exists("connected", $response)) { - $this->SetValue( - "Easee_Gateway_Connected", - (bool)$response["connected"] - ); - } - if (!isset($response["state"]) || !is_array($response["state"])) { return; } @@ -1137,4 +1109,3 @@ $this->RegisterVariableString("Token_Intern", "Internes Token Easee"); } } ?> - diff --git a/Ladestation_v2/module.php b/Ladestation_v2/module.php index 7de3fed..391c377 100644 --- a/Ladestation_v2/module.php +++ b/Ladestation_v2/module.php @@ -92,17 +92,6 @@ class Ladestation_v2 extends IPSModule $this->RegisterVariableInteger("Leistung_Delta", "Leistung_Delta", "", 0); IPS_SetHidden($this->GetIDForIdent("Leistung_Delta"), true); - $this->RegisterVariableBoolean( - "Easee_Gateway_Connected", - "Easee Gateway verbunden", - "~Switch", - false - ); - IPS_SetHidden( - $this->GetIDForIdent("Easee_Gateway_Connected"), - true - ); - $this->SetBuffer("EaseeGatewayState", "{}"); $this->RegisterVariableString("Token_Intern", "Internes Token Easee"); IPS_SetHidden($this->GetIDForIdent("Token_Intern"), true); @@ -121,45 +110,38 @@ $this->RegisterVariableString("Token_Intern", "Internes Token Easee"); $this->RegisterVariableInteger("Mindestaldestrom", "Mindestaldestrom", "", 0); $this->EnableAction("Mindestaldestrom"); - $this->ConnectParent(self::EASEE_GATEWAY_MODULE_ID); } public function ApplyChanges() { parent::ApplyChanges(); - - $this->RegisterVariableBoolean( - "Easee_Gateway_Connected", - "Easee Gateway verbunden", - "~Switch", - false - ); $this->SetTimerInterval( "Timer_Do_UserCalc_EVC", $this->ReadPropertyInteger("Interval") * 1000 ); - $this->SetTimerInterval("Timer_Refresh_Token", 0); $stationType = $this->ReadPropertyInteger("Ladestation"); - $usesEaseeGateway = $this->UsesEaseeGateway($stationType); - IPS_SetHidden( - $this->GetIDForIdent("Easee_Gateway_Connected"), - !$usesEaseeGateway - ); - - $instance = IPS_GetInstance($this->InstanceID); - $parentID = (int)$instance["ConnectionID"]; - if ($parentID <= 0) { - $this->ConnectParent(self::EASEE_GATEWAY_MODULE_ID); - $instance = IPS_GetInstance($this->InstanceID); - $parentID = (int)$instance["ConnectionID"]; + if (!$this->UsesEaseeGateway($stationType)) { + return; } - if ($usesEaseeGateway && $this->IsEaseeGatewayInstance($parentID)) { + $this->SetTimerInterval("Timer_Refresh_Token", 0); + try { + $instance = IPS_GetInstance($this->InstanceID); + $parentID = (int)$instance["ConnectionID"]; + if ($parentID <= 0) { + $this->ConnectParent(self::EASEE_GATEWAY_MODULE_ID); + $instance = IPS_GetInstance($this->InstanceID); + $parentID = (int)$instance["ConnectionID"]; + } + + if (!$this->IsEaseeGatewayInstance($parentID)) { + return; + } $this->SubscribeToEaseeGateway(); $this->GetEaseeStateFromGateway(); - } else { - $this->SetValue("Easee_Gateway_Connected", false); + } catch (Throwable $exception) { + return; } } @@ -308,10 +290,6 @@ $this->RegisterVariableString("Token_Intern", "Internes Token Easee"); } if ($message["type"] === "GatewayStatus") { - $this->SetValue( - "Easee_Gateway_Connected", - (bool)($message["connected"] ?? false) - ); return; } @@ -1057,7 +1035,6 @@ $this->RegisterVariableString("Token_Intern", "Internes Token Easee"); $instance = IPS_GetInstance($this->InstanceID); $parentID = (int)$instance["ConnectionID"]; if (!$this->IsEaseeGatewayInstance($parentID)) { - $this->SetValue("Easee_Gateway_Connected", false); return null; } @@ -1077,17 +1054,9 @@ $this->RegisterVariableString("Token_Intern", "Internes Token Easee"); private function ApplyEaseeGatewayResponse($response) { if (!is_array($response)) { - $this->SetValue("Easee_Gateway_Connected", false); return; } - if (array_key_exists("connected", $response)) { - $this->SetValue( - "Easee_Gateway_Connected", - (bool)$response["connected"] - ); - } - if (!isset($response["state"]) || !is_array($response["state"])) { return; } @@ -1227,4 +1196,3 @@ $this->RegisterVariableString("Token_Intern", "Internes Token Easee"); } ?> -