Skip to content

Commit

Permalink
Fix for Force Charge not working when using H1 over LAN (#671)
Browse files Browse the repository at this point in the history
It looks like a bug has crept in on the later releases when trying to set force charge for H1 using LAN.

H1 LAN doesn't support work mode hence it is not possible to set a fall back mode and the 'assert if work_mode_map is not None' correctly raises an error for H1 LAN.
  • Loading branch information
FozzieUK authored Sep 18, 2024
1 parent 7b730f0 commit 0dc4f7a
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions custom_components/foxess_modbus/remote_control_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -272,12 +272,15 @@ async def _update_discharge(self) -> None:
async def _enable_remote_control(self, fallback_work_mode: WorkMode) -> None:
# We set a fallback work mode so that the inverter still does "roughly" the right thing if we disconnect
# (This might not be available, e.g. on H1 LAN)
assert self._addresses.work_mode_map is not None
fallback_work_mode_value = self._addresses.work_mode_map[fallback_work_mode]

current_work_mode = self._read(self._addresses.work_mode, signed=False)
if current_work_mode != fallback_work_mode_value and self._addresses.work_mode is not None:
await self._controller.write_register(self._addresses.work_mode, fallback_work_mode_value)
if (
fallback_work_mode is not None
and self._addresses.work_mode is not None
and self._addresses.work_mode_map is not None
):
fallback_work_mode_value = self._addresses.work_mode_map[fallback_work_mode]
current_work_mode = self._read(self._addresses.work_mode, signed=False)
if current_work_mode != fallback_work_mode_value:
await self._controller.write_register(self._addresses.work_mode, fallback_work_mode_value)

if not self._remote_control_enabled:
self._remote_control_enabled = True
Expand Down

0 comments on commit 0dc4f7a

Please sign in to comment.