From f96adcfb3c6d6306b2b433312bd61969d1e21295 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Simon=20St=C3=BCrz?= Date: Wed, 10 Aug 2022 10:53:51 +0200 Subject: [PATCH] Update documentation and remove energystorage interface from batteries --- huawei/README.md | 5 ++++- huawei/huaweifusionsolar.cpp | 28 ++-------------------------- huawei/huaweifusionsolar.h | 8 -------- huawei/integrationpluginhuawei.cpp | 5 ++--- huawei/integrationpluginhuawei.json | 2 +- 5 files changed, 9 insertions(+), 39 deletions(-) diff --git a/huawei/README.md b/huawei/README.md index 82d7646..51816a4 100644 --- a/huawei/README.md +++ b/huawei/README.md @@ -4,7 +4,7 @@ Connects to a Huawei FusionSolar using Modbus RTU or TCP. ## Huawei FusionSolar -In order to communicate with the Huawei FusionSolar inverter, a working communikation must be provided. This can be done with a Huawei SmartDongle or with a direct modbus RTU connection. +In order to communicate with the Huawei FusionSolar inverter, a working communication must be provided. This can be done with a Huawei SmartDongle or with a directly with the modbus RTU connection. Once nymea has connected successfully to the inverter, following devices will be supported: @@ -12,6 +12,9 @@ Once nymea has connected successfully to the inverter, following devices will be * Huawei Meter (connected internally to the Inverter) * Luna2000 battery units 1 and 2 if connected +The batteries will be shown in the system as informative things, but will not be considered in the energy view and and energy balance. Since the batteries are connected internally behind the inverter, power coming from the battery will be shown as power coming from the inverter. The inverter power represents power from the PV or from the battery. + + ### Huawei SmartDongle The [SmartDongle](https://solar.huawei.com/-/media/Solar/attachment/pdf/apac/datasheet/SmartDongle-WLAN-FE.pdf) can be used to communicate diff --git a/huawei/huaweifusionsolar.cpp b/huawei/huaweifusionsolar.cpp index 094b17e..0d68652 100644 --- a/huawei/huaweifusionsolar.cpp +++ b/huawei/huaweifusionsolar.cpp @@ -108,9 +108,10 @@ bool HuaweiFusionSolar::update() m_registersQueue.enqueue(HuaweiFusionModbusTcpConnection::RegisterLunaBattery2Power); m_registersQueue.enqueue(HuaweiFusionModbusTcpConnection::RegisterPowerMeterActivePower); - m_registersQueue.enqueue(HuaweiFusionModbusTcpConnection::RegisterInverterEnergyProduced); m_registersQueue.enqueue(HuaweiFusionModbusTcpConnection::RegisterInverterDeviceStatus); + + // Note: we constantly read the status in any case so we detect if a battery came online m_registersQueue.enqueue(HuaweiFusionModbusTcpConnection::RegisterLunaBattery1Status); m_registersQueue.enqueue(HuaweiFusionModbusTcpConnection::RegisterLunaBattery2Status); @@ -127,11 +128,6 @@ bool HuaweiFusionSolar::update() return true; } -double HuaweiFusionSolar::actualInverterPower() const -{ - return m_actualInverterPower; -} - void HuaweiFusionSolar::readNextRegister() { // Check if currently a reply is pending @@ -171,7 +167,6 @@ void HuaweiFusionSolar::readNextRegister() qCWarning(dcHuaweiFusionSolar()) << "<-- Received invalid values. Requested" << 2 << "but received" << unit.values(); } else { processInverterActivePowerRegisterValues(unit.values()); - calculatActualInverterPower(); } } @@ -391,7 +386,6 @@ void HuaweiFusionSolar::readNextRegister() qCWarning(dcHuaweiFusionSolar()) << "<-- Received invalid values. Requested" << 2 << "but received" << unit.values(); } else { processLunaBattery1PowerRegisterValues(unit.values()); - calculatActualInverterPower(); } } finishRequest(); @@ -522,7 +516,6 @@ void HuaweiFusionSolar::readNextRegister() qCWarning(dcHuaweiFusionSolar()) << "<-- Received invalid values count. Requested" << 2 << "but received" << unit.values(); } else { processLunaBattery2PowerRegisterValues(unit.values()); - calculatActualInverterPower(); } } finishRequest(); @@ -616,23 +609,6 @@ bool HuaweiFusionSolar::valuesAreVaild(const QVector &values, int readS return true; } -void HuaweiFusionSolar::calculatActualInverterPower() -{ - double actualPower = m_inverterActivePower * -1000.0; - if (m_battery1Available) - actualPower += m_lunaBattery1Power; - - if (m_battery2Available) - actualPower += m_lunaBattery2Power; - - qCDebug(dcHuaweiFusionSolar()) << "Inverter power:" << m_inverterActivePower << "W Battery 1:" << m_lunaBattery1Power << "W Battery 2:" << m_lunaBattery2Power << "W -->" << "Actual inverter power:" << actualPower << "W"; - if (m_actualInverterPower == actualPower) - return; - - m_actualInverterPower = actualPower; - emit actualInverterPowerChanged(m_actualInverterPower); -} - void HuaweiFusionSolar::finishRequest() { m_currentRegisterRequest = -1; diff --git a/huawei/huaweifusionsolar.h b/huawei/huaweifusionsolar.h index cb32652..df879ff 100644 --- a/huawei/huaweifusionsolar.h +++ b/huawei/huaweifusionsolar.h @@ -46,13 +46,6 @@ public: bool initialize() override; virtual bool update() override; - // The inverter shows the pv power AND the power of the connected batteries if they discharge. - // This power values represents the power taking the batteries into account. - double actualInverterPower() const; - -signals: - void actualInverterPowerChanged(double actualInverterPower); - private: QQueue m_registersQueue; QModbusReply *m_initReply = nullptr; @@ -70,7 +63,6 @@ private: private slots: void readNextRegister(); bool valuesAreVaild(const QVector &values, int readSize); - void calculatActualInverterPower(); }; diff --git a/huawei/integrationpluginhuawei.cpp b/huawei/integrationpluginhuawei.cpp index 49df53d..1785611 100644 --- a/huawei/integrationpluginhuawei.cpp +++ b/huawei/integrationpluginhuawei.cpp @@ -460,9 +460,8 @@ void IntegrationPluginHuawei::setupFusionSolar(ThingSetupInfo *info) } }); - connect(connection, &HuaweiFusionSolar::actualInverterPowerChanged, thing, [thing](float actualInverterPower){ - qCDebug(dcHuawei()) << "Inverter actual power changed" << actualInverterPower << "W"; - thing->setStateValue(huaweiFusionSolarInverterCurrentPowerStateTypeId, actualInverterPower); + connect(connection, &HuaweiFusionSolar::inverterActivePowerChanged, thing, [thing](float inverterActivePower){ + thing->setStateValue(huaweiFusionSolarInverterCurrentPowerStateTypeId, inverterActivePower * -1000.0); }); connect(connection, &HuaweiFusionSolar::inverterDeviceStatusReadFinished, thing, [thing](HuaweiFusionSolar::InverterDeviceStatus inverterDeviceStatus){ diff --git a/huawei/integrationpluginhuawei.json b/huawei/integrationpluginhuawei.json index 7d7054d..8df9556 100644 --- a/huawei/integrationpluginhuawei.json +++ b/huawei/integrationpluginhuawei.json @@ -293,7 +293,7 @@ "displayName": "Huawei Battery", "id": "40104aac-0456-475d-8bd6-18f946597d96", "createMethods": ["auto"], - "interfaces": [ "energystorage", "connectable"], + "interfaces": [ "battery", "connectable"], "paramTypes": [ { "id": "019287a6-c593-45a8-9695-2e1ad8e81c32",