From 1f00d24154bc546d21af817bf3b32d3f5c42ab46 Mon Sep 17 00:00:00 2001 From: Daniel Tartavel Date: Sat, 4 Oct 2025 23:05:36 +0200 Subject: [PATCH] =?UTF-8?q?modif=20notifications=20une=20seule=20notificat?= =?UTF-8?q?ion=20avec=20tous=20les=20param=C3=A8tres\ndebug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- fleche.png | Bin 2070 -> 0 bytes main.cpp | 3 +- pws2mqtt-qt.pro.user | 186 ++++++++++++++++++---------------- pws2mqtt.cpp | 232 +++++++++++++++++++++++++++++++------------ pws2mqtt.h | 6 +- version.h | 2 +- 6 files changed, 275 insertions(+), 154 deletions(-) delete mode 100644 fleche.png diff --git a/fleche.png b/fleche.png deleted file mode 100644 index eca26ea8db597f7415fb3d59a28d695ecd9ab39c..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 2070 zcmV+x2-m!Dp_Z!_pz=km2s&&IcIwc6R&Vo$W#~ zoZ+0N^Kz@Zo!@-tGc&*6Z+^#ex!liDz9s;u8$9p0DJXAKpYpuprj?oGJZ1iHQklng&hNFflO!BD&$y z6kimgVsUXX#u$U+IB*;Xj4>1ng;+U6mP4qd`O)3GcL4ylZNs*006;7j0}*{x4yt7# zYMSN)#uyakKjsug0b>lNX+HR06O}YS7#SJyXv(FRR7XZeKtvzxlxjJM797Wcsy^{R zj4?3Ao;XrfmBJTyItbflWRkw|4>dJ4tCAi7IF929_6A`L^Yil+0N&cJU)>Q=B6=u< zfTAeglKTZajsrzeVB0o`=;7y0R1*2Hwzl@6+?Ts|?}nynSXfv909033!?G+aE-peI zv`i+m55SMMLsi)UO~bM*Zy$DabbQ><(BS>v(9nR6j*csG|5}y>BKqg&b(kcHzeJP=h z{M}F}gkrG>#u!FNN4o)Be^#o>HfX-Hva;gQ?CRLWTL!*P!#|;=RdBfsPL$cjg1Wg7=9M2$}`e@b7^VG zquJfvodED1Ig#~#)Fl{|#dd zwr$JP9NIyC5%Sxbnwt6*fX}v?uu=len%UV|XqpBg1bTXUz&U?=8;OPL27sTPJb4mA z2xyvyxw$zI(f+NdDq9%NOixe0?eFK^TK&3w~b?;A=>%>Z`uXlEKLI?p>Rgp@iKt$$dlT$XKxim8~ zbJ-tlDl02nHkgnU9VrwF9??Rf006gq2WgFfUAuO*_@h`VmHLw#a@A6WN}BhR$)rcK zwY3$T^D{nSru(T9(apBDw!f#-X-{Z6oyM_a$NoV?(y9CV2+sL8TU%Q_s?*ccAfo$E zqpCcG=1Mx9z9wlpj)Usz>QexM09IT>K>*i@=$D3JglA@EpsK2OuUAzSv$L}>4C50b z`Za*RxqXCdL#?i^KIOk-rPJwa^0%#oN}9J5iG)Y<@ZrPYoOiiKDqV`1=H})*hGA5z zs_JGSz~*iUo+ z{{7!|jeiNiheJa{7YxI=G(SI&U@!>VwqaQoT3T9=&1SVsCR1_z_;Fa41tA22!60(E z91O#_I5;?X0l-DqR^`5Z`@Zd`n#<+FTP?jTC|n&MANTG#jg5`qoF4(OLPS;d_4N-U zk%(6eGffl0U=X^lzklo2t)Buo58$og;o-M+UH@$;6oP4*9_eT_in_YGJP|bjc*Hqx zX>4rtLUTMG2N7Lep920@eRO$wIU#8>#?aK%bQ-`NUDpfocpLx_3;LAfpLk}a7$eO-}VVvvj?Zxfew=0^On!>46>ZTlXd3iYj;1?TR zmnF?h;cz%3opEh#Esh>NdLt5v3>J$;XqpDcaUg_1RaF(*+S-1?Ip4iWDct*xh%)hb z{8BELgQ}|VCpdk5eZz@F;#4}F_G$zJ0|Rw_pS@;}T9%dZN0)_#1sH}gSS%J12n4)6 zr|bITWHQ<6iWHlKQ_qKT&TEs&WS6e%3qlB3mW4nd03ien!#FiRKfflbS(Y`sp6Gd( z=6m6Ac+Dnu9A^#1y1F_XI&|nI&iPkmAzg^}-`fVoQs`cuo11$uH8tgxexwdXQIO4McL6x7xGzU! zG?51h0CZiya_7#S@4F(mL$MUPuSTQMAL_b(g)!!3|1!!EQN-^@8)fm;wr#Yxx6Azz z1<>e^>t+5=O2+?s&Uw_fZPwY@>FIEn|118bzu4a1p3mp==;-M99p^mdMh;PCai!D_ z1QFH8VzKj8RaJ<^VlM!AgO&L&#^=@){GYUc1HTA1Eb%w&aR2}S07*qoM6N<$g4D3- AKL7v# diff --git a/main.cpp b/main.cpp index ad887c1..16cb376 100644 --- a/main.cpp +++ b/main.cpp @@ -91,9 +91,10 @@ int main(int argc, char *argv[]) void debug(QString debugHeader, QString msg, uint8_t level, QByteArray property) { + msg.replace("\n", "\\n"); 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) { diff --git a/pws2mqtt-qt.pro.user b/pws2mqtt-qt.pro.user index ca68089..58670d4 100644 --- a/pws2mqtt-qt.pro.user +++ b/pws2mqtt-qt.pro.user @@ -1,6 +1,6 @@ - + EnvironmentId @@ -85,6 +85,97 @@ ProjectExplorer.Project.Target.0 + + Desktop + Qt 6.4.1 (qt6) + Qt 6.4.1 (qt6) + {17b0ba8e-e6fe-4c71-98eb-9b4d3bcc4307} + 0 + 0 + 0 + + 0 + /home/daniel/develop/build-pws2mqtt-qt-Desktop-Debug + /home/daniel/develop/build-pws2mqtt-qt-Desktop-Debug + + + true + -x versioning -s 1 + bash + %{ActiveProject:NativePath} + ProjectExplorer.ProcessStep + + + true + QtProjectManager.QMakeBuildStep + false + + + + true + Qt4ProjectManager.MakeStep + + 3 + Build + Build + ProjectExplorer.BuildSteps.Build + + + + true + Qt4ProjectManager.MakeStep + clean + + 1 + Clean + Clean + ProjectExplorer.BuildSteps.Clean + + 2 + false + + false + + Debug + Qt4ProjectManager.Qt4BuildConfiguration + 2 + + 1 + + + 0 + Deploy + Deploy + ProjectExplorer.BuildSteps.Deploy + + 1 + + false + ProjectExplorer.DefaultDeployConfiguration + + 1 + + true + true + true + + 2 + + Qt4ProjectManager.Qt4RunConfiguration:/home/daniel/develop/pws2mqtt-qt/pws2mqtt-qt.pro + /home/daniel/develop/pws2mqtt-qt/pws2mqtt-qt.pro + false + true + true + false + true + false + /home/daniel/develop/build-pws2mqtt-qt-Desktop-Debug + + 1 + + + + ProjectExplorer.Project.Target.1 Desktop Desktop @@ -99,16 +190,23 @@ /home/daniel/develop/build-pws2mqtt-qt-Desktop-Debug + true + -s 1 + versioning + %{buildDir} + ProjectExplorer.ProcessStep + + true QtProjectManager.QMakeBuildStep false - + true Qt4ProjectManager.MakeStep - 2 + 3 Build Build ProjectExplorer.BuildSteps.Build @@ -243,88 +341,6 @@ true false true - /home/daniel/develop/build-pws2mqtt-qt-Desktop-Debug - - 1 - - - - ProjectExplorer.Project.Target.1 - - Desktop - Qt 6.4.1 (qt6) - Qt 6.4.1 (qt6) - {17b0ba8e-e6fe-4c71-98eb-9b4d3bcc4307} - 0 - 0 - 0 - - 0 - /home/daniel/develop/build-pws2mqtt-qt-Desktop-Debug - /home/daniel/develop/build-pws2mqtt-qt-Desktop-Debug - - - true - QtProjectManager.QMakeBuildStep - true - - - - true - Qt4ProjectManager.MakeStep - - 2 - Build - Build - ProjectExplorer.BuildSteps.Build - - - - true - Qt4ProjectManager.MakeStep - clean - - 1 - Clean - Clean - ProjectExplorer.BuildSteps.Clean - - 2 - false - - false - - Debug - Qt4ProjectManager.Qt4BuildConfiguration - 2 - - 1 - - - 0 - Deploy - Deploy - ProjectExplorer.BuildSteps.Deploy - - 1 - - false - ProjectExplorer.DefaultDeployConfiguration - - 1 - - true - true - true - - 2 - - ProjectExplorer.CustomExecutableRunConfiguration - - false - true - false - true 1 diff --git a/pws2mqtt.cpp b/pws2mqtt.cpp index 613a61c..39026c4 100644 --- a/pws2mqtt.cpp +++ b/pws2mqtt.cpp @@ -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 } -QMap propertyList; +QMap propertyList; QMap > propertyName { {"tempf", {"Température extérieure", "°C"}}, @@ -41,12 +41,12 @@ QMap > propertyName {"dewptf", {"Point de rosée", "°C"}}, {"windchillf", {"Température ressentie", "°C"}}, {"winddir", {"Direction du vent", "°"}}, - {"windspeedmph", {"vitesse du vent", "km/h"}}, - {"windgustmph", {"Rafales", "km/h"}}, - {"rainin", {"Pluie", "mm/h"}}, - {"dailyrainin", {"Pluie de la journée", "mm"}}, - {"monthlyrainin", {"Pluie du mois", "mm"}}, - {"yearlyrainin", {"Pluie de l'année", "mm"}}, + {"windspeedmph", {"vitesse du vent", " km/h"}}, + {"windgustmph", {"Rafales", " km/h"}}, + {"rainin", {"Pluie", " mm/h"}}, + {"dailyrainin", {"Pluie de la journée", " mm"}}, + {"monthlyrainin", {"Pluie du mois", " mm"}}, + {"yearlyrainin", {"Pluie de l'année", " mm"}}, {"solarradiation", {"Énergie solaire", " W/m²"}}, {"indoortempf", {"Température intérieure", "°C"}}, {"indoorhumidity", {"Humidité intérieure", "%"}}, @@ -55,6 +55,22 @@ QMap > propertyName {"UV", {"Alerte UV", ""}} }; +QList > 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() { @@ -129,8 +145,9 @@ void Pws2mqtt::parseData(QList> queryList) double propertyValue = 0; QStringList priorityList {"", "min", "low", "default", "High", "urgent"}; quint8 priority = 2; - QPair winddir = {"", 0}; + static qreal winddir = 0; QString attachment = ""; + bool changed = false; debug(DEBUGMACRO, "looping list of query", DEBUG); @@ -139,6 +156,7 @@ void Pws2mqtt::parseData(QList> queryList) debug(DEBUGMACRO, pair.first + " = " + pair.second, DEBUG); QByteArray name = pair.first.toLatin1(); QByteArray value = pair.second.toLatin1(); + float fValue = value.toDouble(); if (this->deviceProperties.contains(name)) { @@ -166,75 +184,105 @@ void Pws2mqtt::parseData(QList> queryList) if (name == "tempf") { 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); - 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))); - debug (DEBUGMACRO, "Notif = #" + notif + "#", DEBUG); + //notif += formatNotifString (propertyName[name].first, propertyName[name].second, QByteArray::number(qPow(propertyValue, 1.0))); + //debug (DEBUGMACRO, "", DEBUG); timeTemp = timeTemp.currentDateTime().addSecs(300); propertyList[name] = propertyValue; + changed = true; } - }else if (name == "indoortempf") + /*}else if (name == "indoortempf") { static QDateTime timeIndoorTemp = QDateTime::currentDateTime().addSecs(-600); propertyValue = round(fahrenheitToCelsius(pair.second.toFloat())); 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); timeIndoorTemp = timeIndoorTemp.currentDateTime().addSecs(300); propertyList[name] = propertyValue; - } + }*/ }else if (name == "humidity") { - propertyValue = pair.second.toFloat(); - if (compare (propertyList[name], propertyValue, 3)) + propertyValue = value.toFloat(); + debug (DEBUGMACRO, name + " : " + QByteArray::number(propertyValue), DEBUG); + + if (compare (propertyList[name].toFloat(), propertyValue, 3)) { - notif += formatNotifString (propertyName[name].first, propertyName[name].second , value); - debug (DEBUGMACRO, "Notif = #" + notif + "#", DEBUG); + //notif += formatNotifString (propertyName[name].first, propertyName[name].second , value); propertyList[name] = propertyValue; + changed = true; } }else if (name == "windchillf") { static QDateTime timeWindchill = QDateTime::currentDateTime().addSecs(-600); - propertyValue = round(fahrenheitToCelsius(pair.second.toFloat())); - if (compare (propertyList[name], propertyValue, 1) and timeWindchill < QDateTime::currentDateTime()) + propertyValue = round(fahrenheitToCelsius(value.toFloat())); + 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))); - debug (DEBUGMACRO, "Notif = #" + notif + "#", DEBUG); + //notif += formatNotifString (propertyName[name].first, propertyName[name].second , QByteArray::number(qPow(propertyValue, 1.0))); + //debug (DEBUGMACRO, "Notif = #" + notif + "#", DEBUG); timeWindchill = timeWindchill.currentDateTime().addSecs(300); propertyList[name] = propertyValue; + changed = true; } }else if (name == "winddir") { - winddir.first = name; - winddir.second = value; - }else if (name == "windspeedmph") + winddir = value.toFloat(); + rotateAndSaveImage(this->inputPath, this->outputPath, (qreal)winddir); + debug (DEBUGMACRO, name + " : " + QByteArray::number(propertyValue), DEBUG); + + }else if (name == "windspeedmph" or name == "windgustmph") { - propertyValue = round(mphTokmh(pair.second.toFloat())); - if (compare (propertyList[name], propertyValue, 5)) + QString msg = ""; + static QDateTime timeWind = QDateTime::currentDateTime().addSecs(-600); + quint8 windPriority = 1; + + debug (DEBUGMACRO, name + " : " + QByteArray::number(propertyValue), DEBUG); + propertyValue = round(mphTokmh(value.toFloat())); + for (quint8 i=0; i 10) + if (propertyValue <= forceVent[i][0].toDouble()) { - 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); - - if (propertyValue > 30) - priority = setPriority (priority, 4); - if (propertyValue > 50) - priority = setPriority (priority, 5); - propertyList[name] = propertyValue; - 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())); if (compare (propertyList[name], propertyValue, 5) and propertyValue > 20) @@ -246,7 +294,7 @@ void Pws2mqtt::parseData(QList> queryList) priority = setPriority (priority, 5); propertyList[name] = propertyValue; debug (DEBUGMACRO, "Notif = #" + notif + "#", DEBUG); - } + }*/ }else if (name == "rainin") { static double ecart; @@ -258,31 +306,51 @@ void Pws2mqtt::parseData(QList> queryList) { 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); - debug (DEBUGMACRO, "Notif = #" + notif + "#", DEBUG); + //debug (DEBUGMACRO, "Notif = #" + notif + "#", DEBUG); propertyList[name] = propertyValue; + changed = true; } }else if (name == "baromin") { propertyValue = tohPa(pair.second.toFloat()); - debug (DEBUGMACRO, "Notif = #" + notif + "#", DEBUG); - if (compare (propertyList[name], propertyValue, 5)) + debug (DEBUGMACRO, "Barometre en hPa : " + QByteArray::number(propertyValue), DEBUG); + if (compare (propertyList[name].toFloat(), propertyValue, 0.5)) { - pressureVariation(propertyValue); - - notif += formatNotifString (propertyName[name].first, propertyName[name].second , QByteArray::number(propertyValue)); + //notif += formatNotifString (propertyName[name].first, propertyName[name].second , QByteArray::number(propertyValue)); + //debug (DEBUGMACRO, "Notif = #" + notif + "#", DEBUG); 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") - { + { static QDateTime timeUV = QDateTime::currentDateTime().addSecs(-600); 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 ) priority = setPriority (priority, 3); if (propertyValue >= 6 ) @@ -291,22 +359,23 @@ void Pws2mqtt::parseData(QList> queryList) propertyList[name] = propertyValue; debug (DEBUGMACRO, "Notif = #" + notif + "#", DEBUG); } - }else if (name == "lowbat") + }/*else if (name == "lowbat") { static QDateTime timeLowBat = QDateTime::currentDateTime().addSecs(-4000); if (pair.second.toInt() == 0 and timeLowBat < QDateTime::currentDateTime()) { - notif += formatNotifString (propertyName[name].first, propertyName[name].second ); - debug (DEBUGMACRO, "Notif = #" + notif + "#", DEBUG); + //notif += formatNotifString (propertyName[name].first, propertyName[name].second ); + //debug (DEBUGMACRO, "Notif = #" + notif + "#", DEBUG); priority = setPriority (priority, 4); timeLowBat = timeLowBat.currentDateTime().addSecs(3600); propertyList[name] = propertyValue; } - } + }*/ } } if (!jsonString.isEmpty()) { + debug(DEBUGMACRO, "json string : " + jsonString, DEBUG); jsonString = jsonString +", " + deviceString + "}}"; mqttClient->send_message(jsonString); }else @@ -314,16 +383,49 @@ void Pws2mqtt::parseData(QList> queryList) 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); - notify (notif, priorityList[priority]); + notify (notif, priorityList[priority], attachment); } debug(DEBUGMACRO, "parseData: Returning", DEBUG); } quint8 previsionMeteo(double currentPressure, double variation3h) { + debug (DEBUGMACRO, "begin", DEBUG); if (currentPressure > 1020.0 && variation3h >= 0.0) { return 0; @@ -386,8 +488,10 @@ QString pressureVariation(double currentPressure) { 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 ""; } @@ -409,7 +513,7 @@ double fahrenheitToCelsius (double fahrenheit) double tohPa (double value) { - return value * 33.8639; + return round(value * 33.8639 * 100) / 100; } double mphTokmh (double value) diff --git a/pws2mqtt.h b/pws2mqtt.h index 4631d69..ffe9944 100644 --- a/pws2mqtt.h +++ b/pws2mqtt.h @@ -20,7 +20,7 @@ #define ERROR 8 // => 8 #define ALERT 32 #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=""); //QString addValue(QByteArray value); @@ -39,8 +39,8 @@ class Pws2mqtt : public QObject uint listenPort = 5000; int sockfd = 0; int newsockfd = 0; - QString inputPath = "./fleche.png"; - QString outpuPath = "/tmp/pws2mqttFleche.png"; + QString inputPath = "/usr/local/share/pws2mqtt/fleche.png"; + QString outputPath = "/tmp/pws2mqttFleche.png"; QList deviceProperties = { "ieeeAddress", "type", "dateutc", "softwaretype", "action", "realtime", "freq", "wh65batt", "wh25batt", "runtime" diff --git a/version.h b/version.h index 2baadc4..a6bac64 100644 --- a/version.h +++ b/version.h @@ -3,6 +3,6 @@ #include -std::string version = "1.0.39"; +std::string version = "1.0.69"; #endif // VERSION_H