From cbee1ba496477675c21a75bb90fe6cce9414bb7c Mon Sep 17 00:00:00 2001 From: amitfin Date: Tue, 14 Mar 2023 10:47:26 +0200 Subject: [PATCH] Increase timeout for coolmaster with swing (#87573) Co-authored-by: G Johansson --- .../components/coolmaster/__init__.py | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/homeassistant/components/coolmaster/__init__.py b/homeassistant/components/coolmaster/__init__.py index 129797c356f..289e70e8067 100644 --- a/homeassistant/components/coolmaster/__init__.py +++ b/homeassistant/components/coolmaster/__init__.py @@ -21,9 +21,21 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: """Set up Coolmaster from a config entry.""" host = entry.data[CONF_HOST] port = entry.data[CONF_PORT] - coolmaster = CoolMasterNet( - host, port, swing_support=entry.data.get(CONF_SWING_SUPPORT, False) - ) + if not entry.data.get(CONF_SWING_SUPPORT): + coolmaster = CoolMasterNet( + host, + port, + ) + else: + # Swing support adds an additional request per unit. The requests are + # done in parallel, which can cause delays on the server. Therefore, + # we increase the request timeout to 5 seconds instead of 1. + coolmaster = CoolMasterNet( + host, + port, + read_timeout=5, + swing_support=True, + ) try: info = await coolmaster.info() if not info: