diff --git a/src/pws2mqtt.cpp b/src/pws2mqtt.cpp index 4ef8e1f..b18d4dd 100644 --- a/src/pws2mqtt.cpp +++ b/src/pws2mqtt.cpp @@ -276,26 +276,29 @@ void Pws2mqtt::parseData(QList> queryList) propertyList[name] = formatNotifString(propertyName[name], QByteArray::number(propertyValue)); propertiesValue[name] = propertyValue; debug (DEBUGMACRO, name + " : " + QByteArray::number(propertyValue) + " announced = " + QByteArray::number(announced[name]), DEBUG); - if (qRound(propertyValue) >= 35) + quint8 valueRounded = qRound(propertyValue + 0.5); + QString alertString = formatNotifString(propertyName[name], QByteArray::number(valueRounded)); + + if (valueRounded >= 35) { if (announced[name] != 5) { debug(DEBUGMACRO, "Nofifying external temp >= 35°C", DEBUG); - notify (propertyList[name], priorityList[5]); + notify (alertString, priorityList[5]); announced[name] = 5; } - }else if (qRound(propertyValue) >= 27) + }else if (qRound(propertyValue + 0.5) >= 27) { if (announced[name] != 4) { debug(DEBUGMACRO, "Nofifying external temp >= 27°C", DEBUG); - notify (propertyList[name], priorityList[4]); + notify (alertString, priorityList[4]); announced[name] = 4; } }else if (announced[name] != 0) { debug(DEBUGMACRO, "Nofifying external temp < 27°C", DEBUG); - notify (propertyList[name], priorityList[4]); + notify (alertString, priorityList[4]); announced[name] = 0; } } @@ -487,7 +490,7 @@ void Pws2mqtt::parseData(QList> queryList) //debug (DEBUGMACRO, "Notif = #" + notif + "#", DEBUG); propertyList[name] = "- UV - " + QByteArray::number(propertyValue) + "\n"; - if (propertyValue >= 5) + if (propertyValue > 5) { if (announced[name] != propertyValue) { @@ -497,7 +500,9 @@ void Pws2mqtt::parseData(QList> queryList) } }else { + notify (propertyList[name], priorityList[priority[name]]); announced[name] = 0; + debug (DEBUGMACRO, "Notifying : " + name + " is " + QString::number(propertyValue), DEBUG); } } }else if (name == "solarradiation") @@ -550,7 +555,7 @@ void Pws2mqtt::parseData(QList> queryList) debug(DEBUGMACRO, "looping to fill notif", DEBUG); QTime currentTime = QTime::currentTime(); - if (currentTime.minute() == 0 or start == false) + if ((currentTime.minute() == 0 and currentTime.second() <= 30)or start == false) { timer = QDateTime::currentDateTime(); start = true;