From 93c0998b4ea164672da2e65378c58213db889cc8 Mon Sep 17 00:00:00 2001 From: osk2 Date: Thu, 19 Aug 2021 11:53:32 +0800 Subject: [PATCH] Improve exception handling --- custom_components/panasonic_smart_app/smartApp/__init__.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/custom_components/panasonic_smart_app/smartApp/__init__.py b/custom_components/panasonic_smart_app/smartApp/__init__.py index aadfef4..b5b9c81 100644 --- a/custom_components/panasonic_smart_app/smartApp/__init__.py +++ b/custom_components/panasonic_smart_app/smartApp/__init__.py @@ -226,7 +226,7 @@ async def request( timeout=REQUEST_TIMEOUT, ) except: - auth = headers["auth"] or None + auth = headers.get("auth") if auth: device = list( filter(lambda device: device["auth"] == auth, self._devices) @@ -246,7 +246,7 @@ async def request( resp = await response.json() if resp.get("StateMsg") == EXCEPTION_COMMAND_NOT_FOUND: - auth = headers["auth"] + auth = headers.get("auth") if auth: device = list( filter(lambda device: device["auth"] == auth, self._devices)