From 7924bcc9260178d2471717be73e16abc7cd6e6ea Mon Sep 17 00:00:00 2001 From: mle Date: Sun, 14 Apr 2024 18:03:38 +0200 Subject: [PATCH] Improve model/protocol recognition --- goodwe/es.py | 2 +- goodwe/et.py | 6 +++--- goodwe/model.py | 39 +++++++++++++++++++++------------------ 3 files changed, 25 insertions(+), 22 deletions(-) diff --git a/goodwe/es.py b/goodwe/es.py index 8cbf8bb..5add511 100644 --- a/goodwe/es.py +++ b/goodwe/es.py @@ -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") diff --git a/goodwe/et.py b/goodwe/et.py index 15e11a7..a5d485f 100644 --- a/goodwe/et.py +++ b/goodwe/et.py @@ -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, ...] = ( @@ -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) @@ -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() @@ -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') diff --git a/goodwe/model.py b/goodwe/model.py index a2c56b4..d08cf56 100644 --- a/goodwe/model.py +++ b/goodwe/model.py @@ -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: @@ -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)