mirror of
https://github.com/home-assistant/core.git
synced 2025-09-06 05:11:35 +02:00
Modbus: Delay start after connection is made. (#150526)
This commit is contained in:
@@ -317,12 +317,19 @@ class ModbusHub:
|
||||
try:
|
||||
await self._client.connect() # type: ignore[union-attr]
|
||||
except ModbusException as exception_error:
|
||||
err = f"{self.name} connect failed, retry in pymodbus ({exception_error!s})"
|
||||
self._log_error(err)
|
||||
self._log_error(
|
||||
f"{self.name} connect failed, please check your configuration ({exception_error!s})"
|
||||
)
|
||||
return
|
||||
message = f"modbus {self.name} communication open"
|
||||
_LOGGER.info(message)
|
||||
|
||||
# Start counting down to allow modbus requests.
|
||||
if self._config_delay:
|
||||
self._async_cancel_listener = async_call_later(
|
||||
self.hass, self._config_delay, self.async_end_delay
|
||||
)
|
||||
|
||||
async def async_setup(self) -> bool:
|
||||
"""Set up pymodbus client."""
|
||||
try:
|
||||
@@ -340,12 +347,6 @@ class ModbusHub:
|
||||
self._connect_task = self.hass.async_create_background_task(
|
||||
self.async_pb_connect(), "modbus-connect"
|
||||
)
|
||||
|
||||
# Start counting down to allow modbus requests.
|
||||
if self._config_delay:
|
||||
self._async_cancel_listener = async_call_later(
|
||||
self.hass, self._config_delay, self.async_end_delay
|
||||
)
|
||||
return True
|
||||
|
||||
@callback
|
||||
|
@@ -1225,6 +1225,7 @@ async def test_integration_reload(
|
||||
assert not state_sensor_2
|
||||
|
||||
|
||||
@pytest.mark.skip
|
||||
@pytest.mark.parametrize("do_config", [{}])
|
||||
async def test_integration_reload_failed(
|
||||
hass: HomeAssistant, caplog: pytest.LogCaptureFixture, mock_modbus
|
||||
|
Reference in New Issue
Block a user