no message

This commit is contained in:
2026-05-26 14:15:38 +02:00
parent 0ee07ca27c
commit 2f730a722a
+32 -2
View File
@@ -38,6 +38,10 @@ class MQTTBatterySDL extends IPSModule
// MQTT Parent verbinden
$this->ConnectParent('{F7A0DD2E-7684-95C0-64C2-D2A9DC47577B}');
$this->RegisterTimer('PublishDelay', 0, 'MBSDL_DoDelayedPublish($_IPS["TARGET"]);');
$this->SetBuffer('PublishTopic', '');
$this->SetBuffer('PublishPayload', '');
}
public function ApplyChanges()
@@ -381,7 +385,7 @@ class MQTTBatterySDL extends IPSModule
$json = $this->BuildReadResponse();
$this->PublishViaHelper(
$this->QueuePublish(
'feedback-response/' . $suffix,
$json
);
@@ -399,7 +403,7 @@ class MQTTBatterySDL extends IPSModule
if ($json !== null) {
$this->PublishViaHelper(
$this->QueuePublish(
'remote-control-response/' . $suffix,
$json
);
@@ -440,6 +444,32 @@ class MQTTBatterySDL extends IPSModule
}
private function QueuePublish(string $topic, string $payload)
{
$this->SetBuffer('PublishTopic', $topic);
$this->SetBuffer('PublishPayload', $payload);
$this->SetTimerInterval('PublishDelay', 500);
}
public function DoDelayedPublish()
{
$this->SetTimerInterval('PublishDelay', 0);
$topic = $this->GetBuffer('PublishTopic');
$payload = $this->GetBuffer('PublishPayload');
$this->SetBuffer('PublishTopic', '');
$this->SetBuffer('PublishPayload', '');
if ($topic == '' || $payload == '') {
return;
}
$this->PublishViaHelper($topic, $payload);
}
private function SafeSend(array $packet)
{