Skip to content

Commit 08e85ad

Browse files
committed
Delay start after connection is made.
1 parent dafe375 commit 08e85ad

File tree

2 files changed

+10
-8
lines changed

2 files changed

+10
-8
lines changed

custom_components/modbus/manifest.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,5 @@
66
"iot_class": "local_polling",
77
"loggers": ["pymodbus"],
88
"requirements": ["pymodbus==3.11.1"]
9+
"version": "1.4.0"
910
}

custom_components/modbus/modbus.py

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -317,12 +317,19 @@ async def async_pb_connect(self) -> None:
317317
try:
318318
await self._client.connect() # type: ignore[union-attr]
319319
except ModbusException as exception_error:
320-
err = f"{self.name} connect failed, retry in pymodbus ({exception_error!s})"
321-
self._log_error(err)
320+
self._log_error(
321+
f"{self.name} connect failed, please check your configuration ({exception_error!s})"
322+
)
322323
return
323324
message = f"modbus {self.name} communication open"
324325
_LOGGER.info(message)
325326

327+
# Start counting down to allow modbus requests.
328+
if self._config_delay:
329+
self._async_cancel_listener = async_call_later(
330+
self.hass, self._config_delay, self.async_end_delay
331+
)
332+
326333
async def async_setup(self) -> bool:
327334
"""Set up pymodbus client."""
328335
try:
@@ -340,12 +347,6 @@ async def async_setup(self) -> bool:
340347
self._connect_task = self.hass.async_create_background_task(
341348
self.async_pb_connect(), "modbus-connect"
342349
)
343-
344-
# Start counting down to allow modbus requests.
345-
if self._config_delay:
346-
self._async_cancel_listener = async_call_later(
347-
self.hass, self._config_delay, self.async_end_delay
348-
)
349350
return True
350351

351352
@callback

0 commit comments

Comments
 (0)