power: implement workaround for Homeassistant devices
Some devices on the Home Assistant server do not update their internal state immediately after a request returns. Introduce a configurable delay to work around this issue. Signed-off-by: Eric Callahan <arksine.code@gmail.com>
This commit is contained in:
parent
c3400bd237
commit
1caaebe03f
|
@ -775,6 +775,7 @@ class HomeAssistant(HTTPDevice):
|
|||
self.device: str = config.get("device")
|
||||
self.token: str = config.get("token")
|
||||
self.domain: str = config.get("domain", "switch")
|
||||
self.status_delay: float = config.getfloat("status_delay", 1.)
|
||||
|
||||
async def _send_homeassistant_command(self,
|
||||
command: str
|
||||
|
@ -818,6 +819,7 @@ class HomeAssistant(HTTPDevice):
|
|||
|
||||
async def _send_power_request(self, state: str) -> str:
|
||||
await self._send_homeassistant_command(state)
|
||||
await asyncio.sleep(self.status_delay)
|
||||
res = await self._send_status_request()
|
||||
return res
|
||||
|
||||
|
|
Loading…
Reference in New Issue