no message

This commit is contained in:
2025-11-28 08:37:19 +01:00
parent 5ba0650c00
commit 0c587fd67a

View File

@@ -10,7 +10,7 @@ class VGT_Sub extends IPSModule
$this->RegisterPropertyString('DeviceID', ''); $this->RegisterPropertyString('DeviceID', '');
// Status Variablen // Status Variablen (editable)
$this->RegisterVariableFloat('PowerProduction', 'Power Production', '', 10); $this->RegisterVariableFloat('PowerProduction', 'Power Production', '', 10);
$this->EnableAction('PowerProduction'); $this->EnableAction('PowerProduction');
@@ -29,7 +29,7 @@ class VGT_Sub extends IPSModule
$this->RegisterVariableFloat('MaxSoc', 'Max SoC', '', 15); $this->RegisterVariableFloat('MaxSoc', 'Max SoC', '', 15);
$this->EnableAction('MaxSoc'); $this->EnableAction('MaxSoc');
// Remote-control readonly Variablen // Remote control readonly variables
$this->RegisterVariableInteger('PowerSetpoint', 'Power Setpoint', '', 30); $this->RegisterVariableInteger('PowerSetpoint', 'Power Setpoint', '', 30);
IPS_SetVariableCustomAction($this->GetIDForIdent('PowerSetpoint'), 0); IPS_SetVariableCustomAction($this->GetIDForIdent('PowerSetpoint'), 0);
@@ -41,7 +41,7 @@ class VGT_Sub extends IPSModule
{ {
parent::ApplyChanges(); parent::ApplyChanges();
// Richtiger Parent // Correct Parent: MQTTClientSplitter
$this->ConnectParent('{F7A0DD2E-7684-95C0-64C2-D2A9DC47577B}'); $this->ConnectParent('{F7A0DD2E-7684-95C0-64C2-D2A9DC47577B}');
$this->SubscribeTopics(); $this->SubscribeTopics();
@@ -60,11 +60,11 @@ class VGT_Sub extends IPSModule
]; ];
foreach ($topics as $topic) { foreach ($topics as $topic) {
$this->SendDebug("Subscribe", $topic, 0); $this->SendDebug("SUBSCRIBE", $topic, 0);
$this->SendDataToParent(json_encode([ $this->SendDataToParent(json_encode([
"DataID" => "{F7A0DD2E-7684-95C0-64C2-D2A9DC47577B}", "DataID" => "{F7A0DD2E-7684-95C0-64C2-D2A9DC47577B}",
"PacketType" => 8, // Subscribe "PacketType" => 8, // SUBSCRIBE
"Topic" => $topic, "Topic" => $topic,
"QoS" => 0 "QoS" => 0
])); ]));
@@ -82,19 +82,17 @@ class VGT_Sub extends IPSModule
$topic = $data['Topic']; $topic = $data['Topic'];
$payload = $data['Payload']; $payload = $data['Payload'];
$this->SendDebug("RX Topic", $topic, 0); $this->SendDebug("RX TOPIC", $topic, 0);
$this->SendDebug("RX Payload", $payload, 0); $this->SendDebug("RX PAYLOAD", $payload, 0);
$device = $this->ReadPropertyString('DeviceID'); $device = $this->ReadPropertyString('DeviceID');
if ($topic === "feedback-request/$device") { if ($topic === "feedback-request/$device") {
$this->HandleFeedbackRequest($device); $this->HandleFeedbackRequest($device);
return;
} }
if ($topic === "remote-control-request/$device") { if ($topic === "remote-control-request/$device") {
$this->HandleRemoteControlRequest($device, $payload); $this->HandleRemoteControlRequest($device, $payload);
return;
} }
} }
@@ -109,15 +107,14 @@ class VGT_Sub extends IPSModule
"max_soc" => GetValue($this->GetIDForIdent('MaxSoc')) "max_soc" => GetValue($this->GetIDForIdent('MaxSoc'))
]; ];
$json = json_encode($response); $json = json_encode($response);
$topic = "feedback-response/$device"; $topic = "feedback-response/$device";
$this->SendDebug("TX Feedback", $json, 0); $this->SendDebug("TX FEEDBACK", $json, 0);
// RAW MQTT Publish
$this->SendDataToParent(json_encode([ $this->SendDataToParent(json_encode([
"DataID" => "{F7A0DD2E-7684-95C0-64C2-D2A9DC47577B}", "DataID" => "{F7A0DD2E-7684-95C0-64C2-D2A9DC47577B}",
"PacketType" => 3, // Publish "PacketType" => 3, // PUBLISH
"Topic" => $topic, "Topic" => $topic,
"Payload" => $json, "Payload" => $json,
"QoS" => 0, "QoS" => 0,
@@ -129,7 +126,7 @@ class VGT_Sub extends IPSModule
{ {
$json = @json_decode($payload, true); $json = @json_decode($payload, true);
if (!is_array($json)) { if (!is_array($json)) {
$this->SendDebug("Error", "Ungültiges JSON", 0); $this->SendDebug("ERROR", "Ungültiges JSON", 0);
return; return;
} }
@@ -141,12 +138,11 @@ class VGT_Sub extends IPSModule
SetValueString($this->GetIDForIdent('Strategy'), (string)$json['strategy']); SetValueString($this->GetIDForIdent('Strategy'), (string)$json['strategy']);
} }
$topic = "remote-control-response/$device";
$payloadOut = json_encode($json); $payloadOut = json_encode($json);
$topic = "remote-control-response/$device";
$this->SendDebug("TX RemoteControl", $payloadOut, 0); $this->SendDebug("TX REMOTE", $payloadOut, 0);
// RAW MQTT Publish
$this->SendDataToParent(json_encode([ $this->SendDataToParent(json_encode([
"DataID" => "{F7A0DD2E-7684-95C0-64C2-D2A9DC47577B}", "DataID" => "{F7A0DD2E-7684-95C0-64C2-D2A9DC47577B}",
"PacketType" => 3, "PacketType" => 3,