From 33e8553d92db1d3b97f2cabc3427bf0e54030c48 Mon Sep 17 00:00:00 2001 From: jan iversen Date: Sun, 25 Apr 2021 23:11:01 +0200 Subject: [PATCH] Fix frontend freeze due to modbus device not responding (#49651) Changing the timeout from package default, secures SENDING will timeout, and after 3 retries break off. Remark: this commit is tested with pymodbus v2.5.1 the old version v2.3.0 have several problems in this area. self._value = await self.async_get_last_state() pymodbus v2.5.1 is active on DEV (bumped in an earlier PR). --- homeassistant/components/modbus/modbus.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/homeassistant/components/modbus/modbus.py b/homeassistant/components/modbus/modbus.py index 44dd330f6ef..ad53bd2aa53 100644 --- a/homeassistant/components/modbus/modbus.py +++ b/homeassistant/components/modbus/modbus.py @@ -3,6 +3,7 @@ import logging import threading from pymodbus.client.sync import ModbusSerialClient, ModbusTcpClient, ModbusUdpClient +from pymodbus.constants import Defaults from pymodbus.exceptions import ModbusException from pymodbus.transaction import ModbusRtuFramer @@ -138,6 +139,7 @@ class ModbusHub: self._config_timeout = client_config[CONF_TIMEOUT] self._config_delay = 0 + Defaults.Timeout = 10 if self._config_type == "serial": # serial configuration self._config_method = client_config[CONF_METHOD]