no message

This commit is contained in:
2026-05-26 13:48:43 +02:00
parent 23b5ef6eed
commit 296df5aee0
+33 -13
View File
@@ -408,25 +408,45 @@ class MQTTBatterySDL extends IPSModule
}
}
private function PublishMQTT(string $topic, string $payload)
{
sleep(1);
$this->SendDebug(
'PublishMQTT',
$topic . ' => ' . $payload,
0
);
$this->SendDataToParent(json_encode([
'DataID' => '{018EF6B5-AB94-40C6-AA53-46943E824ACF}',
private function PublishMQTT(string $topic, string $payload)
{
$this->SafeSend([
'DataID' => '{043EA491-0325-4ADD-8FC2-A30C8EEB4D3F}',
'PacketType' => 3,
'Payload' => $payload,
'QualityOfService' => 0,
'Retain' => false,
'Topic' => $topic
]));
'Topic' => $topic,
'Payload' => $payload
]);
$this->SendDebug('PublishMQTT', $topic . ' → ' . $payload, 0);
}
private function SafeSend(array $packet)
{
$parent = @IPS_GetInstance($this->InstanceID)['ConnectionID'] ?? 0;
if ($parent === 0 || !IPS_InstanceExists($parent)) {
$this->SendDebug('SafeSend', 'Kein Parent vorhanden', 0);
return;
}
if (IPS_GetInstance($parent)['InstanceStatus'] !== 102) {
$this->SendDebug('SafeSend', 'Parent nicht aktiv', 0);
return;
}
@$this->SendDataToParent(json_encode($packet));
}
private function IsValidVariable(int $id)
{
return (