Skip to content

Commit

Permalink
Fix the mptt typos in the source code
Browse files Browse the repository at this point in the history
Fix the mptt (should be mppt) typos in the source code
  • Loading branch information
mletenay committed Jan 29, 2024
1 parent af1bad4 commit 1220e83
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 20 deletions.
4 changes: 2 additions & 2 deletions goodwe/dt.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from .inverter import Inverter
from .inverter import OperationMode
from .inverter import SensorKind as Kind
from .model import is_3_mptt, is_single_phase
from .model import is_3_mppt, is_single_phase
from .protocol import ProtocolCommand, ModbusReadCommand, ModbusWriteCommand, ModbusWriteMultiCommand
from .sensor import *

Expand Down Expand Up @@ -162,7 +162,7 @@ async def read_device_info(self):
else:
self._settings.update({s.id_: s for s in self.__settings_three_phase})

if is_3_mptt(self):
if is_3_mppt(self):
# this is 3 PV strings inverter, keep all sensors
pass
else:
Expand Down
28 changes: 14 additions & 14 deletions goodwe/et.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from .inverter import Inverter
from .inverter import OperationMode
from .inverter import SensorKind as Kind
from .model import is_2_battery, is_3_mptt, is_4_mptt, is_single_phase
from .model import is_2_battery, is_3_mppt, is_4_mppt, is_single_phase
from .protocol import ProtocolCommand, ModbusReadCommand, ModbusWriteCommand, ModbusWriteMultiCommand
from .sensor import *

Expand Down Expand Up @@ -267,7 +267,7 @@ class ET(Inverter):

# Inverter's MPPT data
# Modbus registers from offset 0x89e5 (35301)
__all_sensors_mptt: Tuple[Sensor, ...] = (
__all_sensors_mppt: Tuple[Sensor, ...] = (
Power4("ppv_total", 35301, "PV Power Total", Kind.PV),
Integer("pv_channel", 35303, "PV Channel", "", Kind.PV),
Voltage("vpv5", 35304, "PV5 Voltage", Kind.PV),
Expand Down Expand Up @@ -410,16 +410,16 @@ def __init__(self, host: str, comm_addr: int = 0, timeout: int = 1, retries: int
self._READ_METER_DATA_EXTENDED: ProtocolCommand = ModbusReadCommand(self.comm_addr, 0x8ca0, 0x3a)
self._READ_BATTERY_INFO: ProtocolCommand = ModbusReadCommand(self.comm_addr, 0x9088, 0x0018)
self._READ_BATTERY2_INFO: ProtocolCommand = ModbusReadCommand(self.comm_addr, 0x9858, 0x0016)
self._READ_MPTT_DATA: ProtocolCommand = ModbusReadCommand(self.comm_addr, 0x89e5, 0x3d)
self._READ_MPPT_DATA: ProtocolCommand = ModbusReadCommand(self.comm_addr, 0x89e5, 0x3d)
self._has_battery: bool = True
self._has_battery2: bool = False
self._has_meter_extended: bool = False
self._has_mptt: bool = False
self._has_mppt: bool = False
self._sensors = self.__all_sensors
self._sensors_battery = self.__all_sensors_battery
self._sensors_battery2 = self.__all_sensors_battery2
self._sensors_meter = self.__all_sensors_meter
self._sensors_mptt = self.__all_sensors_mptt
self._sensors_mppt = self.__all_sensors_mppt
self._settings: dict[str, Sensor] = {s.id_: s for s in self.__all_settings}

def _supports_eco_mode_v2(self) -> bool:
Expand Down Expand Up @@ -455,10 +455,10 @@ async def read_device_info(self):
self.firmware = self._decode(response[42:54])
self.arm_firmware = self._decode(response[54:66])

if not is_4_mptt(self):
if not is_4_mppt(self):
# This inverter does not have 4th MPPTs
self._sensors = tuple(filter(lambda s: not ('pv4' in s.id_), self._sensors))
if not is_3_mptt(self):
if not is_3_mppt(self):
# This inverter neither has 3rd MPPTs
self._sensors = tuple(filter(lambda s: not ('pv3' in s.id_), self._sensors))

Expand All @@ -471,7 +471,7 @@ async def read_device_info(self):
self._has_battery2 = True

if self.rated_power >= 15000:
self._has_mptt = True
self._has_mppt = True
self._has_meter_extended = True
else:
self._sensors_meter = tuple(filter(self._not_extended_meter, self._sensors_meter))
Expand Down Expand Up @@ -526,14 +526,14 @@ async def read_runtime_data(self) -> Dict[str, Any]:
response = await self._read_from_socket(self._READ_METER_DATA)
data.update(self._map_response(response, self._sensors_meter))

if self._has_mptt:
if self._has_mppt:
try:
response = await self._read_from_socket(self._READ_MPTT_DATA)
data.update(self._map_response(response, self._sensors_mptt))
response = await self._read_from_socket(self._READ_MPPT_DATA)
data.update(self._map_response(response, self._sensors_mppt))
except RequestRejectedException as ex:
if ex.message == 'ILLEGAL DATA ADDRESS':
logger.warning("Cannot read MPPT values, disabling further attempts.")
self._has_mptt = False
self._has_mppt = False
else:
raise ex

Expand Down Expand Up @@ -652,8 +652,8 @@ def sensors(self) -> Tuple[Sensor, ...]:
result = result + self._sensors_battery
if self._has_battery2:
result = result + self._sensors_battery2
if self._has_mptt:
result = result + self._sensors_mptt
if self._has_mppt:
result = result + self._sensors_mppt
return result

def settings(self) -> Tuple[Sensor, ...]:
Expand Down
4 changes: 2 additions & 2 deletions goodwe/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,11 @@ def is_single_phase(inverter: Inverter) -> bool:
return any(model in inverter.serial_number for model in SINGLE_PHASE_MODELS)


def is_3_mptt(inverter: Inverter) -> bool:
def is_3_mppt(inverter: Inverter) -> bool:
return any(model in inverter.serial_number for model in MPPT3_MODELS)


def is_4_mptt(inverter: Inverter) -> bool:
def is_4_mppt(inverter: Inverter) -> bool:
return any(model in inverter.serial_number for model in MPPT4_MODELS)


Expand Down
4 changes: 2 additions & 2 deletions tests/test_et.py
Original file line number Diff line number Diff line change
Expand Up @@ -890,7 +890,7 @@ def __init__(self, methodName='runTest'):
self.mock_response(self._READ_RUNNING_DATA, 'GW25K-ET_running_data.hex')
self.mock_response(self._READ_METER_DATA_EXTENDED, 'GW25K-ET_meter_data.hex')
self.mock_response(self._READ_BATTERY_INFO, 'GW25K-ET_battery_info.hex')
self.mock_response(self._READ_MPTT_DATA, 'GW25K-ET_mppt_data.hex')
self.mock_response(self._READ_MPPT_DATA, 'GW25K-ET_mppt_data.hex')

def test_GW25K_ET_device_info(self):
self.loop.run_until_complete(self.read_device_info())
Expand Down Expand Up @@ -1167,7 +1167,7 @@ def __init__(self, methodName='runTest'):
self.mock_response(self._READ_METER_DATA_EXTENDED, 'GW29K9-ET_meter_data.hex')
self.mock_response(self._READ_BATTERY_INFO, 'GW29K9-ET_battery_info.hex')
self.mock_response(self._READ_BATTERY2_INFO, 'GW29K9-ET_battery2_info.hex')
self.mock_response(self._READ_MPTT_DATA, 'GW29K9-ET_mppt_data.hex')
self.mock_response(self._READ_MPPT_DATA, 'GW29K9-ET_mppt_data.hex')

def test_GW29K9_ET_device_info(self):
self.loop.run_until_complete(self.read_device_info())
Expand Down

0 comments on commit 1220e83

Please sign in to comment.