diff --git a/custom_components/protocol_wizard/config_flow.py b/custom_components/protocol_wizard/config_flow.py index d94cac1..1522446 100644 --- a/custom_components/protocol_wizard/config_flow.py +++ b/custom_components/protocol_wizard/config_flow.py @@ -15,6 +15,7 @@ AsyncModbusTcpClient, AsyncModbusUdpClient, ) +from pymodbus.exceptions import ModbusIOException from .const import ( CONF_BAUDRATE, @@ -318,7 +319,7 @@ async def async_step_modbus_device(self, user_input: dict[str, Any] | None = Non }, ) - except (OSError, ConnectionError, TimeoutError): + except (ModbusIOException, OSError, ConnectionError, TimeoutError): _LOGGER.exception("Connection test failed") errors["base"] = "cannot_connect" @@ -435,7 +436,7 @@ async def _async_test_modbus_connection(self, data: dict[str, Any]) -> None: if not result.isError() and hasattr(result, "registers") and len(result.registers) == count: success = True break - except (OSError, ConnectionError, TimeoutError) as inner_err: + except (ModbusIOException, OSError, ConnectionError, TimeoutError) as inner_err: _LOGGER.debug("Test read failed for %s at addr %d: %s", name, address, inner_err) if not success: