diff --git a/blinkpy/auth.py b/blinkpy/auth.py index 41d15046..59967f63 100644 --- a/blinkpy/auth.py +++ b/blinkpy/auth.py @@ -132,7 +132,7 @@ def extract_login_info(self): self.token = self.login_response["auth"]["token"] self.client_id = self.login_response["account"]["client_id"] self.account_id = self.login_response["account"]["account_id"] - self.user_id = self.login_response["account"]["user_id"] + self.user_id = self.login_response["account"].get("user_id", None) async def startup(self): """Initialize tokens for communication.""" diff --git a/blinkpy/blinkpy.py b/blinkpy/blinkpy.py index 84862ced..aa5be02b 100644 --- a/blinkpy/blinkpy.py +++ b/blinkpy/blinkpy.py @@ -179,9 +179,6 @@ async def setup_owls(self): """Check for mini cameras.""" network_list = [] camera_list = [] - if self.homescreen is None: - # Don't try to iterate if homescreen is not defined - return camera_list try: for owl in self.homescreen["owls"]: name = owl["name"] @@ -195,7 +192,7 @@ async def setup_owls(self): network_list.append(str(network_id)) self.sync[name] = BlinkOwl(self, name, network_id, owl) await self.sync[name].start() - except KeyError: + except (KeyError, TypeError): # No sync-less devices found pass @@ -206,9 +203,6 @@ async def setup_lotus(self): """Check for doorbells cameras.""" network_list = [] camera_list = [] - if self.homescreen is None: - # Don't try to iterate if homescreen is not defined - return camera_list try: for lotus in self.homescreen["doorbells"]: name = lotus["name"] @@ -228,7 +222,7 @@ async def setup_lotus(self): network_list.append(str(network_id)) self.sync[name] = BlinkLotus(self, name, network_id, lotus) await self.sync[name].start() - except KeyError: + except (KeyError, TypeError): # No sync-less devices found pass diff --git a/tests/test_auth.py b/tests/test_auth.py index 0d6168e9..b0f5122f 100644 --- a/tests/test_auth.py +++ b/tests/test_auth.py @@ -167,6 +167,7 @@ async def test_refresh_token(self, mock_resp): self.assertEqual(self.auth.token, "foobar") self.assertEqual(self.auth.client_id, 1234) self.assertEqual(self.auth.account_id, 5678) + self.assertEqual(self.auth.user_id, None) mock_resp.return_value.status = 400 with self.assertRaises(TokenRefreshFailed):