From 616f0db5ce0384b9ce6376530316a14c46bb0d33 Mon Sep 17 00:00:00 2001 From: "sourcery-ai[bot]" <58596630+sourcery-ai[bot]@users.noreply.github.com> Date: Thu, 7 Apr 2022 17:13:33 +0200 Subject: [PATCH] Add else condition if API call returns none (Sourcery refactored) (#12) * Add else condition if API call returns none I was getting exceptions when the API call returned none. * 'Refactored by Sourcery' Co-authored-by: Brian Orpin Co-authored-by: Sourcery AI <> --- custom_components/vesync/pyvesync/vesyncfan.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/custom_components/vesync/pyvesync/vesyncfan.py b/custom_components/vesync/pyvesync/vesyncfan.py index 102765d..e4e25b5 100644 --- a/custom_components/vesync/pyvesync/vesyncfan.py +++ b/custom_components/vesync/pyvesync/vesyncfan.py @@ -877,9 +877,10 @@ class VeSyncHumid200300S(VeSyncBaseDevice): ) if r is None or not isinstance(r, dict): logger.debug("Error getting status of %s ", self.device_name) - outer_result = r.get("result", {}) + outer_result = None + else: + outer_result = r.get("result", {}) inner_result = None - if outer_result is not None: inner_result = r.get("result", {}).get("result") if inner_result is not None and Helpers.code_check(r):