mirror of
https://github.com/jomjol/AI-on-the-edge-device.git
synced 2025-12-08 20:46:52 +03:00
Extend mqtt json (#1489)
* add whitespaces in JSON in MQTT * re-added pre-value Co-authored-by: CaCO3 <caco@ruinelli.ch>
This commit is contained in:
@@ -225,6 +225,7 @@ bool ClassFlowMQTT::doFlow(string zwtime)
|
|||||||
std::string result;
|
std::string result;
|
||||||
std::string resulterror = "";
|
std::string resulterror = "";
|
||||||
std::string resultraw = "";
|
std::string resultraw = "";
|
||||||
|
std::string resultpre = "";
|
||||||
std::string resultrate = ""; // Always Unit / Minute
|
std::string resultrate = ""; // Always Unit / Minute
|
||||||
std::string resultRatePerTimeUnit = ""; // According to selection
|
std::string resultRatePerTimeUnit = ""; // According to selection
|
||||||
std::string resulttimestamp = "";
|
std::string resulttimestamp = "";
|
||||||
@@ -244,6 +245,7 @@ bool ClassFlowMQTT::doFlow(string zwtime)
|
|||||||
{
|
{
|
||||||
result = (*NUMBERS)[i]->ReturnValue;
|
result = (*NUMBERS)[i]->ReturnValue;
|
||||||
resultraw = (*NUMBERS)[i]->ReturnRawValue;
|
resultraw = (*NUMBERS)[i]->ReturnRawValue;
|
||||||
|
resultpre = (*NUMBERS)[i]->ReturnPreValue;
|
||||||
resulterror = (*NUMBERS)[i]->ErrorMessageText;
|
resulterror = (*NUMBERS)[i]->ErrorMessageText;
|
||||||
resultrate = (*NUMBERS)[i]->ReturnRateValue; // Unit per minutes
|
resultrate = (*NUMBERS)[i]->ReturnRateValue; // Unit per minutes
|
||||||
resultchangabs = (*NUMBERS)[i]->ReturnChangeAbsolute; // Units per round
|
resultchangabs = (*NUMBERS)[i]->ReturnChangeAbsolute; // Units per round
|
||||||
@@ -289,19 +291,22 @@ bool ClassFlowMQTT::doFlow(string zwtime)
|
|||||||
std::string json = "";
|
std::string json = "";
|
||||||
|
|
||||||
if (result.length() > 0)
|
if (result.length() > 0)
|
||||||
json += "{\"value\":"+result;
|
json += "{\"value\": "+result;
|
||||||
else
|
else
|
||||||
json += "{\"value\":\"\"";
|
json += "{\"value\": \"\"";
|
||||||
|
|
||||||
json += ",\"raw\":\""+resultraw;
|
json += ", \"raw\": \""+resultraw;
|
||||||
json += "\",\"error\":\""+resulterror;
|
|
||||||
|
json += ", \"pre\": \"" + resultpre;
|
||||||
|
|
||||||
|
json += "\", \"error\": \""+resulterror;
|
||||||
|
|
||||||
if (resultrate.length() > 0)
|
if (resultrate.length() > 0)
|
||||||
json += "\",\"rate\":"+resultrate;
|
json += "\", \"rate\": "+resultrate;
|
||||||
else
|
else
|
||||||
json += "\",\"rate\":\"\"";
|
json += "\", \"rate\": \"\"";
|
||||||
|
|
||||||
json += ",\"timestamp\":\""+resulttimestamp+"\"}";
|
json += ", \"timestamp\": \""+resulttimestamp+"\"}";
|
||||||
|
|
||||||
MQTTPublish(namenumber + "json", json, SetRetainFlag);
|
MQTTPublish(namenumber + "json", json, SetRetainFlag);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user