Skip to content

Commit

Permalink
Merge pull request #1219 from PSMGoossens/main
Browse files Browse the repository at this point in the history
Issues after pymodbus updates
  • Loading branch information
wills106 authored Jan 16, 2025
2 parents 54ca1b8 + 3e6d42b commit 364625f
Showing 1 changed file with 14 additions and 9 deletions.
23 changes: 14 additions & 9 deletions custom_components/solax_modbus/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -542,15 +542,15 @@ async def async_read_holding_registers(self, unit, address, count):
kwargs = {"slave": unit} if unit else {}
async with self._lock:
await self._check_connection()
resp = await self._client.read_holding_registers(address, count, **kwargs)
resp = await self._client.read_holding_registers(address=address, count=count, **kwargs)
return resp

async def async_read_input_registers(self, unit, address, count):
"""Read input registers."""
kwargs = {"slave": unit} if unit else {}
async with self._lock:
await self._check_connection()
resp = await self._client.read_input_registers(address, count, **kwargs)
resp = await self._client.read_input_registers(address=address, count=count, **kwargs)
return resp

async def async_lowlevel_write_register(self, unit, address, payload):
Expand Down Expand Up @@ -597,7 +597,7 @@ async def async_write_registers_single(self, unit, address, payload): # Needs a
async with self._lock:
await self._check_connection()
try:
resp = await self._client.write_registers(address, payload, **kwargs)
resp = await self._client.write_registers(address=address, values=payload, **kwargs)
except (ConnectionException, ModbusIOException) as e:
original_message = str(e)
raise HomeAssistantError(f"Error writing single Modbus registers: {original_message}") from e
Expand Down Expand Up @@ -655,7 +655,7 @@ async def async_write_registers_multi(self, unit, address, payload): # Needs ad
async with self._lock:
await self._check_connection()
try:
resp = await self._client.write_registers(address, payload, **kwargs)
resp = await self._client.write_registers(address=address, values=payload, **kwargs)
except (ConnectionException, ModbusIOException) as e:
original_message = str(e)
raise HomeAssistantError(f"Error writing multiple Modbus registers: {original_message}") from e
Expand Down Expand Up @@ -773,6 +773,11 @@ async def async_read_modbus_block(self, data, block, typ):
self.plugin.order16,
wordorder=self.plugin.order32,
)
#decoder = self._client.convert_from_registers(
# registers=realtime_data.registers,
# data_type=client.DATATYPE.INT16,
# word_order=self.plugin.order32
#)
prevreg = block.start
for reg in block.regs:
if (reg - prevreg) > 0:
Expand Down Expand Up @@ -989,7 +994,7 @@ async def async_read_holding_registers(self, unit, address, count):
return None
async with hub._lock:
try:
resp = await hub._client.read_holding_registers(address, count, **kwargs)
resp = await hub._client.read_holding_registers(address=address, count=count, **kwargs)
except (ConnectionException, ModbusIOException) as e:
original_message = str(e)
raise HomeAssistantError(f"Error reading Modbus holding registers: {original_message}") from e
Expand All @@ -1007,7 +1012,7 @@ async def async_read_input_registers(self, unit, address, count):
return None
async with hub._lock:
try:
resp = await hub._client.read_input_registers(address, count, **kwargs)
resp = await hub._client.read_input_registers(address=address, count=count, **kwargs)
except (ConnectionException, ModbusIOException) as e:
original_message = str(e)
raise HomeAssistantError(f"Error reading Modbus input registers: {original_message}") from e
Expand All @@ -1029,7 +1034,7 @@ async def async_lowlevel_write_register(self, unit, address, payload):
return None
async with hub._lock:
try:
resp = await self._client.write_register(address, payload[0], **kwargs)
resp = await self._client.write_register(address=address, values=payload[0], **kwargs)
except (ConnectionException, ModbusIOException) as e:
original_message = str(e)
raise HomeAssistantError(f"Error writing single Modbus register: {original_message}") from e
Expand All @@ -1051,7 +1056,7 @@ async def async_write_registers_single(self, unit, address, payload): # Needs a
return None
async with hub._lock:
try:
resp = await self._client.write_registers(address, payload, **kwargs)
resp = await self._client.write_registers(address=address, values=payload, **kwargs)
except (ConnectionException, ModbusIOException) as e:
original_message = str(e)
raise HomeAssistantError(f"Error writing single Modbus registers: {original_message}") from e
Expand Down Expand Up @@ -1116,7 +1121,7 @@ async def async_write_registers_multi(self, unit, address, payload): # Needs ad
return None
async with hub._lock:
try:
resp = await self._client.write_registers(address, payload, **kwargs)
resp = await self._client.write_registers(address=address, values=payload, **kwargs)
except (ConnectionException, ModbusIOException) as e:
original_message = str(e)
raise HomeAssistantError(f"Error writing multiple Modbus registers: {original_message}") from e
Expand Down

0 comments on commit 364625f

Please sign in to comment.