From ed065fefb67936168b064d8700830cb96562d4e5 Mon Sep 17 00:00:00 2001 From: Erick Cantu Paz Date: Wed, 14 Feb 2024 06:02:46 +0000 Subject: [PATCH] cleaning up linting issues --- .../securitas_direct_new_api/apimanager.py | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/custom_components/securitas/securitas_direct_new_api/apimanager.py b/custom_components/securitas/securitas_direct_new_api/apimanager.py index 3c88e81..deaf5f0 100644 --- a/custom_components/securitas/securitas_direct_new_api/apimanager.py +++ b/custom_components/securitas/securitas_direct_new_api/apimanager.py @@ -253,11 +253,10 @@ async def validate_device( for item in data["auth-phones"]: phones.append(OtpPhone(item["id"], item["phone"])) return (otp_hash, phones) - else: - self.authentication_token = response["data"]["xSValidateDevice"]["hash"] - return (None, None) - # FIXME needs testing + self.authentication_token = response["data"]["xSValidateDevice"]["hash"] + return (None, None) + async def refresh_token(self) -> bool: """Send a login refresh.""" content = { @@ -318,11 +317,12 @@ async def login(self) -> None: try: response = await self._execute_request(content, "mkLoginToken") except SecuritasDirectError as err: - (error_message, result_json, headers, content) = err.args - if result_json["data"]["xSLoginToken"]: - if result_json["data"]["xSLoginToken"]["needDeviceAuthorization"]: - # needs a 2FA - raise Login2FAError(err.args) from err + result_json = err.args[1] + if result_json["data"]: + if result_json["data"]["xSLoginToken"]: + if result_json["data"]["xSLoginToken"]["needDeviceAuthorization"]: + # needs a 2FA + raise Login2FAError(err.args) from err raise LoginError(err.args) from err