From 0dc8fb497b1162c08286dfd03f54da3d237f38dd Mon Sep 17 00:00:00 2001 From: Michael <35783820+mib1185@users.noreply.github.com> Date: Sat, 4 Sep 2021 03:01:48 +0200 Subject: [PATCH] Delay state update after switch is toggled for TP-Link HS210 device (#55671) * delay state update for HS210 * Update workaround comment --- homeassistant/components/tplink/switch.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/homeassistant/components/tplink/switch.py b/homeassistant/components/tplink/switch.py index 10cf5c64d75..2d5a379198d 100644 --- a/homeassistant/components/tplink/switch.py +++ b/homeassistant/components/tplink/switch.py @@ -1,6 +1,7 @@ """Support for TPLink HS100/HS110/HS200 smart switch.""" from __future__ import annotations +from asyncio import sleep from typing import Any from pyHS100 import SmartPlug @@ -89,9 +90,15 @@ class SmartPlugSwitch(CoordinatorEntity, SwitchEntity): async def async_turn_on(self, **kwargs: Any) -> None: """Turn the switch on.""" await self.hass.async_add_executor_job(self.smartplug.turn_on) + # Workaround for delayed device state update on HS210: #55190 + if "HS210" in self.device_info["model"]: + await sleep(0.5) await self.coordinator.async_refresh() async def async_turn_off(self, **kwargs: Any) -> None: """Turn the switch off.""" await self.hass.async_add_executor_job(self.smartplug.turn_off) + # Workaround for delayed device state update on HS210: #55190 + if "HS210" in self.device_info["model"]: + await sleep(0.5) await self.coordinator.async_refresh()