This commit is contained in:
2025-11-01 14:08:39 +01:00
parent f80313eaa5
commit eb346b104c
4 changed files with 41 additions and 79 deletions

View File

@@ -139,7 +139,7 @@ public:
QStringList icons;
// Logique combinée pression / tendance
if (p < 990 && d3 <= -3.0)
if (p < 990 && d3 <= -3.0)
{
r.message = "- Tempête ou orage";
r.urgency = 5;
@@ -157,24 +157,30 @@ public:
r.urgency = 0;
icons << "sunny";
debug(DEBUGMACRO, "message : " + r.message, DEBUG);
}else if (p >= 1020 && d3 < -3.0)
}else if (p >= 1020 && (d3 <= +0.5 && d3 >= -0.5))
{
r.message = "- Beau temps stable";
r.urgency = 0;
icons << "sunny";
debug(DEBUGMACRO, "message : " + r.message, DEBUG);
}else if (p >= 1020 && d3 < -3.0)
{
r.message = "- Beau, mais rapide dégradation";
r.urgency = 4;
icons << "sun_behind_large_cloud";
debug(DEBUGMACRO, "message : " + r.message, DEBUG);
}else if (p >= 1020 && d3 < -1.0)
}else if (p >= 1020 && d3 < -1.0)
{
r.message = "- Beau, mais possible dégradation";
r.urgency = 1;
icons << "sun_behind_small_cloud";
debug(DEBUGMACRO, "message : " + r.message, DEBUG);
/*}else if (p >= 1020 && d3 < 0.5.0)
}else if (p >= 1020 && (d3 <= 0.5 && d3 >= -0.5))
{
r.message = "- Beau temps";
r.message = "- Beau temps stable";
r.urgency = 0;
icons << "sunny";
debug(DEBUGMACRO, "message : " + r.message, DEBUG);*/
debug(DEBUGMACRO, "message : " + r.message, DEBUG);
}else if (p >= 1010 && d3 >= +3.0)
{
r.message = "- Nuageux, rapide amélioration";
@@ -199,7 +205,7 @@ public:
r.urgency = 2;
icons << "sun_behind_rain_cloud";
debug(DEBUGMACRO, "message : " + r.message, DEBUG);
}else if (p >= 1010 && d3 <= 0.5)
}else if (p >= 1010 && (d3 <= 0.5 && d3 >= 0.5))
{
r.message = "- Nuageux avec des éclaircies";
r.urgency = 2;
@@ -225,11 +231,17 @@ public:
debug(DEBUGMACRO, "message : " + r.message, DEBUG);
}else if (p >= 1000 && d3 <= -1.0)
{
r.message = "- Pluie ou perturbation";
r.message = "- Pluie ou perturbation stable";
r.urgency = 2;
icons << "cloud_with_rain";
debug(DEBUGMACRO, "message : " + r.message, DEBUG);
}else if (p < 1000 && d3 >= +3.0)
}else if (p >= 1000 && (d3 <= 0.5 && d3 >= -0.5))
{
r.message = "- Pluie ou perturbation";
r.urgency = 2;
icons << "cloud_with_rain";
debug(DEBUGMACRO, "message : " + r.message, DEBUG);
}else if (p < 1000 && d3 >= +3.0)
{
r.message = "- Pluie avec accalmie temporaire, amélioration rapide";
r.urgency = 1;
@@ -247,13 +259,20 @@ public:
r.urgency = 4;
icons << "cloud_with_rain";
debug(DEBUGMACRO, "message : " + r.message, DEBUG);
}
if (qAbs(d3) < 1)
}else if (p < 1000 && (d3 <= 0.5 && d3 >= -0.5))
{
r.message = "- Mauvais temps stable";
r.urgency = 4;
icons << "cloud_with_rain";
debug(DEBUGMACRO, "message : " + r.message, DEBUG);
}
/*if (qAbs(d3) < 1)
{
r.message += "- Stable, pas de changement significatif";
r.urgency = 0;
debug(DEBUGMACRO, "message : " + r.message, DEBUG);
}
}*/
// Risque de neige
if (p < 1000 && d3 < -1.0 && temperatureC <= 1.0 && humidityPercent > 80.0)

View File

@@ -26,7 +26,7 @@
#define BROKER_ADDRESS "localhost"
#define MQTT_PORT 1883;
uint debugLevel = DEBUG | INFO | NOTICE | INFO | WARNING | ERROR | ALERT;
uint debugLevel = INFO | NOTICE | INFO | WARNING | ERROR | ALERT;
QByteArray toFollow;
//class MqttClient;

View File

@@ -11,63 +11,6 @@
#define MQTT_TOPIC "pws2mqtt"
/*{128, "Unspecified error: The Server does not wish to reveal the reason for the failure, or none of the other Reason Codes apply."},
{129, "Malformed Packet; Data within the CONNECT packet could not be correctly parsed."},
{130, "Protocol Error: Data in the CONNECT packet does not conform to this specification."},
{131, "Implementation specific error: The CONNECT is valid but is not accepted by this Server."},
{132, "Unsupported Protocol Version: The Server does not support the version of the MQTT protocol requested by the Client."},
{133, "Client Identifier not valid: The Client Identifier is a valid string but is not allowed by the Server."},
{134, "Bad User Name or Password: The Server does not accept the User Name or Password specified by the Client."},
{135, "Not authorized: The Client is not authorized to connect."},
{136, "Server unavailable: The MQTT Server is not available."},
{137, "Server busy: The Server is busy. Try again later."},
{138, "Banned: This Client has been banned by administrative action. Contact the server administrator."},
{140, "Bad authentication method: The authentication method is not supported or does not match the authentication method currently in use."},
{144, "Topic Name invalid: The Will Topic Name is not malformed, but is not accepted by this Server."},
{149, "Packet too large: The CONNECT packet exceeded the maximum permissible size."},
{151, "Quota exceeded: An implementation or administrative imposed limit has been exceeded."},
{153, "Payload format invalid: The Will Payload does not match the specified Payload Format Indicator."},
{154, "Retain not supported: The Server does not support retained messages, and Will Retain was set to 1."},
{155, "QoS not supported: The Server does not support the QoS set in Will QoS."},
{156, "Use another server: The Client should temporarily use another server."},
{157, "Server moved: The Client should permanently use another server."},
{159, "Connection rate exceeded: The connection rate limit has been exceeded."},
QHash <int, QString> mosq_error
{
{MOSQ_ERR_ERRNO, "System return error"},
{MOSQ_ERR_INVAL, "Input parameters were invalid."},
{MOSQ_ERR_NOMEM, "Out of memory condition occurred."},
{MOSQ_ERR_PAYLOAD_SIZE, "Payloadlen is too large."},
{MOSQ_ERR_MALFORMED_UTF8, "The topic is not valid UTF-8."},
{MOSQ_ERR_NOT_SUPPORTED, "Properties is not NULL and the client is not using MQTT v5"},
{MOSQ_ERR_NO_CONN, "if the client isnt connected to a broker."},
{MOSQ_ERR_DUPLICATE_PROPERTY, "A property is duplicated where it is forbidden."},
{MOSQ_ERR_PROTOCOL, "Any property is invalid for use with DISCONNECT."},
{MOSQ_ERR_QOS_NOT_SUPPORTED, "The QoS is greater than that supported by the broker."},
{MOSQ_ERR_OVERSIZE_PACKET, "The resulting packet would be larger than supported by the broker."},
{MOSQ_ERR_CONN_LOST, "The connection to the broker was lost."},
{MOSQ_ERR_PROTOCOL, "There is a protocol error communicating with the broker."},
};
*/
/*class MqttSub : public QMqttSubscription
{
Q_OBJECT;
public:
explicit MqttSub();
~MqttSub();
public slots:
void updateStatus({ , "SubscriptionState state);
};*/
class MqttClient : public QObject
{
Q_OBJECT

View File

@@ -46,8 +46,8 @@ QMap <QByteArray, QPair<QString, QByteArray>> propertyName
{
{"tempf", {"Température extérieure", "°C"}},
{"humidity", {"Humidité extérieure", "%"}},
{"dewptf", {"Point de rosée", "°C"}},
{"windchill", {"Température ressentie", "°C"}},
// {"dewptf", {"Point de rosée", "°C"}},
{"windchill", {"Température ressentie", "°C"}},
{"winddir", {"Direction du vent", "°"}},
{"windspeedmph", {"Vitesse du vent", " km/h"}},
{"windgustmph", {"Rafales", " km/h"}},
@@ -232,13 +232,13 @@ void Pws2mqtt::parseData(QList<std::pair<QString, QString>> queryList)
static QDateTime timeWind = QDateTime::currentDateTime().addSecs(-600);
quint8 windPriority = 1;
propertiesValue["vent"] = round(mphTokmh(value.toFloat()));
propertiesValue[name] = round(mphTokmh(value.toFloat()));
debug (DEBUGMACRO, name + " : " + QByteArray::number(propertiesValue["vent"]), DEBUG);
debug (DEBUGMACRO, name + " : " + QByteArray::number(propertiesValue[name]), DEBUG);
for (i=0; i<forceVent.size();i++)
{
if (propertiesValue["vent"] <= forceVent[i][0].toDouble())
if (propertiesValue[name] <= forceVent[i][0].toDouble())
{
msg = forceVent[i][1].toString();
windPriority = forceVent[i][2].toUInt();
@@ -246,7 +246,7 @@ void Pws2mqtt::parseData(QList<std::pair<QString, QString>> queryList)
}
}
propertyList[name] = formatNotifString ("Vent - " + msg, propertyName[name].second , QByteArray::number(propertiesValue["vent"]));
propertyList[name] = formatNotifString ("Vent - " + msg, propertyName[name].second , QByteArray::number(propertiesValue[name]));
propertiesValue["forcevent"] = i;
if (i >= 5)
{
@@ -265,11 +265,11 @@ void Pws2mqtt::parseData(QList<std::pair<QString, QString>> queryList)
propertiesValue[name] = round(mphTokmh(value.toFloat()));
debug (DEBUGMACRO, name + " : " + QByteArray::number(propertiesValue["rafale"]), DEBUG);
debug (DEBUGMACRO, name + " : " + QByteArray::number(propertiesValue[name]), DEBUG);
propertyList[name] = formatNotifString (propertyName[name].first, propertyName[name].second , QByteArray::number(propertiesValue[name]));
if (propertiesValue["rafales"] > 50)
if (propertiesValue[name] > 50)
{
priority = qMax(priority, (quint8)4);
}
@@ -414,7 +414,7 @@ void Pws2mqtt::parseData(QList<std::pair<QString, QString>> queryList)
}
notif = "**Prévisions à 12/24h**\n" + propertyList["prevision"];
notify (notif, priorityList[priority], attachment, tag);
notify (notif, priorityList[priority], "", tag);
debug(DEBUGMACRO, "calling notify with notif = #" + notif + "#", DEBUG);
}