diff --git a/MQTTBatterySDL/form.json b/MQTTBatterySDL/form.json index 29254cd..15351e6 100644 --- a/MQTTBatterySDL/form.json +++ b/MQTTBatterySDL/form.json @@ -10,11 +10,6 @@ "name": "ReqActionID", "caption": "Ausgabe-Variable / Nennleistung" }, - { - "type": "SelectInstance", - "name": "PublishInstanceID", - "caption": "MQTT Publish Helper" - }, { "type": "SelectVariable", "name": "SoCID", diff --git a/MQTTBatterySDL/module.php b/MQTTBatterySDL/module.php index 094c4cb..a903433 100644 --- a/MQTTBatterySDL/module.php +++ b/MQTTBatterySDL/module.php @@ -13,7 +13,7 @@ class MQTTBatterySDL extends IPSModule $this->RegisterPropertyInteger('ReqActionID', 0); $this->RegisterPropertyInteger('SoCID', 0); $this->RegisterPropertyInteger('PowerProductionID', 0); - $this->RegisterPropertyInteger('PublishInstanceID', 0); + //$this->RegisterPropertyInteger('PublishInstanceID', 0); $this->RegisterPropertyFloat('TargetSoC', 50); $this->RegisterPropertyInteger('ChargePower', 2500); @@ -474,6 +474,32 @@ class MQTTBatterySDL extends IPSModule $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->SendDebug('Publish', $topic . ' => ' . $payload, 0); + + $this->SendDataToParent(json_encode([ + 'DataID' => '{043EA491-0325-4ADD-8FC2-A30C8EEB4D3F}', + 'PacketType' => 3, + 'QualityOfService' => 0, + 'Retain' => false, + 'Topic' => $topic, + 'Payload' => $payload + ])); +} +/* Von DH auskommentiert am 2.6. public function DoDelayedPublish() { $this->SetTimerInterval('PublishDelay', 0); @@ -490,7 +516,7 @@ public function DoDelayedPublish() $this->PublishViaHelper($topic, $payload); } - +*/ /* private function SafeSend(array $packet)