Skip to content

Commit

Permalink
Merge pull request #624 from canton7/bugfix/h3-pro-fixes
Browse files Browse the repository at this point in the history
Fix battery_soc register for remote control on H3-Pro
  • Loading branch information
canton7 authored May 29, 2024
2 parents e8aa293 + ef4c3c4 commit 1d82ced
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ class ModbusRemoteControlAddressConfig:
work_mode_map: dict[WorkMode, int] | None
"""Map of work mode ->value"""

battery_soc: int
"""Current battery SoC"""
battery_soc: list[int]
"""Current battery SoC. If multiple values, these are the socs of the different batteries"""
max_soc: int | None
"""Configured Max SoC"""
invbatpower: list[int]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
work_mode_map=_NORMAL_WORK_MODE_MAP,
max_soc=41010,
invbatpower=[11008],
battery_soc=11036,
battery_soc=[11036],
pwr_limit_bat_up=[44012],
pv_voltages=[11000, 11003],
),
Expand All @@ -37,7 +37,7 @@
work_mode_map=None,
max_soc=None,
invbatpower=[31022],
battery_soc=31024,
battery_soc=[31024],
pwr_limit_bat_up=None,
pv_voltages=[31000, 31003],
),
Expand All @@ -52,7 +52,7 @@
work_mode_map=_NORMAL_WORK_MODE_MAP,
max_soc=41010,
invbatpower=[31022],
battery_soc=31024,
battery_soc=[31024],
pwr_limit_bat_up=[44012],
pv_voltages=[39070, 39072],
),
Expand All @@ -68,7 +68,7 @@
work_mode_map=_NORMAL_WORK_MODE_MAP,
max_soc=41010,
invbatpower=[11008],
battery_soc=11036,
battery_soc=[11036],
pwr_limit_bat_up=None,
pv_voltages=[11000, 11003, 11096, 11099],
),
Expand All @@ -83,7 +83,7 @@
work_mode_map=_NORMAL_WORK_MODE_MAP,
max_soc=41010,
invbatpower=[31022],
battery_soc=31024,
battery_soc=[31024],
pwr_limit_bat_up=None,
pv_voltages=[31000, 31003, 31039, 31042],
),
Expand All @@ -100,7 +100,7 @@
work_mode_map=_NORMAL_WORK_MODE_MAP,
max_soc=41010,
invbatpower=[31022],
battery_soc=31038,
battery_soc=[31038],
pwr_limit_bat_up=None,
pv_voltages=[31000, 31003],
),
Expand All @@ -121,7 +121,7 @@
},
max_soc=46610,
invbatpower=[39238, 39237],
battery_soc=31038,
battery_soc=[37612, 38310],
pwr_limit_bat_up=[46019, 46018],
pv_voltages=[39070, 39072, 39074, 39076],
),
Expand Down
11 changes: 9 additions & 2 deletions custom_components/foxess_modbus/remote_control_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def __init__(
self._max_soc_override: int | None = None

modbus_addresses = [
self._addresses.battery_soc,
*self._addresses.battery_soc,
self._addresses.work_mode,
self._addresses.max_soc,
*self._addresses.invbatpower,
Expand Down Expand Up @@ -121,8 +121,15 @@ async def _update_charge(self) -> None:
# The inverter doesn't respect Max Soc. Therefore if the SoC >= Max SoC, turn off remote control.
# We don't let the user configure charge power: they can't figure it with normal charge periods, so why bother?
# They can set the max charge current if they want, which has the same effect.
# If there are multiple batteries, then we'll take the max. That doesn't stop the inverter charging the other
# of course, but it's probably the best we can do.

soc: int | None = None
for address in self._addresses.battery_soc:
value = self._read(address, signed=False)
if value is not None and (soc is None or value > soc):
soc = value

soc = self._read(self._addresses.battery_soc, signed=False)
# max_soc might not be available, e.g. on H1 LAN. In this case, we use an override, controlled from a sensor
if self._max_soc_override is not None:
max_soc: int | None = self._max_soc_override
Expand Down

0 comments on commit 1d82ced

Please sign in to comment.