From b29da647101d7cca22a3d909a588e24d42eafe67 Mon Sep 17 00:00:00 2001 From: Iain Matchett Date: Fri, 27 Dec 2019 23:36:04 +0000 Subject: [PATCH] added a guard against devices without the correct structure --- lakeside/__init__.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lakeside/__init__.py b/lakeside/__init__.py index 095f38d..b0c8a92 100755 --- a/lakeside/__init__.py +++ b/lakeside/__init__.py @@ -35,14 +35,13 @@ def get_devices(username, password): payload = {'client_id':client_id, 'client_Secret':client_secret, 'email':username, 'password':password} r = requests.post("https://home-api.eufylife.com/v1/user/email/login", json=payload) - token = r.json()['access_token'] headers = {'token': token, 'category': 'Home'} r = requests.get("https://home-api.eufylife.com/v1/device/list/devices-and-groups", headers=headers) info = r.json() for item in info['items']: - if item['device'] is not None: + if item['device'] is not None and item['device']['wifi'] is not None: devices.append({ 'address': item['device']['wifi']['lan_ip_addr'], 'code': item['device']['local_code'],