Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Add option to skip homescreen check #305

Merged
merged 1 commit into from
Jun 14, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion blinkpy/blinkpy.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,10 @@ class Blink:
"""Class to initialize communication."""

def __init__(
self, refresh_rate=DEFAULT_REFRESH, motion_interval=DEFAULT_MOTION_INTERVAL,
self,
refresh_rate=DEFAULT_REFRESH,
motion_interval=DEFAULT_MOTION_INTERVAL,
no_owls=False,
):
"""
Initialize Blink system.
Expand All @@ -51,6 +54,7 @@ def __init__(
Defaults to last refresh time.
Useful for preventing motion_detected property
from de-asserting too quickly.
:param no_owls: Disable searching for owl entries (blink mini cameras only known entity). Prevents an uneccessary API call if you don't have these in your network.
"""
self.auth = Auth()
self.account_id = None
Expand All @@ -68,6 +72,7 @@ def __init__(
self.available = False
self.key_required = False
self.homescreen = {}
self.no_owls = no_owls

@util.Throttle(seconds=MIN_THROTTLE_TIME)
def refresh(self, force=False):
Expand Down Expand Up @@ -141,6 +146,9 @@ def setup_sync_module(self, name, network_id, cameras):

def setup_owls(self):
"""Check for mini cameras."""
if self.no_owls:
_LOGGER.debug("Skipping owl extraction.")
return []
response = api.request_homescreen(self)
self.homescreen = response
network_list = []
Expand Down
6 changes: 6 additions & 0 deletions tests/test_blinkpy.py
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,12 @@ def test_blink_mini_cameras_returned(self, mock_home):
result, [{"1234": {"name": "foo", "id": "1234", "type": "mini"}}]
)

self.blink.no_owls = True
self.blink.network_ids = []
result = self.blink.setup_owls()
self.assertEqual(self.blink.network_ids, [])
self.assertEqual(result, [])

@mock.patch("blinkpy.api.request_homescreen")
@mock.patch("blinkpy.api.request_camera_usage")
def test_blink_mini_attached_to_sync(self, mock_usage, mock_home):
Expand Down