From e1690e8f747054c1ff986ba913507920c95daca7 Mon Sep 17 00:00:00 2001 From: Thomas Basler Date: Thu, 6 Oct 2022 18:36:13 +0200 Subject: [PATCH] Apply limit instantaneously if inverter info is available --- lib/Hoymiles/src/commands/ActivePowerControlCommand.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/Hoymiles/src/commands/ActivePowerControlCommand.cpp b/lib/Hoymiles/src/commands/ActivePowerControlCommand.cpp index 9c00408..05e671d 100644 --- a/lib/Hoymiles/src/commands/ActivePowerControlCommand.cpp +++ b/lib/Hoymiles/src/commands/ActivePowerControlCommand.cpp @@ -49,7 +49,12 @@ bool ActivePowerControlCommand::handleResponse(InverterAbstract* inverter, fragm if ((getType() == PowerLimitControlType::RelativNonPersistent) || (getType() == PowerLimitControlType::RelativPersistent)) { inverter->SystemConfigPara()->setLimitPercent(getLimit()); } else { - // TODO(tbnobody): Not implemented yet because we only can publish the percentage value + uint16_t max_power = inverter->DevInfo()->getMaxPower(); + if (max_power > 0) { + inverter->SystemConfigPara()->setLimitPercent(static_cast(getLimit()) / max_power * 100); + } else { + // TODO(tbnobody): Not implemented yet because we only can publish the percentage value + } } inverter->SystemConfigPara()->setLastUpdateCommand(millis()); inverter->SystemConfigPara()->setLastLimitCommandSuccess(CMD_OK);