publish energy mqtt data with qos zero (#1518)

This commit is contained in:
giedriuslt
2025-01-22 14:51:23 +02:00
committed by GitHub
parent f209c00a8b
commit 1ef7c8192f
3 changed files with 6 additions and 1 deletions

View File

@ -716,7 +716,7 @@ void BL_ProcessUpdate(float voltage, float current, float power,
} else { //all other sensors
float val = sensors[i].lastReading;
if (sensors[i].names.units == UNIT_WH) val = BL_ChangeEnergyUnitIfNeeded(val);
MQTT_PublishMain_StringFloat(sensors[i].names.name_mqtt, val, sensors[i].rounding_decimals, 0);
MQTT_PublishMain_StringFloat(sensors[i].names.name_mqtt, val, sensors[i].rounding_decimals, OBK_PUBLISH_FLAG_QOS_ZERO);
}
stat_updatesSent++;
}

View File

@ -815,6 +815,10 @@ static OBK_Publish_Result MQTT_PublishTopicToClient(mqtt_client_t* client, const
{
err_t err;
u8_t qos = 1; /* 0 1 or 2, see MQTT specification */
if (flags & OBK_PUBLISH_FLAG_QOS_ZERO)
{
qos = 0;
}
u8_t retain = 0; /* No don't retain such crappy payload... */
size_t sVal_len;
char* pub_topic;

View File

@ -68,6 +68,7 @@ enum OBK_Publish_Result_e {
#define OBK_PUBLISH_FLAG_FORCE_REMOVE_GET 4
// do not add anything to given topic
#define OBK_PUBLISH_FLAG_RAW_TOPIC_NAME 8
#define OBK_PUBLISH_FLAG_QOS_ZERO 16
#include "new_mqtt_deduper.h"