minor corrections

This commit is contained in:
2026-05-13 15:22:54 +02:00
parent 2d3ab95e83
commit 2ff8eb3ee7
+16 -16
View File
@@ -231,15 +231,14 @@ void Pws2mqtt::parseData(QList<std::pair<QString, QString>> queryList)
QString attachment = "";
QString tag = "";
double propertyValue = 0;
bool propertyFlag = false;
bool deviceFlag = false;
static QDateTime timer = QDateTime::currentDateTime().addSecs(-2000);
static QHash <QByteArray, quint8> priority = {};
static bool start = false;
debug(DEBUGMACRO, "looping list of query", DEBUG);
for (QPair<QString, QString> pair : queryList)
for (const QPair<QString, QString> &pair : queryList)
{
debug(DEBUGMACRO, pair.first + " = " + pair.second, DEBUG);
QByteArray name = pair.first.toLatin1();
@@ -248,25 +247,26 @@ void Pws2mqtt::parseData(QList<std::pair<QString, QString>> queryList)
if (this->deviceProperties.contains(name))
{
#ifdef WITH_MQTT
bool propertyFlag = false;
bool deviceFlag = false;
if(deviceFlag == false)
{
deviceFlag = true;
}
#ifdef WITH_MQTT
else
{
deviceString.append(", ");
}
deviceString += "\"" + name + "\": ";
deviceString += pair.second;
#endif
}else
{
if(propertyFlag == false)
{
propertyFlag = true;
}
#ifdef WITH_MQTT
else
{
jsonString.append(", ");
@@ -322,7 +322,7 @@ void Pws2mqtt::parseData(QList<std::pair<QString, QString>> queryList)
propertiesValue[name] = round(mphTokmh(value.toFloat()));
debug (DEBUGMACRO, name + " : " + QByteArray::number(propertiesValue[name]), DEBUG);
debug (DEBUGMACRO, name + " : " + QByteArray::number(propertiesValue[name]) + " km/h", DEBUG);
for (i=0; i<forceVent.size();i++)
{
@@ -334,7 +334,7 @@ void Pws2mqtt::parseData(QList<std::pair<QString, QString>> queryList)
}
}
propertyList[name] = "- Vent - " + msg + " : " + QByteArray::number(propertiesValue[name]) + "Km/h" + "\n";
propertyList[name] = "- Vent - " + msg + " : " + QByteArray::number(propertiesValue[name]) + " Km/h\n";
propertiesValue["forcevent"] = i;
if (i >= 5)
{
@@ -351,9 +351,9 @@ void Pws2mqtt::parseData(QList<std::pair<QString, QString>> queryList)
QString msg = "";
static QDateTime timeWind = QDateTime::currentDateTime().addSecs(-600);
propertiesValue[name] = round(mphTokmh(value.toFloat()));
propertiesValue[name] = round(mphTokmh(value.toFloat()) );
debug (DEBUGMACRO, name + " : " + QByteArray::number(propertiesValue[name]), DEBUG);
debug (DEBUGMACRO, name + " : " + QByteArray::number(propertiesValue[name]) + " km/h", DEBUG);
propertyList[name] = formatNotifString (propertyName[name], QByteArray::number(propertiesValue[name]));
@@ -366,8 +366,8 @@ void Pws2mqtt::parseData(QList<std::pair<QString, QString>> queryList)
{
static double ecart;
quint8 raininPriority = 1;
propertyValue = round(pair.second.toFloat()*100)/100;
if (propertyValue == 0)
propertyValue = round(pair.second.toFloat()*100)/100.0;
if (propertyValue <= 0.01)
{
ecart = 0.0001;
}else
@@ -387,8 +387,8 @@ void Pws2mqtt::parseData(QList<std::pair<QString, QString>> queryList)
}else if (name == "dailyrainin")
{
static double ecart;
propertyValue = round(pair.second.toFloat()*100)/100;
if (propertyValue == 0)
propertyValue = round(pair.second.toFloat()*100)/100.0;
if (propertyValue <= 0.01)
{
ecart = 0.0001;
}else
@@ -449,7 +449,7 @@ void Pws2mqtt::parseData(QList<std::pair<QString, QString>> queryList)
propertyValue = pair.second.toFloat()*100/100;
propertyList[name] = formatNotifString(propertyName[name], QByteArray::number(propertyValue));
propertiesValue[name] = round(pair.second.toFloat()*100/100);
debug (DEBUGMACRO, "SolarRadiations = " + QByteArray::number(propertyValue), DEBUG);
debug (DEBUGMACRO, "solarradiations : " + QByteArray::number(propertyValue), DEBUG);
}
}
}
@@ -612,7 +612,7 @@ double mphTokmh (double value)
bool compare (double value, double currentValue, double ecart)
{
debug(DEBUGMACRO, "value: " + QByteArray::number(value) + "testValue: " + QByteArray::number(currentValue), DEBUG);
debug(DEBUGMACRO, "Old value: " + QByteArray::number(value) + " ==> Current value: " + QByteArray::number(currentValue), DEBUG);
if (currentValue <= (value - ecart) or currentValue >= (value + ecart))
{