From 666a9c6fd5ea3b334d45b366c86d94ea68a1623f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Simon=20St=C3=BCrz?= Date: Mon, 16 Jan 2023 14:42:25 +0100 Subject: [PATCH] SMA: fix data types for for SunnyWebBox plant overview parsing --- sma/integrationpluginsma.cpp | 3 +-- sma/sunnywebbox/sunnywebbox.cpp | 2 +- sma/sunnywebbox/sunnywebbox.h | 4 ++-- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/sma/integrationpluginsma.cpp b/sma/integrationpluginsma.cpp index d504725..cae327d 100644 --- a/sma/integrationpluginsma.cpp +++ b/sma/integrationpluginsma.cpp @@ -562,12 +562,11 @@ void IntegrationPluginSma::onConnectedChanged(bool connected) void IntegrationPluginSma::onPlantOverviewReceived(const QString &messageId, SunnyWebBox::Overview overview) { Q_UNUSED(messageId) - - qCDebug(dcSma()) << "Plant overview received" << overview.status; Thing *thing = m_sunnyWebBoxes.key(static_cast(sender())); if (!thing) return; + qCDebug(dcSma()) << "Plant overview received for" << thing; thing->setStateValue(sunnyWebBoxCurrentPowerStateTypeId, -overview.power); thing->setStateValue(sunnyWebBoxDayEnergyProducedStateTypeId, overview.dailyYield); thing->setStateValue(sunnyWebBoxTotalEnergyProducedStateTypeId, overview.totalYield); diff --git a/sma/sunnywebbox/sunnywebbox.cpp b/sma/sunnywebbox/sunnywebbox.cpp index b75f096..3f59d9a 100644 --- a/sma/sunnywebbox/sunnywebbox.cpp +++ b/sma/sunnywebbox/sunnywebbox.cpp @@ -199,7 +199,7 @@ void SunnyWebBox::parseMessage(const QString &messageId, const QString &messageT QVariantMap map = value.toMap(); if (map["meta"].toString() == "GriPwr") { - overview.power = map["value"].toString().toInt(); + overview.power = map["value"].toString().toDouble(); QString unit = map["unit"].toString(); qCDebug(dcSma()) << "SunnyWebBox: - Power" << overview.power << unit; } else if (map["meta"].toString() == "GriEgyTdy") { diff --git a/sma/sunnywebbox/sunnywebbox.h b/sma/sunnywebbox/sunnywebbox.h index 9446530..da28985 100644 --- a/sma/sunnywebbox/sunnywebbox.h +++ b/sma/sunnywebbox/sunnywebbox.h @@ -45,9 +45,9 @@ class SunnyWebBox : public QObject Q_OBJECT public: struct Overview { - int power; + double power; double dailyYield; - int totalYield; + double totalYield; QString status; QString error; };