Skip to content

Commit

Permalink
Improve model/protocol recognition
Browse files Browse the repository at this point in the history
  • Loading branch information
mletenay committed Apr 14, 2024
1 parent 2949331 commit 7924bcc
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 22 deletions.
2 changes: 1 addition & 1 deletion goodwe/es.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@


class ES(Inverter):
"""Class representing inverter of ES/EM/BP family"""
"""Class representing inverter of ES/EM/BP family AKA platform 105"""

_READ_DEVICE_VERSION_INFO: ProtocolCommand = Aa55ProtocolCommand("010200", "0182")
_READ_DEVICE_RUNNING_DATA: ProtocolCommand = Aa55ProtocolCommand("010600", "0186")
Expand Down
6 changes: 3 additions & 3 deletions goodwe/et.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@


class ET(Inverter):
"""Class representing inverter of ET/EH/BT/BH or GE's GEH families"""
"""Class representing inverter of ET/EH/BT/BH or GE's GEH families AKA platform 205 or 745"""

# Modbus registers from offset 0x891c (35100), count 0x7d (125)
__all_sensors: Tuple[Sensor, ...] = (
Expand Down Expand Up @@ -632,6 +632,7 @@ async def set_operation_mode(self, operation_mode: OperationMode, eco_mode_power
await self._set_offline(True)
await self.write_setting('backup_supply', 1)
await self.write_setting('cold_start', 4)
await self._clear_battery_mode_param()
elif operation_mode == OperationMode.BACKUP:
await self.write_setting('work_mode', 2)
await self._set_offline(False)
Expand All @@ -642,6 +643,7 @@ async def set_operation_mode(self, operation_mode: OperationMode, eco_mode_power
elif operation_mode == OperationMode.PEAK_SHAVING:
await self.write_setting('work_mode', 4)
await self._set_offline(False)
await self._clear_battery_mode_param()
elif operation_mode in (OperationMode.ECO_CHARGE, OperationMode.ECO_DISCHARGE):
if eco_mode_power < 0 or eco_mode_power > 100:
raise ValueError()
Expand All @@ -664,8 +666,6 @@ async def set_operation_mode(self, operation_mode: OperationMode, eco_mode_power
await self.write_setting('eco_mode_4_switch', 0)
await self.write_setting('work_mode', 3)
await self._set_offline(False)
if is_745_platform(self):
await self.write_setting('eco_mode_enable', 1)

async def get_ongrid_battery_dod(self) -> int:
return 100 - await self.read_setting('battery_discharge_depth')
Expand Down
39 changes: 21 additions & 18 deletions goodwe/model.py
Original file line number Diff line number Diff line change
@@ -1,30 +1,32 @@
# Serial number tags to identify inverter type
from .inverter import Inverter

# Serial number tags to identify inverter type
ET_MODEL_TAGS = ["ETU", "ETL", "ETR", "ETC", "EHU", "EHR", "EHB", "ETT",
"BTU", "BTN", "BTC", "BHU", "AES", "ABP", "HHI",
"HSB", "HUA", "CUA",
"ESN", "EMN", "ERN", "EBN", # ES Gen 2
"HLB", "HMB", "HBB", "SPN"] # Gen 2
ES_MODEL_TAGS = ["ESU", "EMU", "ESA", "BPS", "BPU", "EMJ", "IJL"]
DT_MODEL_TAGS = ["DTU", "DTS",
PLATFORM_105_MODELS = ("ESU", "EMU", "ESA", "BPS", "BPU", "EMJ", "IJL")
PLATFORM_205_MODELS = ("ETU", "ETL", "ETR", "BHN", "EHU", "BHU", "EHR", "BTU")
PLATFORM_745_LV_MODELS = ("ESN", "EBN", "EMN", "SPN", "ERN", "ESC", "HLB", "HMB", "HBB", "EOA")
PLATFORM_745_HV_MODELS = ("ETT", "HTA", "HUB", "AEB", "SPB", "CUB", "EUB", "HEB", "ERB", "BTT", "ETF", "ARB", "URB",
"EBR")
PLATFORM_753_MODELS = ("AES", "HHI", "ABP", "EHB", "HSB", "HUA", "CUA")

ET_MODEL_TAGS = PLATFORM_205_MODELS + PLATFORM_745_LV_MODELS + PLATFORM_745_HV_MODELS + PLATFORM_753_MODELS + (
"ETC", "BTC", "BTN") # Qianhai
ES_MODEL_TAGS = PLATFORM_105_MODELS
DT_MODEL_TAGS = ("DTU", "DTS",
"MSU", "MST", "MSC", "DSN", "DTN", "DST", "NSU", "SSN", "SST", "SSX", "SSY",
"PSB", "PSC"]
"PSB", "PSC")

SINGLE_PHASE_MODELS = ["DSN", "DST", "NSU", "SSN", "SST", "SSX", "SSY", # DT
SINGLE_PHASE_MODELS = ("DSN", "DST", "NSU", "SSN", "SST", "SSX", "SSY", # DT
"MSU", "MST", "PSB", "PSC",
"MSC", # Found on third gen MS
"EHU", "EHR", "HSB", # ET
"ESN", "EMN", "ERN", "EBN", "HLB", "HMB", "HBB", "SPN"] # ES Gen 2

MPPT3_MODELS = ["MSU", "MST", "PSC", "MSC",
"25KET", "29K9ET"]
"ESN", "EMN", "ERN", "EBN", "HLB", "HMB", "HBB", "SPN") # ES Gen 2

MPPT4_MODELS = ["HSB"]
MPPT3_MODELS = ("MSU", "MST", "PSC", "MSC",
"25KET", "29K9ET")

BAT_2_MODELS = ["25KET", "29K9ET"]
MPPT4_MODELS = ("HSB",)

PLATFORM_745_MODELS = ["ETT", "ESN"]
BAT_2_MODELS = ("25KET", "29K9ET")


def is_single_phase(inverter: Inverter) -> bool:
Expand All @@ -44,4 +46,5 @@ def is_2_battery(inverter: Inverter) -> bool:


def is_745_platform(inverter: Inverter) -> bool:
return any(model in inverter.serial_number for model in PLATFORM_745_MODELS)
return any(model in inverter.serial_number for model in PLATFORM_745_LV_MODELS) or any(
model in inverter.serial_number for model in PLATFORM_745_HV_MODELS)

0 comments on commit 7924bcc

Please sign in to comment.