diff --git a/MQTTBatterySDL/module.php b/MQTTBatterySDL/module.php index a89973b..0dd1f1f 100644 --- a/MQTTBatterySDL/module.php +++ b/MQTTBatterySDL/module.php @@ -13,6 +13,7 @@ class MQTTBatterySDL extends IPSModule $this->RegisterPropertyInteger('ReqActionID', 0); $this->RegisterPropertyInteger('SoCID', 0); $this->RegisterPropertyInteger('PowerProductionID', 0); + $this->RegisterPropertyInteger('PublishInstanceID', 0); $this->RegisterPropertyInteger('TargetSoC', 50); $this->RegisterPropertyInteger('ChargePower', 2500); @@ -380,7 +381,7 @@ class MQTTBatterySDL extends IPSModule $json = $this->BuildReadResponse(); - $this->PublishMQTT( + $this->PublishViaHelper( 'feedback-response/' . $suffix, $json ); @@ -398,10 +399,10 @@ class MQTTBatterySDL extends IPSModule if ($json !== null) { - $this->PublishMQTT( - 'remote-control-response/' . $suffix, - $json - ); + $this->PublishViaHelper( + 'remote-control-response/' . $suffix, + $json + ); } return; @@ -426,7 +427,17 @@ class MQTTBatterySDL extends IPSModule } + private function PublishViaHelper(string $topic, string $payload) + { + $id = $this->ReadPropertyInteger('PublishInstanceID'); + if ($id <= 0 || !IPS_InstanceExists($id)) { + $this->SendDebug('PublishViaHelper', 'Kein gültiges Publish-Modul gewählt', 0); + return; + } + + MBPUB_Publish($id, $topic, $payload); + }