disabled debug messages
This commit is contained in:
+29
-31
@@ -38,7 +38,7 @@ QStringList previsionList
|
||||
"Temps stable"
|
||||
};
|
||||
|
||||
QHash <QByteArray, quint8> announced = {};
|
||||
QHash <QByteArray, quint8> announced;
|
||||
QMap <QByteArray, QString> precPropertyList;
|
||||
QMap <QByteArray, QPair<QString, QByteArray>> propertyName
|
||||
{
|
||||
@@ -91,25 +91,15 @@ void Pws2mqtt::init()
|
||||
{
|
||||
debug(DEBUGMACRO, "init http server", INFO);
|
||||
|
||||
/* //httpServer->setMissingHandler(httpServer, missingHandler);
|
||||
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 5, 0)
|
||||
httpServer->setMissingHandler([](const QHttpServerRequest &request, QHttpServerResponder &&responder)
|
||||
{
|
||||
debug(DEBUGMACRO, "body " + request.url().toString(), WARNING);
|
||||
responder.sendResponse(QHttpServerResponse static QHash <QByteArray, quint8> announced = {};
|
||||
("text/plain; charset=utf-8", "404 - Page non trouvée. Route par défaut.", QHttpServerResponder::StatusCode::NotFound));
|
||||
});
|
||||
#else
|
||||
httpServer->setMissingHandler([](const QHttpServerRequest &request, QHttpServerResponder &&responder)
|
||||
{
|
||||
debug(DEBUGMACRO, "body " + request.url().toString(), WARNING);
|
||||
(void) responder;
|
||||
return QHttpServerResponse("404 - Page non trouvée. Route par défaut.", QHttpServerResponse::StatusCode::NotFound);
|
||||
//responder.write(QHttpServerResponse("404 - Page non trouvée. Route par défaut.", QHttpServerResponse::StatusCode::NotFound));
|
||||
responder.sendResponse(QHttpServerResponse("text/plain; charset=utf-8", "404 - Page non trouvée. Route par défaut.", QHttpServerResponder::StatusCode::NotFound));
|
||||
});
|
||||
#endif
|
||||
*/
|
||||
|
||||
httpServer->route("/", [](const QHttpServerRequest &request)
|
||||
{
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 8, 0)
|
||||
@@ -155,6 +145,7 @@ void Pws2mqtt::init()
|
||||
void notify(QString notif, QString priority, QString inputPath, QString tag)
|
||||
{
|
||||
(void) inputPath;
|
||||
debug(DEBUGMACRO, "Notifying " + notif, DEBUG);
|
||||
QNetworkAccessManager *manager = new QNetworkAccessManager();
|
||||
QNetworkRequest request(QUrl("http://localhost:81/Meteo"));
|
||||
request.setRawHeader("Content-Type", "charset=UTF-8; text/markdown");
|
||||
@@ -281,23 +272,30 @@ void Pws2mqtt::parseData(QList<std::pair<QString, QString>> queryList)
|
||||
|
||||
if (compare (propertiesValue[name], propertyValue, 1)) // and timeTemp < QDateTime::currentDateTime())
|
||||
{
|
||||
//notif += formatNotifString (propertyName[name].first, propertyName[name].second, QByteArray::number(qPow(propertyValue, 1.0)));
|
||||
//timeTemp = timeTemp.currentDateTime().addSecs(300);
|
||||
propertyList[name] = formatNotifString(propertyName[name], QByteArray::number(propertyValue));
|
||||
propertiesValue[name] = propertyValue;
|
||||
debug (DEBUGMACRO, name + " : " + QByteArray::number(propertyValue) , DEBUG);
|
||||
if (propertyValue > 35 and announced[name] != 5)
|
||||
debug (DEBUGMACRO, name + " : " + QByteArray::number(propertyValue) + " announced = " + QByteArray::number(announced[name]), DEBUG);
|
||||
if (propertyValue > 35)
|
||||
{
|
||||
debug(DEBUGMACRO, "Nofifying external temp > 35°C");
|
||||
notify (notif, priorityList[5]);
|
||||
announced[name] = 5;
|
||||
}else if (propertyValue > 27 and announced[name] != 4)
|
||||
if (announced[name] != 5)
|
||||
{
|
||||
debug(DEBUGMACRO, "Nofifying external temp > 35°C", DEBUG);
|
||||
notify (propertyList[name], priorityList[5]);
|
||||
announced[name] = 5;
|
||||
}
|
||||
}else if (propertyValue > 27)
|
||||
{
|
||||
debug(DEBUGMACRO, "Nofifying external temp > 27°C");
|
||||
notify (notif, priorityList[4]);
|
||||
announced[name] = 4;
|
||||
}else
|
||||
if (announced[name] != 4)
|
||||
{
|
||||
debug(DEBUGMACRO, "Nofifying external temp > 27°C", DEBUG);
|
||||
notify (propertyList[name], priorityList[4]);
|
||||
announced[name] = 4;
|
||||
}
|
||||
}else if (announced[name] != 0)
|
||||
{
|
||||
debug(DEBUGMACRO, "Nofifying external temp < 27°C", DEBUG);
|
||||
notify (propertyList[name], priorityList[4]);
|
||||
announced[name] = 0;
|
||||
}
|
||||
}
|
||||
@@ -565,12 +563,12 @@ void Pws2mqtt::parseData(QList<std::pair<QString, QString>> queryList)
|
||||
notify (notif, priorityList[aPriority], "", tag);
|
||||
debug(DEBUGMACRO, "calling notify with notif = #" + notif + "#", INFO);
|
||||
}
|
||||
if (aPriority >= 3)
|
||||
/*if (aPriority >= 3)
|
||||
{
|
||||
notif = "**ALERTES**\n" + listProperties2notify (precPropertyList, propertyList, priority, 3);
|
||||
precPropertyList = propertyList;
|
||||
notify (notif, priorityList[aPriority], attachment, tag);
|
||||
}
|
||||
}*/
|
||||
debug(DEBUGMACRO, "parseData: Returning", DEBUG);
|
||||
}
|
||||
|
||||
@@ -592,18 +590,18 @@ QString listProperties2notify (const QMap <QByteArray, QString> &precPropertyLis
|
||||
debug(DEBUGMACRO, "notif : " + notif, DEBUG);
|
||||
}else if (priority[name] >= minAlert)
|
||||
{
|
||||
if (announced.contains(name) and priority.contains(name))
|
||||
/*if (announced.contains(name) and priority.contains(name))
|
||||
{
|
||||
if (announced[name] != priority[name])
|
||||
{
|
||||
{*/
|
||||
notif += propertyList[name];
|
||||
announced[name] = priority[name];
|
||||
//announced[name] = priority[name];
|
||||
debug(DEBUGMACRO, "notif : " + notif, DEBUG);
|
||||
}else
|
||||
/*}else
|
||||
{
|
||||
debug (DEBUGMACRO, name + " : déjà annoncé = " + announced[name] + " nouvelle valeur = " + priority[name], INFO);
|
||||
}
|
||||
}
|
||||
}*/
|
||||
}
|
||||
//}
|
||||
}else if (precPropertyList.contains(name))
|
||||
|
||||
Reference in New Issue
Block a user