diff --git a/mainwindow.cpp b/mainwindow.cpp
index 89e3b81..b5b3134 100644
--- a/mainwindow.cpp
+++ b/mainwindow.cpp
@@ -81,18 +81,16 @@ void MainWindow::scanDevices()
isNvme = true;
}
- for (const QJsonValue &attr : attributes) { // Need different logic for NVMe
+ int temperatureInt = localObj["temperature"].toObject()["current"].toInt();
+ if (temperatureInt > 0) {
+ temperature = QString::number(temperatureInt) + " °C";
+ }
+
+ for (const QJsonValue &attr : attributes) {
QJsonObject attrObj = attr.toObject();
- if (attrObj["id"] == 194 && !isNvme) {
- QString raw = attrObj["raw"].toObject()["string"].toString();
- int spaceIndex = raw.indexOf(' ');
- if (spaceIndex != -1) {
- raw = raw.left(spaceIndex);
- }
- int tempInt = raw.toInt();
- temperature = QString::number(tempInt) + " °C";
- } else if (!isNvme && (attrObj["id"] == 5 || attrObj["id"] == 197 || attrObj["id"] == 198) && (attrObj["raw"].toObject()["value"].toInt() != 0)) {
+ if (!isNvme && (attrObj["id"] == 5 || attrObj["id"] == 197 || attrObj["id"] == 198) && (attrObj["raw"].toObject()["value"].toInt() != 0)) {
caution = true;
+ break;
}
}
@@ -137,6 +135,7 @@ void MainWindow::populateWindow(const QJsonObject &localObj, const QString &heal
QString modelName = localObj["model_name"].toString();
QString firmwareVersion = localObj["firmware_version"].toString();
float userCapacityGB = localObj.value("user_capacity").toObject().value("bytes").toDouble() / 1e9;
+ int temperatureInt = localObj["temperature"].toObject()["current"].toInt();
QString userCapacityString = QString::number(static_cast " + QString::number(tempInt) + " °C " + QString::number(temperatureInt) + " °C
N/A
"); }