From 3bc5e59054d50fb30172a1070649c6111414d66e Mon Sep 17 00:00:00 2001 From: "belevo\\mh" Date: Wed, 19 Nov 2025 13:32:19 +0100 Subject: [PATCH] no message --- VGT_Sub/module.php | 68 +++------------------------------------------- 1 file changed, 4 insertions(+), 64 deletions(-) diff --git a/VGT_Sub/module.php b/VGT_Sub/module.php index ca2ac1f..bf5cd08 100644 --- a/VGT_Sub/module.php +++ b/VGT_Sub/module.php @@ -152,28 +152,13 @@ class VGT_Sub extends IPSModule * ------------------------------------------*/ public function ReceiveData($JSONString) { - // äußere Hülle vom MQTT-Client - $data = json_decode($JSONString); - if ($data === null) { - $this->SendDebug('MQTT', 'Ungültiges JSON: ' . $JSONString, 0); + $data = json_decode($JSONString, true); + if (!is_array($data)) { return; } - // aktuelles MQTT-Client-Format: Topic/Payload stecken in Buffer - if (isset($data->Buffer)) { - $buffer = json_decode($data->Buffer, true); - } else { - // Fallback auf direkte Struktur - $buffer = json_decode($JSONString, true); - } - - if (!is_array($buffer)) { - $this->SendDebug('MQTT', 'Buffer ist kein Array: ' . print_r($buffer, true), 0); - return; - } - - $topic = $buffer['Topic'] ?? ''; - $payload = $buffer['Payload'] ?? ''; + $topic = $data['Topic'] ?? ''; + $payload = $data['Payload'] ?? ''; $this->SendDebug('MQTT', 'Receive: Topic=' . $topic . ' Payload=' . $payload, 0); @@ -182,51 +167,6 @@ class VGT_Sub extends IPSModule return; } - // 1) feedback-request/ - if ($topic === "feedback-request/$device") { - - $this->SetValue('FeedbackRequestPayload', $payload); - - $json = json_decode($payload, true); - if (!is_array($json)) { - $json = []; - } - - $response = array_merge($json, [ - "power_production" => $this->GetValue('PowerProduction'), - "is_ready" => $this->GetValue('IsReady'), - "is_running" => $this->GetValue('IsRunning'), - "state_of_charge" => $this->GetValue('StateOfCharge'), - "min_soc" => $this->GetValue('MinSOC'), - "max_soc" => $this->GetValue('MaxSOC') - ]); - - $this->Publish("feedback-response/$device", json_encode($response)); - return; - } - - // 2) remote-control-request/ - if ($topic === "remote-control-request/$device") { - - $this->SetValue('RemoteControlPayload', $payload); - - $json = json_decode($payload, true); - if (is_array($json)) { - - if (array_key_exists('power_setpoint', $json)) { - $this->SetValue('PowerSetpoint', (int)$json['power_setpoint']); - } - - if (array_key_exists('strategy', $json)) { - $this->SetValue('Strategy', (string)$json['strategy']); - } - } - - $this->Publish("remote-control-response/$device", $payload); - return; - } - } - /** ------------------------------------------- * 1️⃣ FEEDBACK REQUEST * ------------------------------------------*/