debbug
This commit is contained in:
@@ -155,11 +155,13 @@ void Pws2mqtt::parseData(QList<std::pair<QString, QString>> queryList)
|
||||
QStringList priorityList {"", "min", "low", "default", "High", "urgent"};
|
||||
QString attachment = "";
|
||||
QString tag = "";
|
||||
quint8 priority = 2;
|
||||
double propertyValue = 0;
|
||||
bool propertyFlag = false;
|
||||
bool deviceFlag = false;
|
||||
static QDateTime timer = QDateTime::currentDateTime().addSecs(-2000);
|
||||
static QHash <QByteArray, quint8> priority = {};
|
||||
static QHash <QByteArray, quint8> announced = {};
|
||||
static bool start = false;
|
||||
|
||||
debug(DEBUGMACRO, "looping list of query", DEBUG);
|
||||
|
||||
@@ -206,6 +208,13 @@ void Pws2mqtt::parseData(QList<std::pair<QString, QString>> queryList)
|
||||
timeTemp = timeTemp.currentDateTime().addSecs(300);
|
||||
propertyList[name] = formatNotifString(propertyName[name].first, propertyName[name].second, QByteArray::number(propertyValue));
|
||||
propertiesValue[name] = propertyValue;
|
||||
if (propertyValue > 35)
|
||||
{
|
||||
priority[name] = 4;
|
||||
}else if (propertyValue > 27)
|
||||
{
|
||||
priority[name] = 3;
|
||||
}
|
||||
}
|
||||
}else if (name == "humidity")
|
||||
{
|
||||
@@ -255,9 +264,9 @@ void Pws2mqtt::parseData(QList<std::pair<QString, QString>> queryList)
|
||||
|
||||
if (propertiesValue["forcevent"] != i)
|
||||
{
|
||||
priority = qMax(priority, windPriority);
|
||||
priority[name] = qMax(priority[name], windPriority);
|
||||
}
|
||||
debug (DEBUGMACRO, "priority = " + QString::number(priority), DEBUG);
|
||||
debug (DEBUGMACRO, "priority = " + QString::number(priority[name]), DEBUG);
|
||||
}else if (name == "windgustmph")
|
||||
{
|
||||
QString msg = "";
|
||||
@@ -271,9 +280,9 @@ void Pws2mqtt::parseData(QList<std::pair<QString, QString>> queryList)
|
||||
|
||||
if (propertiesValue[name] > 50)
|
||||
{
|
||||
priority = qMax(priority, (quint8)4);
|
||||
priority[name] = qMax(priority[name], (quint8)4);
|
||||
}
|
||||
debug (DEBUGMACRO, "priority = " + QString::number(priority), DEBUG);
|
||||
debug (DEBUGMACRO, "priority = " + QString::number(priority[name]), DEBUG);
|
||||
}else if (name == "rainin")
|
||||
{
|
||||
static double ecart;
|
||||
@@ -290,12 +299,12 @@ void Pws2mqtt::parseData(QList<std::pair<QString, QString>> queryList)
|
||||
if (compare (propertiesValue[name], propertyValue, ecart))
|
||||
{
|
||||
QString pluviosite = getPluviosite(propertyValue, raininPriority);
|
||||
priority = setPriority (priority, raininPriority);
|
||||
priority[name] = setPriority (priority[name], raininPriority);
|
||||
//debug (DEBUGMACRO, "Notif = #" + notif + "#", DEBUG);
|
||||
propertyList[name] = formatNotifString(pluviosite, propertyName[name].second, QByteArray::number(propertyValue));
|
||||
propertiesValue[name] = propertyValue;
|
||||
}
|
||||
debug (DEBUGMACRO, "priority = " + QString::number(priority), DEBUG);
|
||||
debug (DEBUGMACRO, "priority = " + QString::number(priority[name]), DEBUG);
|
||||
}else if (name == "dailyrainin")
|
||||
{
|
||||
static double ecart;
|
||||
@@ -310,12 +319,12 @@ void Pws2mqtt::parseData(QList<std::pair<QString, QString>> queryList)
|
||||
debug (DEBUGMACRO, name + " : " + QByteArray::number(propertyValue), DEBUG);
|
||||
if (compare (propertiesValue[name], propertyValue, ecart))
|
||||
{
|
||||
//priority = setPriority (priority, 3);
|
||||
//priority[name] = setPriority (priority[name], 3);
|
||||
//debug (DEBUGMACRO, "Notif = #" + notif + "#", DEBUG);
|
||||
propertyList[name] = formatNotifString(propertyName[name].first, propertyName[name].second, QByteArray::number(propertyValue));
|
||||
propertiesValue[name] = propertyValue;
|
||||
}
|
||||
debug (DEBUGMACRO, "priority = " + QString::number(priority), DEBUG);
|
||||
debug (DEBUGMACRO, "priority = " + QString::number(priority[name]), DEBUG);
|
||||
}else if (name == "baromin")
|
||||
{
|
||||
//static QDateTime timePrevision = QDateTime::currentDateTime().addSecs(-1000);
|
||||
@@ -332,11 +341,11 @@ void Pws2mqtt::parseData(QList<std::pair<QString, QString>> queryList)
|
||||
prevision = ret.message;
|
||||
//if (prevision != newPrevision)
|
||||
//{
|
||||
priority = setPriority(priority, ret.urgency);
|
||||
priority[name] = setPriority(priority[name], ret.urgency);
|
||||
tag += ret.icons;
|
||||
|
||||
propertyList["prevision"] = prevision;
|
||||
debug (DEBUGMACRO, "priority = " + QString::number(priority), DEBUG);
|
||||
debug (DEBUGMACRO, "priority = " + QString::number(priority[name]), DEBUG);
|
||||
}else if (name == "UV")
|
||||
{
|
||||
static QDateTime timeUV = QDateTime::currentDateTime().addSecs(-600);
|
||||
@@ -347,15 +356,15 @@ void Pws2mqtt::parseData(QList<std::pair<QString, QString>> queryList)
|
||||
{
|
||||
//notif += formatNotifString (propertyName[name].first, propertyName[name].second , value);
|
||||
if (propertyValue == 5 )
|
||||
priority = setPriority (priority, 4);
|
||||
priority[name] = setPriority (priority[name], 4);
|
||||
if (propertyValue >= 6 )
|
||||
priority = setPriority (priority, 5);
|
||||
priority[name] = setPriority (priority[name], 5);
|
||||
timeUV = timeUV.currentDateTime().addSecs(300);
|
||||
propertiesValue[name] = propertyValue;
|
||||
debug (DEBUGMACRO, "Notif = #" + notif + "#", DEBUG);
|
||||
propertyList[name] = formatNotifString(propertyName[name].first, "", QByteArray::number(propertyValue));
|
||||
}
|
||||
debug (DEBUGMACRO, "priority = " + QString::number(priority), DEBUG);
|
||||
debug (DEBUGMACRO, "priority = " + QString::number(priority[name]), DEBUG);
|
||||
|
||||
}else if (name == "solarradiation")
|
||||
{
|
||||
@@ -380,43 +389,47 @@ void Pws2mqtt::parseData(QList<std::pair<QString, QString>> queryList)
|
||||
|
||||
debug(DEBUGMACRO, "current datetime : " + QDateTime::currentDateTime().toString() + ", timer = " + timer.toString(), DEBUG);
|
||||
|
||||
if (priority > 3 or QDateTime::currentDateTime() > timer.addSecs(1800))
|
||||
{
|
||||
bool changed = false;
|
||||
timer = QDateTime::currentDateTime();
|
||||
debug(DEBUGMACRO, "looping to fill notif, priority = " + QString::number(priority), DEBUG);
|
||||
|
||||
if (precPropertyList.size() == 0)
|
||||
{
|
||||
changed = true;
|
||||
}
|
||||
//bool changed = false;
|
||||
quint8 aPriority= 0;
|
||||
|
||||
debug(DEBUGMACRO, "looping to fill notif", DEBUG);
|
||||
|
||||
for (auto [name, value]: propertyList.asKeyValueRange())
|
||||
{
|
||||
if (precPropertyList.contains(name))
|
||||
{
|
||||
if (precPropertyList[name] != propertyList[name])
|
||||
{
|
||||
if (announced.contains(name) and priority.contains(name))
|
||||
{
|
||||
if (announced[name] != priority[name])
|
||||
{
|
||||
debug(DEBUGMACRO, "changed = true", DEBUG);
|
||||
changed = true;
|
||||
announced[name] = priority[name];
|
||||
//changed = true;
|
||||
aPriority = qMax(aPriority, priority[name]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
debug(DEBUGMACRO, "Name = " + name + ", value = " + value, DEBUG);
|
||||
if (! (name == "prevision"))
|
||||
if (name != "prevision")
|
||||
{
|
||||
notif += propertyList[name];
|
||||
}
|
||||
}
|
||||
if (changed)
|
||||
if (QDateTime::currentDateTime() > timer.addSecs(3600) or start == false or aPriority >= 3)
|
||||
{
|
||||
notify (notif, priorityList[priority], attachment, tag);
|
||||
timer = QDateTime::currentDateTime();
|
||||
start = true;
|
||||
notify (notif, priorityList[aPriority], attachment, tag);
|
||||
precPropertyList = propertyList;
|
||||
}
|
||||
|
||||
notif = "**Prévisions à 12/24h**\n" + propertyList["prevision"];
|
||||
notify (notif, priorityList[priority], "", tag);
|
||||
notify (notif, priorityList[aPriority], "", tag);
|
||||
debug(DEBUGMACRO, "calling notify with notif = #" + notif + "#", DEBUG);
|
||||
|
||||
}
|
||||
debug(DEBUGMACRO, "parseData: Returning", DEBUG);
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
#include <QObject>
|
||||
#include <QtMqtt>
|
||||
#include <QtMqtt/QMqttClient>
|
||||
#include <cstdint>
|
||||
|
||||
#define RED "\e[31m"
|
||||
#define GREEN "\e[32m"
|
||||
|
||||
Reference in New Issue
Block a user