diff --git a/homeassistant/components/modbus/modbus.py b/homeassistant/components/modbus/modbus.py index 20e9978c0e8..f75c30b363b 100644 --- a/homeassistant/components/modbus/modbus.py +++ b/homeassistant/components/modbus/modbus.py @@ -329,6 +329,10 @@ class ModbusHub: if not self._client.is_socket_open(): return None async with self._lock: - return await self.hass.async_add_executor_job( + result = await self.hass.async_add_executor_job( self._pymodbus_call, unit, address, value, use_call ) + if self._config_type == "serial": + # small delay until next request/response + await asyncio.sleep(30 / 1000) + return result diff --git a/tests/components/modbus/test_init.py b/tests/components/modbus/test_init.py index 5f311ab57b0..737c5ef2bb6 100644 --- a/tests/components/modbus/test_init.py +++ b/tests/components/modbus/test_init.py @@ -325,9 +325,13 @@ SERVICE = "service" [ { CONF_NAME: TEST_MODBUS_NAME, - CONF_TYPE: "tcp", - CONF_HOST: TEST_HOST, - CONF_PORT: 5501, + CONF_TYPE: "serial", + CONF_BAUDRATE: 9600, + CONF_BYTESIZE: 8, + CONF_METHOD: "rtu", + CONF_PORT: "usb01", + CONF_PARITY: "E", + CONF_STOPBITS: 1, }, ], )