From d8c81a2c31c06845bea9a18815b9e0f5ef8c2c78 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Simon=20St=C3=BCrz?= Date: Wed, 7 Dec 2022 10:05:46 +0100 Subject: [PATCH] Fix wifi signal strength for base module --- netatmo/integrationpluginnetatmo.cpp | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/netatmo/integrationpluginnetatmo.cpp b/netatmo/integrationpluginnetatmo.cpp index d320009c..24528e5c 100644 --- a/netatmo/integrationpluginnetatmo.cpp +++ b/netatmo/integrationpluginnetatmo.cpp @@ -61,7 +61,7 @@ void IntegrationPluginNetatmo::startPairing(ThingPairingInfo *info) NetatmoConnection *connection = new NetatmoConnection(hardwareManager()->networkManager(), m_clientId, m_clientSecret, this); QUrl loginUrl = connection->getLoginUrl(); - // Checking the internet connection + // Checking the internet connect^ion QNetworkReply *reply = hardwareManager()->networkManager()->get(QNetworkRequest(QUrl("https://api.netatmo.net"))); connect(reply, &QNetworkReply::finished, reply, &QNetworkReply::deleteLater); connect(reply, &QNetworkReply::finished, info, [this, reply, info, connection, loginUrl]() { @@ -539,7 +539,7 @@ void IntegrationPluginNetatmo::updateModuleStates(Thing *thing, const QVariantMa thing->setStateValue("batteryCritical", thing->stateValue("batteryLevel").toInt() < 10); } - // Signal strength + // Signal strength (RF, 90 low, 60 highest) if (data.contains("rf_status")) { int signalStrength = data.value("rf_status").toInt(); if (signalStrength <= 60) { @@ -552,6 +552,20 @@ void IntegrationPluginNetatmo::updateModuleStates(Thing *thing, const QVariantMa } } + // Wifi status (86=bad, 56=good)" + + if (data.contains("wifi_status")) { + int signalStrength = data.value("wifi_status").toInt(); + if (signalStrength <= 56) { + thing->setStateValue("signalStrength", 100); + } else if (signalStrength >= 86) { + thing->setStateValue("signalStrength", 0); + } else { + int delta = 30 - (signalStrength - 56); + thing->setStateValue("signalStrength", qRound(100.0 * delta / 30.0)); + } + } + // update reachable state if (data.contains("reachable")) thing->setStateValue("connected", data.value("reachable").toBool());