From 69e0165aba79eb4ab71fa8d017eea75397aea487 Mon Sep 17 00:00:00 2001 From: Marc Hoersken Date: Sun, 9 Jun 2024 20:48:19 +0200 Subject: [PATCH] Add another get_homescreen() call after 2fa verification Follow up to #941 as discussed in #917 to fix missing owls/lotus. --- blinkpy/blinkpy.py | 2 ++ tests/test_blinkpy.py | 8 ++++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/blinkpy/blinkpy.py b/blinkpy/blinkpy.py index aa5be02b..dc031ac5 100644 --- a/blinkpy/blinkpy.py +++ b/blinkpy/blinkpy.py @@ -144,6 +144,8 @@ async def setup_prompt_2fa(self): async def setup_post_verify(self): """Initialize blink system after verification.""" try: + if not self.homescreen: + await self.get_homescreen() await self.setup_networks() networks = self.setup_network_ids() cameras = await self.setup_camera_list() diff --git a/tests/test_blinkpy.py b/tests/test_blinkpy.py index 9c01eb04..4caa81f1 100644 --- a/tests/test_blinkpy.py +++ b/tests/test_blinkpy.py @@ -192,12 +192,13 @@ async def test_setup_prompt_2fa(self, mock_key): self.assertTrue(self.blink.key_required) @mock.patch("blinkpy.blinkpy.Blink.setup_camera_list") + @mock.patch("blinkpy.api.request_homescreen") @mock.patch("blinkpy.api.request_networks") @mock.patch("blinkpy.blinkpy.Blink.setup_owls") @mock.patch("blinkpy.blinkpy.Blink.setup_lotus") @mock.patch("blinkpy.blinkpy.BlinkSyncModule.start") async def test_setup_post_verify( - self, mock_sync, mock_lotus, mock_owl, mock_networks, mock_camera + self, mock_sync, mock_lotus, mock_owl, mock_networks, mock_home, mock_camera ): """Test setup after verification.""" self.blink.available = False @@ -214,16 +215,19 @@ async def test_setup_post_verify( mock_networks.return_value = { "summary": {"foo": {"onboarded": True, "name": "bar"}} } + mock_home.return_value = {} mock_camera.return_value = [] self.assertTrue(await self.blink.setup_post_verify()) self.assertTrue(self.blink.available) self.assertFalse(self.blink.key_required) + @mock.patch("blinkpy.api.request_homescreen") @mock.patch("blinkpy.api.request_networks") - async def test_setup_post_verify_failure(self, mock_networks): + async def test_setup_post_verify_failure(self, mock_networks, mock_home): """Test failed setup after verification.""" self.blink.available = False mock_networks.return_value = {} + mock_home.return_value = {} self.assertFalse(await self.blink.setup_post_verify()) self.assertFalse(self.blink.available)