SMA: fix data types for for SunnyWebBox plant overview parsing

master
Simon Stürz 2023-01-16 14:42:25 +01:00
parent 015e25ee13
commit 666a9c6fd5
3 changed files with 4 additions and 5 deletions

View File

@ -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<SunnyWebBox *>(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);

View File

@ -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") {

View File

@ -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;
};