Skip to content

Commit 9c5e491

Browse files
Merge pull request #898 from WillCodeForCats/896-modbus-exception-when-detecting-meters
Update ExceptionResponse import for pymodbus 3.11
2 parents c198542 + eed9c74 commit 9c5e491

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

custom_components/solaredge_modbus_multi/hub.py

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,13 @@
1414
from pymodbus.client import AsyncModbusTcpClient
1515
from pymodbus.client.mixin import ModbusClientMixin
1616
from pymodbus.exceptions import ConnectionException, ModbusIOException
17-
from pymodbus.pdu import ExceptionResponse
17+
18+
try:
19+
# for pymodbus 3.11.1 and newer
20+
from pymodbus.pdu.pdu import ExceptionResponse
21+
except ImportError:
22+
# or backwards compatibility
23+
from pymodbus.pdu import ExceptionResponse
1824

1925
from .const import (
2026
BATTERY_REG_BASE,
@@ -528,6 +534,11 @@ async def modbus_read_holding_registers(self, unit, address, rcount):
528534

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

537+
_LOGGER.debug(
538+
f"I{self._rr_unit}: modbus_read_holding_registers "
539+
f"address={self._rr_address} count={self._rr_count}"
540+
)
541+
531542
if "device_id" in sig.parameters:
532543
result = await self._client.read_holding_registers(
533544
address=self._rr_address, count=self._rr_count, device_id=self._rr_unit
@@ -537,7 +548,11 @@ async def modbus_read_holding_registers(self, unit, address, rcount):
537548
address=self._rr_address, count=self._rr_count, slave=self._rr_unit
538549
)
539550

551+
_LOGGER.debug(f"I{self._rr_unit}: result is error: {result.isError()} ")
552+
540553
if result.isError():
554+
_LOGGER.debug(f"I{self._rr_unit}: error result: {type(result)} ")
555+
541556
if type(result) is ModbusIOException:
542557
raise ModbusIOError(result)
543558

custom_components/solaredge_modbus_multi/manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,5 @@
1010
"issue_tracker": "https://github.com/WillCodeForCats/solaredge-modbus-multi/issues",
1111
"loggers": ["custom_components.solaredge_modbus_multi"],
1212
"requirements": ["pymodbus>=3.8.3"],
13-
"version": "3.1.6"
13+
"version": "3.1.7-pre.1"
1414
}

0 commit comments

Comments
 (0)