Add fix delay after send/request to allow RS485 adapter to switch in modbus (#51417)

This commit is contained in:
jan iversen 2021-06-05 14:41:32 +02:00 committed by GitHub
parent b8afb7dcfe
commit 59b5f94569
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 4 deletions

View File

@ -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

View File

@ -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,
},
],
)