Prevent empty HASS auto discovery topics if memory allocation fails (onBattery)
This commit is contained in:
parent
ec93004724
commit
d6d274f078
@ -8,6 +8,7 @@
|
||||
#include "NetworkSettings.h"
|
||||
#include "MessageOutput.h"
|
||||
#include "VictronMppt.h"
|
||||
#include "Utils.h"
|
||||
|
||||
MqttHandleVedirectHassClass MqttHandleVedirectHass;
|
||||
|
||||
@ -109,6 +110,9 @@ void MqttHandleVedirectHassClass::publishSensor(const char* caption, const char*
|
||||
statTopic.concat(subTopic);
|
||||
|
||||
DynamicJsonDocument root(1024);
|
||||
if (!Utils::checkJsonAlloc(root, __FUNCTION__, __LINE__)) {
|
||||
return;
|
||||
}
|
||||
root["name"] = caption;
|
||||
root["stat_t"] = statTopic;
|
||||
root["uniq_id"] = serial + "_" + sensorId;
|
||||
@ -160,6 +164,9 @@ void MqttHandleVedirectHassClass::publishBinarySensor(const char* caption, const
|
||||
statTopic.concat(subTopic);
|
||||
|
||||
DynamicJsonDocument root(1024);
|
||||
if (!Utils::checkJsonAlloc(root, __FUNCTION__, __LINE__)) {
|
||||
return;
|
||||
}
|
||||
root["name"] = caption;
|
||||
root["uniq_id"] = serial + "_" + sensorId;
|
||||
root["stat_t"] = statTopic;
|
||||
|
||||
@ -6,6 +6,7 @@
|
||||
#include "Configuration.h"
|
||||
#include "MqttSettings.h"
|
||||
#include "MessageOutput.h"
|
||||
#include "Utils.h"
|
||||
|
||||
MqttHandlePylontechHassClass MqttHandlePylontechHass;
|
||||
|
||||
@ -115,6 +116,9 @@ void MqttHandlePylontechHassClass::publishSensor(const char* caption, const char
|
||||
statTopic.concat(subTopic);
|
||||
|
||||
DynamicJsonDocument root(1024);
|
||||
if (!Utils::checkJsonAlloc(root, __FUNCTION__, __LINE__)) {
|
||||
return;
|
||||
}
|
||||
root["name"] = caption;
|
||||
root["stat_t"] = statTopic;
|
||||
root["uniq_id"] = serial + "_" + sensorId;
|
||||
@ -166,6 +170,9 @@ void MqttHandlePylontechHassClass::publishBinarySensor(const char* caption, cons
|
||||
statTopic.concat(subTopic);
|
||||
|
||||
DynamicJsonDocument root(1024);
|
||||
if (!Utils::checkJsonAlloc(root, __FUNCTION__, __LINE__)) {
|
||||
return;
|
||||
}
|
||||
root["name"] = caption;
|
||||
root["uniq_id"] = serial + "_" + sensorId;
|
||||
root["stat_t"] = statTopic;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user