Skip to content

Commit

Permalink
Merge pull request #170 from tomquist/reset-all-inverter-data
Browse files Browse the repository at this point in the history
Reset all inverter data when inverter becomes unavailable
  • Loading branch information
reserve85 authored Mar 23, 2024
2 parents b7d677b + 88bee42 commit c3592b0
Showing 1 changed file with 31 additions and 11 deletions.
42 changes: 31 additions & 11 deletions HoymilesZeroExport.py
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,36 @@ def SetLimitMixedModeWithPriority(pLimit):
SetLimitMixedModeWithPriority.LastLimitAck = False
raise

def ResetInverterData(pInverterId):
attributes_to_delete = [
"LastLimit",
"LastLimitAck",
]
array_attributes_to_delete = [
{"LastPowerStatus": False},
{"SamePowerStatusCnt": 0},
]
target_objects = [
SetLimit,
SetLimitWithPriority,
SetLimitMixedModeWithPriority,
GetHoymilesPanelMinVoltage,
]
for target_object in target_objects:
for attribute in attributes_to_delete:
if hasattr(target_object, attribute):
delattr(target_object, attribute)
for array_attribute in array_attributes_to_delete:
for key, value in array_attribute.items():
if hasattr(target_object, key):
target_object[key][pInverterId] = value

LASTLIMITACKNOWLEDGED[pInverterId] = False
HOY_PANEL_MIN_VOLTAGE_HISTORY_LIST[pInverterId] = []
CURRENT_LIMIT[pInverterId] = -1
HOY_BATTERY_GOOD_VOLTAGE[pInverterId] = True
TEMPERATURE[pInverterId] = str('--- degC')

def SetLimit(pLimit):
try:
if GetMixedMode():
Expand Down Expand Up @@ -309,15 +339,7 @@ def GetHoymilesAvailable():
if AVAILABLE[i]:
GetHoymilesAvailable = True
if not WasAvail:
if hasattr(SetLimit, "LastLimit"):
SetLimit.LastLimit = CastToInt(0)
if hasattr(SetLimit, "LastLimitAck"):
SetLimit.LastLimitAck = bool(False)
if hasattr(SetLimitWithPriority, "LastLimit"):
SetLimitWithPriority.LastLimit = CastToInt(0)
if hasattr(SetLimitWithPriority, "LastLimitAck"):
SetLimitWithPriority.LastLimitAck = bool(False)
LASTLIMITACKNOWLEDGED[i] = False
ResetInverterData(i)
GetHoymilesInfo()
except Exception as e:
AVAILABLE[i] = False
Expand Down Expand Up @@ -349,8 +371,6 @@ def GetHoymilesInfo():
raise

def GetHoymilesPanelMinVoltage(pInverterId):
if not hasattr(GetHoymilesPanelMinVoltage, "HoymilesPanelMinVoltageArray"):
GetHoymilesPanelMinVoltage.HoymilesPanelMinVoltageArray = []
try:
if not AVAILABLE[pInverterId]:
return 0
Expand Down

0 comments on commit c3592b0

Please sign in to comment.