Skip to content

Commit

Permalink
Adapt to pymodbus 3.8.0 API change on client keyword only parameters …
Browse files Browse the repository at this point in the history
  • Loading branch information
alexdelprete committed Feb 2, 2025
1 parent e2dc153 commit 6be5e19
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions custom_components/sinapsi_alfa/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,12 +203,14 @@ def connect(self):
_LOGGER.debug("Inverter not ready for Modbus TCP connection")
raise ConnectionError(f"Inverter not active on {self._host}:{self._port}")

def read_holding_registers(self, address, count, slave):
def read_holding_registers(self, address, count):
"""Read holding registers."""
kwargs = {"slave": slave} if slave else {"slave": self._slave_id}

try:
with self._lock:
return self._client.read_holding_registers(address, count, **kwargs)
return self._client.read_holding_registers(
address=address, count=count, slave=self._slave_id
)
except ConnectionException as connect_error:
_LOGGER.debug(f"Read Holding Registers connect_error: {connect_error}")
raise ConnectionError() from connect_error
Expand Down Expand Up @@ -277,7 +279,7 @@ def read_modbus_alfa(self):
)
else:
read_data = self.read_holding_registers(
address=reg_addr, count=reg_count, slave=self._slave_id
address=reg_addr, count=reg_count
)
# No connection errors, we can start scraping registers
decoder = BinaryPayloadDecoder.fromRegisters(
Expand Down

0 comments on commit 6be5e19

Please sign in to comment.