From b4b2c1c56ade896d8f98412c70ec88cca3ea5c3b Mon Sep 17 00:00:00 2001 From: Alex X Date: Wed, 18 Sep 2024 07:16:21 +0300 Subject: [PATCH] Fix send cloud command after logout --- .../sonoff/core/ewelink/cloud.py | 27 ++++++++++--------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/custom_components/sonoff/core/ewelink/cloud.py b/custom_components/sonoff/core/ewelink/cloud.py index 0e22041..c451bbd 100644 --- a/custom_components/sonoff/core/ewelink/cloud.py +++ b/custom_components/sonoff/core/ewelink/cloud.py @@ -467,21 +467,22 @@ async def send( sequence = await self.sequence() log += sequence - # https://coolkit-technologies.github.io/eWeLink-API/#/en/APICenterV2?id=websocket-update-device-status - payload = { - "action": "update" if params else "query", - # we need to use device apikey bacause device may be shared from - # another account - "apikey": device["apikey"], - "selfApikey": self.auth["user"]["apikey"], - "deviceid": device["deviceid"], - "params": params or [], - "userAgent": "app", - "sequence": sequence, - } - _LOGGER.debug(log) try: + # https://coolkit-technologies.github.io/eWeLink-API/#/en/APICenterV2?id=websocket-update-device-status + payload = { + "action": "update" if params else "query", + # we need to use device apikey bacause device may be shared from + # another account + "apikey": device["apikey"], + # auth can be null (logged in from another place) + "selfApikey": self.auth["user"]["apikey"], + "deviceid": device["deviceid"], + "params": params or [], + "userAgent": "app", + "sequence": sequence, + } + await self.ws.send_json(payload) if timeout: