Add timestamp handling in SendTopic method to improve MQTT publishing logic

This commit is contained in:
jhartworks
2026-03-04 14:57:36 +01:00
parent fd9d075786
commit 4b5eba3a23
+3 -2
View File
@@ -120,6 +120,7 @@ class MonitoringClient extends IPSModule {
return true; return true;
} // MQTT_Publish } // MQTT_Publish
public function SendTopic() { public function SendTopic() {
$mqttId = $this->ReadPropertyInteger("MqttCLientID"); $mqttId = $this->ReadPropertyInteger("MqttCLientID");
@@ -169,7 +170,7 @@ class MonitoringClient extends IPSModule {
$varname = IPS_GetName($childid); $varname = IPS_GetName($childid);
$topic = $catId["top"]. $parname."_".$varname; $topic = $catId["top"]. $parname."_".$varname;
$payload = round(getvalue($childid), 2); $payload = round(getvalue($childid), 2);
$time = time();
if($changedtime > $time - $updatetime){ if($changedtime > $time - $updatetime){
$this->MqttPublish($mqttId, $topic, $payload, false); $this->MqttPublish($mqttId, $topic, $payload, false);
} }
@@ -194,7 +195,7 @@ class MonitoringClient extends IPSModule {
$varname = IPS_GetName($childid); $varname = IPS_GetName($childid);
$topic = $catId["top"].$varname; $topic = $catId["top"].$varname;
$payload = round(getvalue($childid), 2); $payload = round(getvalue($childid), 2);
$time = time();
if($changedtime > $time - $updatetime){ if($changedtime > $time - $updatetime){
$this->MqttPublish($mqttId, $topic, $payload, false); $this->MqttPublish($mqttId, $topic, $payload, false);
} }