Skip to content

Commit

Permalink
Merge pull request #234 from reserve85/dev
Browse files Browse the repository at this point in the history
Fix Mixed Mode, improved Startup-Init
  • Loading branch information
reserve85 authored Aug 28, 2024
2 parents dab1d9b + 2a49941 commit fa1f5f6
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 5 deletions.
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

0 comments on commit fa1f5f6

Please sign in to comment.