Skip to content
Merged
Show file tree
Hide file tree
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
17 changes: 16 additions & 1 deletion custom_components/solaredge_modbus_multi/hub.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,13 @@
from pymodbus.client import AsyncModbusTcpClient
from pymodbus.client.mixin import ModbusClientMixin
from pymodbus.exceptions import ConnectionException, ModbusIOException
from pymodbus.pdu import ExceptionResponse

try:
# for pymodbus 3.11.1 and newer
from pymodbus.pdu.pdu import ExceptionResponse
except ImportError:
# or backwards compatibility
from pymodbus.pdu import ExceptionResponse

from .const import (
BATTERY_REG_BASE,
Expand Down Expand Up @@ -528,6 +534,11 @@ async def modbus_read_holding_registers(self, unit, address, rcount):

sig = inspect.signature(self._client.read_holding_registers)

_LOGGER.debug(
f"I{self._rr_unit}: modbus_read_holding_registers "
f"address={self._rr_address} count={self._rr_count}"
)

if "device_id" in sig.parameters:
result = await self._client.read_holding_registers(
address=self._rr_address, count=self._rr_count, device_id=self._rr_unit
Expand All @@ -537,7 +548,11 @@ async def modbus_read_holding_registers(self, unit, address, rcount):
address=self._rr_address, count=self._rr_count, slave=self._rr_unit
)

_LOGGER.debug(f"I{self._rr_unit}: result is error: {result.isError()} ")

if result.isError():
_LOGGER.debug(f"I{self._rr_unit}: error result: {type(result)} ")

if type(result) is ModbusIOException:
raise ModbusIOError(result)

Expand Down
2 changes: 1 addition & 1 deletion custom_components/solaredge_modbus_multi/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@
"issue_tracker": "https://github.com/WillCodeForCats/solaredge-modbus-multi/issues",
"loggers": ["custom_components.solaredge_modbus_multi"],
"requirements": ["pymodbus>=3.8.3"],
"version": "3.1.6"
"version": "3.1.7-pre.1"
}