Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Mixed Mode, improved Startup-Init #234

Merged
merged 4 commits into from
Aug 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# Changelog

## V 1.100
### script
* improve startup: init newLimitSetpoint

## V 1.99
### script
* fix mixed mode: if setLimit < getminwatt there was an calulation error (results in setLimit = 0).

## V 1.98
### script
* added a limit cross-check (real DTU Limit is cross-checked vs. Set Limit +/- 5%) (https://github.com/reserve85/HoymilesZeroExport/issues/223)
Expand Down
20 changes: 15 additions & 5 deletions HoymilesZeroExport.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.

__author__ = "Tobias Kraft"
__version__ = "1.98"
__version__ = "1.100"

import time
from requests.sessions import Session
Expand Down Expand Up @@ -181,7 +181,7 @@ def SetLimitMixedModeWithPriority(pLimit):
SetLimitMixedModeWithPriority.LastLimitAck = True
min_watt_all_inverters = GetMinWattFromAllInverters()
if (CastToInt(pLimit) <= min_watt_all_inverters):
pLimit = 0 # set only minWatt for every inv.
pLimit = min_watt_all_inverters # set only minWatt for every inv.
PublishGlobalState("limit", min_watt_all_inverters)
else:
PublishGlobalState("limit", CastToInt(pLimit))
Expand All @@ -191,7 +191,7 @@ def SetLimitMixedModeWithPriority(pLimit):
if RemainingLimit >= GetMaxInverterWattFromAllNonBatteryInverters():
nonBatteryInvertersLimit = GetMaxInverterWattFromAllNonBatteryInverters()
else:
nonBatteryInvertersLimit = RemainingLimit
nonBatteryInvertersLimit = RemainingLimit - GetMinWattFromAllBatteryInverters()

for i in range(INVERTER_COUNT):
if not AVAILABLE[i] or HOY_BATTERY_MODE[i]:
Expand Down Expand Up @@ -635,6 +635,14 @@ def GetMinWattFromAllInverters():
minWatt = minWatt + GetMinWatt(i)
return minWatt

def GetMinWattFromAllBatteryInverters():
minWatt = 0
for i in range(INVERTER_COUNT):
if (not AVAILABLE[i]) or (not HOY_BATTERY_MODE[i]) or (not HOY_BATTERY_GOOD_VOLTAGE[i]):
continue
minWatt = minWatt + GetMinWatt(i)
return minWatt

def GetMixedMode():
#if battery mode and custom priority use SetLimitWithPriority
for i in range(INVERTER_COUNT):
Expand Down Expand Up @@ -1607,14 +1615,16 @@ def emit(self, record):
try:
logger.info("---Init---")

newLimitSetpoint = 0
DTU.CheckMinVersion()
if GetHoymilesAvailable():
for i in range(INVERTER_COUNT):
SetHoymilesPowerStatus(i, True)
SetLimit(GetMinWattFromAllInverters())
newLimitSetpoint = GetMinWattFromAllInverters()
SetLimit(newLimitSetpoint)
GetHoymilesActualPower()
GetCheckBattery()
else:
newLimitSetpoint = 0
GetPowermeterWatts()
except Exception as e:
if hasattr(e, 'message'):
Expand Down
Loading