From 5edf000ce8c97ec23bddc131dbe3c4b8a2639c4c Mon Sep 17 00:00:00 2001 From: Andrey Date: Fri, 5 Mar 2021 12:38:14 +0300 Subject: [PATCH] tune restore --- custom_components/mega/http.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/custom_components/mega/http.py b/custom_components/mega/http.py index cf60481..072cb10 100644 --- a/custom_components/mega/http.py +++ b/custom_components/mega/http.py @@ -92,9 +92,7 @@ class MegaView(HomeAssistantView): _LOGGER.debug(f"Request: %s from '%s'", data, request.remote) make_ints(data) if data.get('st') == '1': - hass.async_create_task(hub.reload()) - if hub.restore_on_restart: - hass.async_create_task(self.later_restore(hub)) + hass.async_create_task(self.later_restore(hub)) return Response(status=200) port = data.get('pt') data = data.copy() @@ -164,7 +162,9 @@ class MegaView(HomeAssistantView): :return: """ await asyncio.sleep(0.2) - await hub.restore_states() + if hub.restore_on_restart: + await hub.restore_states() + await hub.reload() async def later_update(self, hub): await asyncio.sleep(1)