modif notifications une seule notification avec tous les paramètres\ndebug

This commit is contained in:
DTux committed 2025-10-04 23:05:36 +02:00
1 parent 33a9fb517e
commit 1f00d24154
6 files changed
+275 -154

No files matched your search

BIN
View File
Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.0 KiB

+2 -1
View File
@@ -91,9 +91,10 @@ int main(int argc, char *argv[])
void debug(QString debugHeader, QString msg, uint8_t level, QByteArray property) void debug(QString debugHeader, QString msg, uint8_t level, QByteArray property)
{ {
msg.replace("\n", "\\n");
if ((debugLevel & level) == 1) if ((debugLevel & level) == 1)
{ {
qInfo("%s%sINFO: %s%s", debugHeader.toStdString().c_str(), GREEN, ("'" + msg.toStdString() + "'").c_str(), NORMAL); qInfo("%s%sINFO: %s%s", debugHeader.toStdString().c_str(), GREEN, msg.toStdString().c_str(), NORMAL);
} }
if ((debugLevel & level) == 2) if ((debugLevel & level) == 2)
{ {
+101 -85
View File
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE QtCreatorProject> <!DOCTYPE QtCreatorProject>
<!-- Written by QtCreator 9.0.1, 2024-09-10T18:21:21. --> <!-- Written by QtCreator 9.0.1, 2025-10-03T23:36:59. -->
<qtcreator> <qtcreator>
<data> <data>
<variable>EnvironmentId</variable> <variable>EnvironmentId</variable>
@@ -85,6 +85,97 @@
</data> </data>
<data> <data>
<variable>ProjectExplorer.Project.Target.0</variable> <variable>ProjectExplorer.Project.Target.0</variable>
<valuemap type="QVariantMap">
<value type="QString" key="DeviceType">Desktop</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Qt 6.4.1 (qt6)</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Qt 6.4.1 (qt6)</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">{17b0ba8e-e6fe-4c71-98eb-9b4d3bcc4307}</value>
<value type="qlonglong" key="ProjectExplorer.Target.ActiveBuildConfiguration">0</value>
<value type="qlonglong" key="ProjectExplorer.Target.ActiveDeployConfiguration">0</value>
<value type="qlonglong" key="ProjectExplorer.Target.ActiveRunConfiguration">0</value>
<valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.0">
<value type="int" key="EnableQmlDebugging">0</value>
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">/home/daniel/develop/build-pws2mqtt-qt-Desktop-Debug</value>
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory.shadowDir">/home/daniel/develop/build-pws2mqtt-qt-Desktop-Debug</value>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
<value type="QString" key="ProjectExplorer.ProcessStep.Arguments"> -x versioning -s 1</value>
<value type="QString" key="ProjectExplorer.ProcessStep.Command">bash</value>
<value type="QString" key="ProjectExplorer.ProcessStep.WorkingDirectory">%{ActiveProject:NativePath}</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.ProcessStep</value>
</valuemap>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.1">
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">QtProjectManager.QMakeBuildStep</value>
<value type="bool" key="QtProjectManager.QMakeBuildStep.QMakeForced">false</value>
<valuelist type="QVariantList" key="QtProjectManager.QMakeBuildStep.SelectedAbis"/>
</valuemap>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.2">
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
</valuemap>
<value type="qlonglong" key="ProjectExplorer.BuildStepList.StepsCount">3</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Build</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Build</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Build</value>
</valuemap>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.1">
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments">clean</value>
</valuemap>
<value type="qlonglong" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Clean</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Clean</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Clean</value>
</valuemap>
<value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">2</value>
<value type="bool" key="ProjectExplorer.BuildConfiguration.ClearSystemEnvironment">false</value>
<valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.CustomParsers"/>
<value type="bool" key="ProjectExplorer.BuildConfiguration.ParseStandardOutput">false</value>
<valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.UserEnvironmentChanges"/>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Debug</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4BuildConfiguration</value>
<value type="int" key="Qt4ProjectManager.Qt4BuildConfiguration.BuildConfiguration">2</value>
</valuemap>
<value type="qlonglong" key="ProjectExplorer.Target.BuildConfigurationCount">1</value>
<valuemap type="QVariantMap" key="ProjectExplorer.Target.DeployConfiguration.0">
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
<value type="qlonglong" key="ProjectExplorer.BuildStepList.StepsCount">0</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Deploy</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Deploy</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Deploy</value>
</valuemap>
<value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">1</value>
<valuemap type="QVariantMap" key="ProjectExplorer.DeployConfiguration.CustomData"/>
<value type="bool" key="ProjectExplorer.DeployConfiguration.CustomDataEnabled">false</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.DefaultDeployConfiguration</value>
</valuemap>
<value type="qlonglong" key="ProjectExplorer.Target.DeployConfigurationCount">1</value>
<valuemap type="QVariantMap" key="ProjectExplorer.Target.RunConfiguration.0">
<value type="bool" key="Analyzer.Perf.Settings.UseGlobalSettings">true</value>
<value type="bool" key="Analyzer.QmlProfiler.Settings.UseGlobalSettings">true</value>
<value type="bool" key="Analyzer.Valgrind.Settings.UseGlobalSettings">true</value>
<valuelist type="QVariantList" key="CustomOutputParsers"/>
<value type="int" key="PE.EnvironmentAspect.Base">2</value>
<valuelist type="QVariantList" key="PE.EnvironmentAspect.Changes"/>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4RunConfiguration:/home/daniel/develop/pws2mqtt-qt/pws2mqtt-qt.pro</value>
<value type="QString" key="ProjectExplorer.RunConfiguration.BuildKey">/home/daniel/develop/pws2mqtt-qt/pws2mqtt-qt.pro</value>
<value type="bool" key="RunConfiguration.UseCppDebugger">false</value>
<value type="bool" key="RunConfiguration.UseCppDebuggerAuto">true</value>
<value type="bool" key="RunConfiguration.UseLibrarySearchPath">true</value>
<value type="bool" key="RunConfiguration.UseQmlDebugger">false</value>
<value type="bool" key="RunConfiguration.UseQmlDebuggerAuto">true</value>
<value type="bool" key="RunConfiguration.UseTerminal">false</value>
<value type="QString" key="RunConfiguration.WorkingDirectory.default">/home/daniel/develop/build-pws2mqtt-qt-Desktop-Debug</value>
</valuemap>
<value type="qlonglong" key="ProjectExplorer.Target.RunConfigurationCount">1</value>
</valuemap>
</data>
<data>
<variable>ProjectExplorer.Project.Target.1</variable>
<valuemap type="QVariantMap"> <valuemap type="QVariantMap">
<value type="QString" key="DeviceType">Desktop</value> <value type="QString" key="DeviceType">Desktop</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Desktop</value> <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Desktop</value>
@@ -99,16 +190,23 @@
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory.shadowDir">/home/daniel/develop/build-pws2mqtt-qt-Desktop-Debug</value> <value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory.shadowDir">/home/daniel/develop/build-pws2mqtt-qt-Desktop-Debug</value>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0"> <valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0"> <valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
<value type="QString" key="ProjectExplorer.ProcessStep.Arguments">-s 1</value>
<value type="QString" key="ProjectExplorer.ProcessStep.Command">versioning</value>
<value type="QString" key="ProjectExplorer.ProcessStep.WorkingDirectory">%{buildDir}</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.ProcessStep</value>
</valuemap>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.1">
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value> <value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">QtProjectManager.QMakeBuildStep</value> <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">QtProjectManager.QMakeBuildStep</value>
<value type="bool" key="QtProjectManager.QMakeBuildStep.QMakeForced">false</value> <value type="bool" key="QtProjectManager.QMakeBuildStep.QMakeForced">false</value>
<valuelist type="QVariantList" key="QtProjectManager.QMakeBuildStep.SelectedAbis"/> <valuelist type="QVariantList" key="QtProjectManager.QMakeBuildStep.SelectedAbis"/>
</valuemap> </valuemap>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.1"> <valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.2">
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value> <value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value> <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
</valuemap> </valuemap>
<value type="qlonglong" key="ProjectExplorer.BuildStepList.StepsCount">2</value> <value type="qlonglong" key="ProjectExplorer.BuildStepList.StepsCount">3</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Build</value> <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Build</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Build</value> <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Build</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Build</value> <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Build</value>
@@ -243,88 +341,6 @@
<value type="bool" key="RunConfiguration.UseLibrarySearchPath">true</value> <value type="bool" key="RunConfiguration.UseLibrarySearchPath">true</value>
<value type="bool" key="RunConfiguration.UseQmlDebugger">false</value> <value type="bool" key="RunConfiguration.UseQmlDebugger">false</value>
<value type="bool" key="RunConfiguration.UseQmlDebuggerAuto">true</value> <value type="bool" key="RunConfiguration.UseQmlDebuggerAuto">true</value>
<value type="QString" key="RunConfiguration.WorkingDirectory.default">/home/daniel/develop/build-pws2mqtt-qt-Desktop-Debug</value>
</valuemap>
<value type="qlonglong" key="ProjectExplorer.Target.RunConfigurationCount">1</value>
</valuemap>
</data>
<data>
<variable>ProjectExplorer.Project.Target.1</variable>
<valuemap type="QVariantMap">
<value type="QString" key="DeviceType">Desktop</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Qt 6.4.1 (qt6)</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Qt 6.4.1 (qt6)</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">{17b0ba8e-e6fe-4c71-98eb-9b4d3bcc4307}</value>
<value type="qlonglong" key="ProjectExplorer.Target.ActiveBuildConfiguration">0</value>
<value type="qlonglong" key="ProjectExplorer.Target.ActiveDeployConfiguration">0</value>
<value type="qlonglong" key="ProjectExplorer.Target.ActiveRunConfiguration">0</value>
<valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.0">
<value type="int" key="EnableQmlDebugging">0</value>
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">/home/daniel/develop/build-pws2mqtt-qt-Desktop-Debug</value>
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory.shadowDir">/home/daniel/develop/build-pws2mqtt-qt-Desktop-Debug</value>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">QtProjectManager.QMakeBuildStep</value>
<value type="bool" key="QtProjectManager.QMakeBuildStep.QMakeForced">true</value>
<valuelist type="QVariantList" key="QtProjectManager.QMakeBuildStep.SelectedAbis"/>
</valuemap>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.1">
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
</valuemap>
<value type="qlonglong" key="ProjectExplorer.BuildStepList.StepsCount">2</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Build</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Build</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Build</value>
</valuemap>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.1">
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments">clean</value>
</valuemap>
<value type="qlonglong" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Clean</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Clean</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Clean</value>
</valuemap>
<value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">2</value>
<value type="bool" key="ProjectExplorer.BuildConfiguration.ClearSystemEnvironment">false</value>
<valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.CustomParsers"/>
<value type="bool" key="ProjectExplorer.BuildConfiguration.ParseStandardOutput">false</value>
<valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.UserEnvironmentChanges"/>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Debug</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4BuildConfiguration</value>
<value type="int" key="Qt4ProjectManager.Qt4BuildConfiguration.BuildConfiguration">2</value>
</valuemap>
<value type="qlonglong" key="ProjectExplorer.Target.BuildConfigurationCount">1</value>
<valuemap type="QVariantMap" key="ProjectExplorer.Target.DeployConfiguration.0">
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
<value type="qlonglong" key="ProjectExplorer.BuildStepList.StepsCount">0</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Deploy</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Deploy</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Deploy</value>
</valuemap>
<value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">1</value>
<valuemap type="QVariantMap" key="ProjectExplorer.DeployConfiguration.CustomData"/>
<value type="bool" key="ProjectExplorer.DeployConfiguration.CustomDataEnabled">false</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.DefaultDeployConfiguration</value>
</valuemap>
<value type="qlonglong" key="ProjectExplorer.Target.DeployConfigurationCount">1</value>
<valuemap type="QVariantMap" key="ProjectExplorer.Target.RunConfiguration.0">
<value type="bool" key="Analyzer.Perf.Settings.UseGlobalSettings">true</value>
<value type="bool" key="Analyzer.QmlProfiler.Settings.UseGlobalSettings">true</value>
<value type="bool" key="Analyzer.Valgrind.Settings.UseGlobalSettings">true</value>
<valuelist type="QVariantList" key="CustomOutputParsers"/>
<value type="int" key="PE.EnvironmentAspect.Base">2</value>
<valuelist type="QVariantList" key="PE.EnvironmentAspect.Changes"/>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.CustomExecutableRunConfiguration</value>
<value type="QString" key="ProjectExplorer.RunConfiguration.BuildKey"></value>
<value type="bool" key="RunConfiguration.UseCppDebugger">false</value>
<value type="bool" key="RunConfiguration.UseCppDebuggerAuto">true</value>
<value type="bool" key="RunConfiguration.UseQmlDebugger">false</value>
<value type="bool" key="RunConfiguration.UseQmlDebuggerAuto">true</value>
</valuemap> </valuemap>
<value type="qlonglong" key="ProjectExplorer.Target.RunConfigurationCount">1</value> <value type="qlonglong" key="ProjectExplorer.Target.RunConfigurationCount">1</value>
</valuemap> </valuemap>
+168 -64
View File
@@ -33,7 +33,7 @@ static size_t WriteCallback(void *contents, size_t size, size_t nmemb, void *use
return size * nmemb; // On ne traite pas les données reçues return size * nmemb; // On ne traite pas les données reçues
} }
QMap <QByteArray, double> propertyList; QMap <QByteArray, QVariant> propertyList;
QMap <QByteArray, QPair<QString, QByteArray>> propertyName QMap <QByteArray, QPair<QString, QByteArray>> propertyName
{ {
{"tempf", {"Température extérieure", "°C"}}, {"tempf", {"Température extérieure", "°C"}},
@@ -41,12 +41,12 @@ QMap <QByteArray, QPair<QString, QByteArray>> propertyName
{"dewptf", {"Point de rosée", "°C"}}, {"dewptf", {"Point de rosée", "°C"}},
{"windchillf", {"Température ressentie", "°C"}}, {"windchillf", {"Température ressentie", "°C"}},
{"winddir", {"Direction du vent", "°"}}, {"winddir", {"Direction du vent", "°"}},
{"windspeedmph", {"vitesse du vent", "km/h"}}, {"windspeedmph", {"vitesse du vent", " km/h"}},
{"windgustmph", {"Rafales", "km/h"}}, {"windgustmph", {"Rafales", " km/h"}},
{"rainin", {"Pluie", "mm/h"}}, {"rainin", {"Pluie", " mm/h"}},
{"dailyrainin", {"Pluie de la journée", "mm"}}, {"dailyrainin", {"Pluie de la journée", " mm"}},
{"monthlyrainin", {"Pluie du mois", "mm"}}, {"monthlyrainin", {"Pluie du mois", " mm"}},
{"yearlyrainin", {"Pluie de l'année", "mm"}}, {"yearlyrainin", {"Pluie de l'année", " mm"}},
{"solarradiation", {"Énergie solaire", " W/m²"}}, {"solarradiation", {"Énergie solaire", " W/m²"}},
{"indoortempf", {"Température intérieure", "°C"}}, {"indoortempf", {"Température intérieure", "°C"}},
{"indoorhumidity", {"Humidité intérieure", "%"}}, {"indoorhumidity", {"Humidité intérieure", "%"}},
@@ -55,6 +55,22 @@ QMap <QByteArray, QPair<QString, QByteArray>> propertyName
{"UV", {"Alerte UV", ""}} {"UV", {"Alerte UV", ""}}
}; };
QList <QList <QVariant>> forceVent
{
// { max wind speed, name, priority}
{1, "Temps calme", 1},
{5, "Très légère brise", 1},
{11, "Légère brise", 1},
{19, "Petite brise", 1},
{28, "Jolie brise", 1},
{38, "Bonne brise", 1},
{49, "Vent frais", 3},
{61, "Grand vent", 4},
{74, "Vent fort", 5},
{88, "Vent violent", 5},
{117, "Tempête", 5},
{1000, "Ouragan", 5}
};
Pws2mqtt::Pws2mqtt() Pws2mqtt::Pws2mqtt()
{ {
@@ -129,8 +145,9 @@ void Pws2mqtt::parseData(QList<std::pair<QString, QString>> queryList)
double propertyValue = 0; double propertyValue = 0;
QStringList priorityList {"", "min", "low", "default", "High", "urgent"}; QStringList priorityList {"", "min", "low", "default", "High", "urgent"};
quint8 priority = 2; quint8 priority = 2;
QPair <QByteArray, QByteArray> winddir = {"", 0}; static qreal winddir = 0;
QString attachment = ""; QString attachment = "";
bool changed = false;
debug(DEBUGMACRO, "looping list of query", DEBUG); debug(DEBUGMACRO, "looping list of query", DEBUG);
@@ -139,6 +156,7 @@ void Pws2mqtt::parseData(QList<std::pair<QString, QString>> queryList)
debug(DEBUGMACRO, pair.first + " = " + pair.second, DEBUG); debug(DEBUGMACRO, pair.first + " = " + pair.second, DEBUG);
QByteArray name = pair.first.toLatin1(); QByteArray name = pair.first.toLatin1();
QByteArray value = pair.second.toLatin1(); QByteArray value = pair.second.toLatin1();
float fValue = value.toDouble();
if (this->deviceProperties.contains(name)) if (this->deviceProperties.contains(name))
{ {
@@ -166,75 +184,105 @@ void Pws2mqtt::parseData(QList<std::pair<QString, QString>> queryList)
if (name == "tempf") if (name == "tempf")
{ {
static QDateTime timeTemp = QDateTime::currentDateTime().addSecs(-600); static QDateTime timeTemp = QDateTime::currentDateTime().addSecs(-600);
propertyValue = round(fahrenheitToCelsius(pair.second.toFloat())); propertyValue = round(fahrenheitToCelsius(fValue));
debug (DEBUGMACRO, "timeTemp = " + timeTemp.time().toString() + " - current :" + QDateTime::currentDateTime().toString() , DEBUG); debug (DEBUGMACRO, "timeTemp = " + timeTemp.time().toString() + " - current :" + QDateTime::currentDateTime().toString() , DEBUG);
if (compare (propertyList[name], propertyValue, 1) and timeTemp < QDateTime::currentDateTime()) if (compare (propertyList[name].toDouble(), propertyValue, 1) and timeTemp < QDateTime::currentDateTime())
{ {
notif += formatNotifString (propertyName[name].first, propertyName[name].second, QByteArray::number(qPow(propertyValue, 1.0))); //notif += formatNotifString (propertyName[name].first, propertyName[name].second, QByteArray::number(qPow(propertyValue, 1.0)));
debug (DEBUGMACRO, "Notif = #" + notif + "#", DEBUG); //debug (DEBUGMACRO, "", DEBUG);
timeTemp = timeTemp.currentDateTime().addSecs(300); timeTemp = timeTemp.currentDateTime().addSecs(300);
propertyList[name] = propertyValue; propertyList[name] = propertyValue;
changed = true;
} }
}else if (name == "indoortempf") /*}else if (name == "indoortempf")
{ {
static QDateTime timeIndoorTemp = QDateTime::currentDateTime().addSecs(-600); static QDateTime timeIndoorTemp = QDateTime::currentDateTime().addSecs(-600);
propertyValue = round(fahrenheitToCelsius(pair.second.toFloat())); propertyValue = round(fahrenheitToCelsius(pair.second.toFloat()));
if (compare (propertyList[name], propertyValue, 1) and timeIndoorTemp < QDateTime::currentDateTime()) if (compare (propertyList[name], propertyValue, 1) and timeIndoorTemp < QDateTime::currentDateTime())
{ {
notif += formatNotifString (propertyName[name].first, propertyName[name].second , QByteArray::number(qPow(propertyValue, 1.0))); //notif += formatNotifString (propertyName[name].first, propertyName[name].second , QByteArray::number(qPow(propertyValue, 1.0)));
debug (DEBUGMACRO, "Notif = #" + notif + "#", DEBUG); debug (DEBUGMACRO, "Notif = #" + notif + "#", DEBUG);
timeIndoorTemp = timeIndoorTemp.currentDateTime().addSecs(300); timeIndoorTemp = timeIndoorTemp.currentDateTime().addSecs(300);
propertyList[name] = propertyValue; propertyList[name] = propertyValue;
} }*/
}else if (name == "humidity") }else if (name == "humidity")
{ {
propertyValue = pair.second.toFloat(); propertyValue = value.toFloat();
if (compare (propertyList[name], propertyValue, 3)) debug (DEBUGMACRO, name + " : " + QByteArray::number(propertyValue), DEBUG);
if (compare (propertyList[name].toFloat(), propertyValue, 3))
{ {
notif += formatNotifString (propertyName[name].first, propertyName[name].second , value); //notif += formatNotifString (propertyName[name].first, propertyName[name].second , value);
debug (DEBUGMACRO, "Notif = #" + notif + "#", DEBUG);
propertyList[name] = propertyValue; propertyList[name] = propertyValue;
changed = true;
} }
}else if (name == "windchillf") }else if (name == "windchillf")
{ {
static QDateTime timeWindchill = QDateTime::currentDateTime().addSecs(-600); static QDateTime timeWindchill = QDateTime::currentDateTime().addSecs(-600);
propertyValue = round(fahrenheitToCelsius(pair.second.toFloat())); propertyValue = round(fahrenheitToCelsius(value.toFloat()));
if (compare (propertyList[name], propertyValue, 1) and timeWindchill < QDateTime::currentDateTime()) debug (DEBUGMACRO, name + " : " + QByteArray::number(propertyValue), DEBUG);
if (compare (propertyList[name].toFloat(), propertyValue, 1) and timeWindchill < QDateTime::currentDateTime())
{ {
notif += formatNotifString (propertyName[name].first, propertyName[name].second , QByteArray::number(qPow(propertyValue, 1.0))); //notif += formatNotifString (propertyName[name].first, propertyName[name].second , QByteArray::number(qPow(propertyValue, 1.0)));
debug (DEBUGMACRO, "Notif = #" + notif + "#", DEBUG); //debug (DEBUGMACRO, "Notif = #" + notif + "#", DEBUG);
timeWindchill = timeWindchill.currentDateTime().addSecs(300); timeWindchill = timeWindchill.currentDateTime().addSecs(300);
propertyList[name] = propertyValue; propertyList[name] = propertyValue;
changed = true;
} }
}else if (name == "winddir") }else if (name == "winddir")
{ {
winddir.first = name; winddir = value.toFloat();
winddir.second = value; rotateAndSaveImage(this->inputPath, this->outputPath, (qreal)winddir);
}else if (name == "windspeedmph") debug (DEBUGMACRO, name + " : " + QByteArray::number(propertyValue), DEBUG);
{
propertyValue = round(mphTokmh(pair.second.toFloat()));
if (compare (propertyList[name], propertyValue, 5))
{
if (propertyValue > 10)
{
priority = setPriority (priority, 2);
notif += formatNotifString (propertyName[name].first, propertyName[name].second , QByteArray::number(propertyValue));
notif += formatNotifString (winddir.first, winddir.second);
//TODO attache fleche
debug (DEBUGMACRO, "Notif = #" + notif + "#", DEBUG); }else if (name == "windspeedmph" or name == "windgustmph")
{
QString msg = "";
static QDateTime timeWind = QDateTime::currentDateTime().addSecs(-600);
quint8 windPriority = 1;
if (propertyValue > 30) debug (DEBUGMACRO, name + " : " + QByteArray::number(propertyValue), DEBUG);
priority = setPriority (priority, 4); propertyValue = round(mphTokmh(value.toFloat()));
if (propertyValue > 50) for (quint8 i=0; i<forceVent.size();i++)
priority = setPriority (priority, 5); {
propertyList[name] = propertyValue; if (propertyValue <= forceVent[i][0].toDouble())
attachment = this->inputPath; {
debug (DEBUGMACRO, "Notif = #" + notif + "#", DEBUG); msg = forceVent[i][1].toString();
windPriority = forceVent[i][1].toUInt();
break;
} }
} }
}else if (name == "windgustmph")
if (propertyList["forcevent"].toString() != msg or propertyList["rafales"].toString() != msg)
{
if (name == "windspeedmph")
{
propertyList["forcevent"] = msg;
msg.prepend("Vent - ");
}else
{
propertyList["rafales"] = msg;
msg.prepend("Rafales - ");
}
QString msgNotif = formatNotifString (msg, propertyName[name].second , QByteArray::number(propertyValue));
notif += msgNotif;
setPriority(priority, windPriority);
propertyList["winddir"] = winddir;
attachment = this->outputPath;
if (priority > 3)
{
notify(msgNotif, priorityList[priority], attachment);
}else if (timeWind < QDateTime::currentDateTime())
{
timeWind = timeWind.currentDateTime().addSecs(300);
changed = true;
}
debug (DEBUGMACRO, "Notif = *" + notif + "*", DEBUG);
}
/*}else if (name == "windgustmph")
{ {
propertyValue = round(mphTokmh(pair.second.toFloat())); propertyValue = round(mphTokmh(pair.second.toFloat()));
if (compare (propertyList[name], propertyValue, 5) and propertyValue > 20) if (compare (propertyList[name], propertyValue, 5) and propertyValue > 20)
@@ -246,7 +294,7 @@ void Pws2mqtt::parseData(QList<std::pair<QString, QString>> queryList)
priority = setPriority (priority, 5); priority = setPriority (priority, 5);
propertyList[name] = propertyValue; propertyList[name] = propertyValue;
debug (DEBUGMACRO, "Notif = #" + notif + "#", DEBUG); debug (DEBUGMACRO, "Notif = #" + notif + "#", DEBUG);
} }*/
}else if (name == "rainin") }else if (name == "rainin")
{ {
static double ecart; static double ecart;
@@ -258,31 +306,51 @@ void Pws2mqtt::parseData(QList<std::pair<QString, QString>> queryList)
{ {
ecart = 0.01; ecart = 0.01;
} }
if (compare (propertyList[name], propertyValue, ecart)) debug (DEBUGMACRO, name + " : " + QByteArray::number(propertyValue), DEBUG);
if (compare (propertyList[name].toFloat(), propertyValue, ecart))
{ {
notif += formatNotifString (propertyName[name].first, propertyName[name].second , value); //notif += formatNotifString (propertyName[name].first, propertyName[name].second , value);
priority = setPriority (priority, 4); priority = setPriority (priority, 4);
debug (DEBUGMACRO, "Notif = #" + notif + "#", DEBUG); //debug (DEBUGMACRO, "Notif = #" + notif + "#", DEBUG);
propertyList[name] = propertyValue; propertyList[name] = propertyValue;
changed = true;
} }
}else if (name == "baromin") }else if (name == "baromin")
{ {
propertyValue = tohPa(pair.second.toFloat()); propertyValue = tohPa(pair.second.toFloat());
debug (DEBUGMACRO, "Notif = #" + notif + "#", DEBUG); debug (DEBUGMACRO, "Barometre en hPa : " + QByteArray::number(propertyValue), DEBUG);
if (compare (propertyList[name], propertyValue, 5)) if (compare (propertyList[name].toFloat(), propertyValue, 0.5))
{ {
pressureVariation(propertyValue); //notif += formatNotifString (propertyName[name].first, propertyName[name].second , QByteArray::number(propertyValue));
//debug (DEBUGMACRO, "Notif = #" + notif + "#", DEBUG);
notif += formatNotifString (propertyName[name].first, propertyName[name].second , QByteArray::number(propertyValue));
propertyList[name] = propertyValue; propertyList[name] = propertyValue;
changed = true;
}
static double prevision;
QString ret = pressureVariation(propertyValue);
if (!ret.isEmpty())
{
debug (DEBUGMACRO, "baromin ret not empty : " + QByteArray::number(propertyValue), DEBUG);
QStringList liste = ret.split(",");
double newPrevision = liste[1].toInt();
if (prevision != newPrevision)
{
prevision = newPrevision;
propertyList["prevision"] = prevision;
//notif += prevision + " \n";
//debug (DEBUGMACRO, "Notif = #" + notif + "#", DEBUG);
changed = true;
}
} }
}else if (name == "UV") }else if (name == "UV")
{ {
static QDateTime timeUV = QDateTime::currentDateTime().addSecs(-600); static QDateTime timeUV = QDateTime::currentDateTime().addSecs(-600);
propertyValue = pair.second.toFloat(); propertyValue = pair.second.toFloat();
if (compare (propertyList[name], propertyValue, 1) and timeUV < QDateTime::currentDateTime())
debug (DEBUGMACRO, name + " : " + QByteArray::number(propertyValue), DEBUG);
if (compare (propertyList[name].toFloat(), propertyValue, 1) and timeUV < QDateTime::currentDateTime())
{ {
notif += formatNotifString (propertyName[name].first, propertyName[name].second , value); //notif += formatNotifString (propertyName[name].first, propertyName[name].second , value);
if (propertyValue == 5 ) if (propertyValue == 5 )
priority = setPriority (priority, 3); priority = setPriority (priority, 3);
if (propertyValue >= 6 ) if (propertyValue >= 6 )
@@ -291,22 +359,23 @@ void Pws2mqtt::parseData(QList<std::pair<QString, QString>> queryList)
propertyList[name] = propertyValue; propertyList[name] = propertyValue;
debug (DEBUGMACRO, "Notif = #" + notif + "#", DEBUG); debug (DEBUGMACRO, "Notif = #" + notif + "#", DEBUG);
} }
}else if (name == "lowbat") }/*else if (name == "lowbat")
{ {
static QDateTime timeLowBat = QDateTime::currentDateTime().addSecs(-4000); static QDateTime timeLowBat = QDateTime::currentDateTime().addSecs(-4000);
if (pair.second.toInt() == 0 and timeLowBat < QDateTime::currentDateTime()) if (pair.second.toInt() == 0 and timeLowBat < QDateTime::currentDateTime())
{ {
notif += formatNotifString (propertyName[name].first, propertyName[name].second ); //notif += formatNotifString (propertyName[name].first, propertyName[name].second );
debug (DEBUGMACRO, "Notif = #" + notif + "#", DEBUG); //debug (DEBUGMACRO, "Notif = #" + notif + "#", DEBUG);
priority = setPriority (priority, 4); priority = setPriority (priority, 4);
timeLowBat = timeLowBat.currentDateTime().addSecs(3600); timeLowBat = timeLowBat.currentDateTime().addSecs(3600);
propertyList[name] = propertyValue; propertyList[name] = propertyValue;
} }
} }*/
} }
} }
if (!jsonString.isEmpty()) if (!jsonString.isEmpty())
{ {
debug(DEBUGMACRO, "json string : " + jsonString, DEBUG);
jsonString = jsonString +", " + deviceString + "}}"; jsonString = jsonString +", " + deviceString + "}}";
mqttClient->send_message(jsonString); mqttClient->send_message(jsonString);
}else }else
@@ -314,16 +383,49 @@ void Pws2mqtt::parseData(QList<std::pair<QString, QString>> queryList)
debug(DEBUGMACRO, "No values to send", DEBUG); debug(DEBUGMACRO, "No values to send", DEBUG);
} }
if (!notif.isEmpty()) if (changed)
{ {
debug(DEBUGMACRO, "looping to fill notif", DEBUG);
for (auto [name, value]: propertyList.asKeyValueRange())
{
QString unit;
QByteArray valueBA;
debug(DEBUGMACRO, "Name = " + name + ", value = " + QString::number(value.toUInt()), DEBUG);
if (! propertyName.contains(name))
{
unit = "";
debug(DEBUGMACRO, "unit is empty ", DEBUG);
}else
{
unit = propertyName[name].second;
debug(DEBUGMACRO, "unit : " + unit, DEBUG);
QString dataType = value.typeName();
debug(DEBUGMACRO, "datatype is : " + dataType, DEBUG);
if (dataType == "double")
{
debug(DEBUGMACRO, "datatype is 'double'", DEBUG);
valueBA = QByteArray::number(value.toFloat());
}else if (dataType == "QString")
{
debug(DEBUGMACRO, "datatype is 'QString'" + value.toString(), DEBUG);
valueBA = value.toByteArray();
}else
{
debug(DEBUGMACRO, "datatype is null" + QString::number(value.toUInt()), DEBUG);
valueBA = value.toByteArray();
}
notif += formatNotifString(propertyName[name].first, unit, valueBA);
}
}
debug(DEBUGMACRO, "calling notify with notif = #" + notif + "#", DEBUG); debug(DEBUGMACRO, "calling notify with notif = #" + notif + "#", DEBUG);
notify (notif, priorityList[priority]); notify (notif, priorityList[priority], attachment);
} }
debug(DEBUGMACRO, "parseData: Returning", DEBUG); debug(DEBUGMACRO, "parseData: Returning", DEBUG);
} }
quint8 previsionMeteo(double currentPressure, double variation3h) quint8 previsionMeteo(double currentPressure, double variation3h)
{ {
debug (DEBUGMACRO, "begin", DEBUG);
if (currentPressure > 1020.0 && variation3h >= 0.0) if (currentPressure > 1020.0 && variation3h >= 0.0)
{ {
return 0; return 0;
@@ -386,8 +488,10 @@ QString pressureVariation(double currentPressure)
{ {
priority = "urgent"; priority = "urgent";
} }
return previsionList[prevision] + "," + priority; debug(DEBUGMACRO, "ending pressureVariation with result", DEBUG);
return QByteArray::number(prevision) + "," + priority;
} }
debug(DEBUGMACRO, "ending pressureVariation no result", DEBUG);
return ""; return "";
} }
@@ -409,7 +513,7 @@ double fahrenheitToCelsius (double fahrenheit)
double tohPa (double value) double tohPa (double value)
{ {
return value * 33.8639; return round(value * 33.8639 * 100) / 100;
} }
double mphTokmh (double value) double mphTokmh (double value)
+3 -3
View File
@@ -20,7 +20,7 @@
#define ERROR 8 // => 8 #define ERROR 8 // => 8
#define ALERT 32 #define ALERT 32
#define ALL DEBUG | INFO | NOTICE | WARNING | ERROR | ALERT #define ALL DEBUG | INFO | NOTICE | WARNING | ERROR | ALERT
#define DEBUGMACRO QString(__FILE__) + ": " + QString::number(__LINE__) + " -> " + QString(Q_FUNC_INFO) #define DEBUGMACRO QString(__FILE__) + ": " + QString::number(__LINE__) + " -> "
void debug(QString debugHeader, QString msg, uint8_t level=ALL, QByteArray value=""); void debug(QString debugHeader, QString msg, uint8_t level=ALL, QByteArray value="");
//QString addValue(QByteArray value); //QString addValue(QByteArray value);
@@ -39,8 +39,8 @@ class Pws2mqtt : public QObject
uint listenPort = 5000; uint listenPort = 5000;
int sockfd = 0; int sockfd = 0;
int newsockfd = 0; int newsockfd = 0;
QString inputPath = "./fleche.png"; QString inputPath = "/usr/local/share/pws2mqtt/fleche.png";
QString outpuPath = "/tmp/pws2mqttFleche.png"; QString outputPath = "/tmp/pws2mqttFleche.png";
QList <QString> deviceProperties = QList <QString> deviceProperties =
{ {
"ieeeAddress", "type", "dateutc", "softwaretype", "action", "realtime", "freq", "wh65batt", "wh25batt", "runtime" "ieeeAddress", "type", "dateutc", "softwaretype", "action", "realtime", "freq", "wh65batt", "wh25batt", "runtime"
+1 -1
View File
@@ -3,6 +3,6 @@
#include <string> #include <string>
std::string version = "1.0.39"; std::string version = "1.0.69";
#endif // VERSION_H #endif // VERSION_H