Improve power stability when using MQTT (#1070)

* Changes to improve MQTT and power stability

* Re-added the memory leak fix

* Re-added the memory leak fix

* Stop client before deleting

* Fixed potential nullpointer
This commit is contained in:
Gunnar Skjold
2025-12-01 10:01:20 +01:00
committed by GitHub
parent c0c696a55c
commit 9252a810df
6 changed files with 29 additions and 18 deletions

View File

@@ -10,7 +10,7 @@
#include "FirmwareVersion.h"
bool RawMqttHandler::publish(AmsData* update, AmsData* previousState, EnergyAccounting* ea, PriceService* ps) {
if(topic.isEmpty() || !mqtt.connected())
if(topic.isEmpty() || !connected())
return false;
AmsData data;
@@ -237,7 +237,7 @@ bool RawMqttHandler::publishTemperatures(AmsConfiguration* config, HwTools* hw)
}
bool RawMqttHandler::publishPrices(PriceService* ps) {
if(topic.isEmpty() || !mqtt.connected())
if(topic.isEmpty() || !connected())
return false;
if(!ps->hasPrice())
return false;
@@ -369,7 +369,7 @@ bool RawMqttHandler::publishPrices(PriceService* ps) {
}
bool RawMqttHandler::publishSystem(HwTools* hw, PriceService* ps, EnergyAccounting* ea) {
if(topic.isEmpty() || !mqtt.connected())
if(topic.isEmpty() || !connected())
return false;
mqtt.publish(topic + "/id", WiFi.macAddress(), true, 0);