mirror of
https://github.com/emsesp/EMS-ESP32.git
synced 2025-12-07 16:29:51 +03:00
do not publish empty messages, free mem
This commit is contained in:
@@ -456,11 +456,13 @@ void EMSESP::publish_device_values(uint8_t device_type) {
|
||||
|
||||
// if its a boiler, generate json for each group and publish it directly
|
||||
if (device_type == DeviceType::BOILER) {
|
||||
emsdevice->generate_values_json(json, DeviceValueTAG::TAG_BOILER_DATA, false);
|
||||
Mqtt::publish(Mqtt::tag_to_topic(device_type, DeviceValueTAG::TAG_BOILER_DATA), json);
|
||||
json.clear();
|
||||
emsdevice->generate_values_json(json, DeviceValueTAG::TAG_DEVICE_DATA_WW, false);
|
||||
Mqtt::publish(Mqtt::tag_to_topic(device_type, DeviceValueTAG::TAG_DEVICE_DATA_WW), json);
|
||||
if (emsdevice->generate_values_json(json, DeviceValueTAG::TAG_BOILER_DATA, false)) {
|
||||
Mqtt::publish(Mqtt::tag_to_topic(device_type, DeviceValueTAG::TAG_BOILER_DATA), json);
|
||||
}
|
||||
doc.clear();
|
||||
if (emsdevice->generate_values_json(json, DeviceValueTAG::TAG_DEVICE_DATA_WW, false)) {
|
||||
Mqtt::publish(Mqtt::tag_to_topic(device_type, DeviceValueTAG::TAG_DEVICE_DATA_WW), json);
|
||||
}
|
||||
need_publish = false;
|
||||
}
|
||||
|
||||
@@ -471,14 +473,16 @@ void EMSESP::publish_device_values(uint8_t device_type) {
|
||||
if (nested) {
|
||||
need_publish |= emsdevice->generate_values_json(json, DeviceValueTAG::TAG_NONE, true); // nested
|
||||
} else {
|
||||
emsdevice->generate_values_json(json, DeviceValueTAG::TAG_THERMOSTAT_DATA, false); // not nested
|
||||
Mqtt::publish(Mqtt::tag_to_topic(device_type, DeviceValueTAG::TAG_NONE), json);
|
||||
json.clear();
|
||||
if (emsdevice->generate_values_json(json, DeviceValueTAG::TAG_THERMOSTAT_DATA, false)) { // not nested
|
||||
Mqtt::publish(Mqtt::tag_to_topic(device_type, DeviceValueTAG::TAG_NONE), json);
|
||||
}
|
||||
doc.clear();
|
||||
|
||||
for (uint8_t hc_tag = TAG_HC1; hc_tag <= DeviceValueTAG::TAG_HC4; hc_tag++) {
|
||||
emsdevice->generate_values_json(json, hc_tag, false); // not nested
|
||||
Mqtt::publish(Mqtt::tag_to_topic(device_type, hc_tag), json);
|
||||
json.clear();
|
||||
if (emsdevice->generate_values_json(json, hc_tag, false)) { // not nested
|
||||
Mqtt::publish(Mqtt::tag_to_topic(device_type, hc_tag), json);
|
||||
}
|
||||
doc.clear();
|
||||
}
|
||||
need_publish = false;
|
||||
}
|
||||
@@ -491,9 +495,10 @@ void EMSESP::publish_device_values(uint8_t device_type) {
|
||||
need_publish |= emsdevice->generate_values_json(json, DeviceValueTAG::TAG_NONE, true); // nested
|
||||
} else {
|
||||
for (uint8_t hc_tag = TAG_HC1; hc_tag <= DeviceValueTAG::TAG_WWC4; hc_tag++) {
|
||||
emsdevice->generate_values_json(json, hc_tag, false); // not nested
|
||||
Mqtt::publish(Mqtt::tag_to_topic(device_type, hc_tag), json);
|
||||
json.clear();
|
||||
if (emsdevice->generate_values_json(json, hc_tag, false)) { // not nested
|
||||
Mqtt::publish(Mqtt::tag_to_topic(device_type, hc_tag), json);
|
||||
}
|
||||
doc.clear();
|
||||
}
|
||||
need_publish = false;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user