Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issues after pymodbus updates #1219

Merged
merged 2 commits into from
Jan 16, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 14 additions & 9 deletions custom_components/solax_modbus/__init__.py
Original file line number Diff line number Diff line change
@@ -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):
@@ -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
@@ -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
@@ -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:
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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