Skip to content

Commit

Permalink
Merge pull request #630 from canton7/bugfix/h3-pro-fixes
Browse files Browse the repository at this point in the history
Fix order that remote control multi-register values are written
  • Loading branch information
canton7 authored Jun 12, 2024
2 parents f97c43b + eb2e212 commit 9ade875
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions custom_components/foxess_modbus/remote_control_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,10 +112,12 @@ async def _write_active_power(self, export_power: int) -> None:
values = []
for i in range(len(self._addresses.active_power)):
# If there are multiple registers, they must be contiguous and descending
# (Low-order bits are in the higher register)
if i > 0:
assert self._addresses.active_power[i] == self._addresses.active_power[i - 1] - 1
values.append((export_power >> (i * 16)) & 0xFFFF)
# Last register is the lowest address
values.reverse()
await self._controller.write_registers(self._addresses.active_power[-1], values)

async def _update_charge(self) -> None:
Expand Down

0 comments on commit 9ade875

Please sign in to comment.