Delay state update after switch is toggled for TP-Link HS210 device (#55671)

* delay state update for HS210

* Update workaround comment
This commit is contained in:
Michael 2021-09-04 03:01:48 +02:00 committed by GitHub
parent b10fc89a6b
commit 0dc8fb497b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

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