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