Compare commits
16
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
130b5acf84 | ||
|
|
d0fa303c88 | ||
|
|
dff0746450 | ||
|
|
815dfd9a8e | ||
|
|
b0ea0566a5 | ||
|
|
0167900415 | ||
|
|
9279ba2aa9 | ||
|
|
2abfc3e843 | ||
|
|
4ff83585b4 | ||
|
|
3cf2b5e093 | ||
|
|
6a7eff6501 | ||
|
|
3805a41d9f | ||
|
|
f8c78fb499 | ||
|
|
3314ff85ed | ||
|
|
67b24eb89a | ||
|
|
d416e42925 |
+14
-6
@@ -1,11 +1,12 @@
|
||||
"""Script to run blinkpy as an app."""
|
||||
from os import environ
|
||||
from datetime import datetime, timedelta
|
||||
from blinkpy import blinkpy
|
||||
from blinkpy.blinkpy import Blink
|
||||
from blinkpy.auth import Auth
|
||||
from blinkpy.helpers.util import json_load
|
||||
|
||||
|
||||
USERNAME = environ.get("USERNAME")
|
||||
PASSWORD = environ.get("PASSWORD")
|
||||
CREDFILE = environ.get("CREDFILE")
|
||||
TIMEDELTA = timedelta(environ.get("TIMEDELTA", 1))
|
||||
|
||||
|
||||
@@ -21,11 +22,18 @@ def download_videos(blink, save_dir="/media"):
|
||||
|
||||
def start():
|
||||
"""Startup blink app."""
|
||||
blink = blinkpy.Blink(username=USERNAME, password=PASSWORD)
|
||||
blink = Blink()
|
||||
blink.auth = Auth(json_load(CREDFILE))
|
||||
blink.start()
|
||||
return blink
|
||||
|
||||
|
||||
def main():
|
||||
"""Run the app."""
|
||||
blink = start()
|
||||
download_videos(blink)
|
||||
blink.save(CREDFILE)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
BLINK = start()
|
||||
download_videos(BLINK)
|
||||
main()
|
||||
|
||||
+1
-1
@@ -32,7 +32,7 @@ def request_login(
|
||||
"client_name": "Computer",
|
||||
"client_type": "android",
|
||||
"os_version": "5.1.1",
|
||||
"reauth": "true",
|
||||
"reauth": "false",
|
||||
}
|
||||
)
|
||||
return auth.query(
|
||||
|
||||
+10
-6
@@ -100,6 +100,7 @@ class Blink:
|
||||
self.auth.startup()
|
||||
self.setup_login_ids()
|
||||
self.setup_urls()
|
||||
self.get_homescreen()
|
||||
except (LoginError, TokenRefreshFailed, BlinkSetupError):
|
||||
_LOGGER.error("Cannot setup Blink platform.")
|
||||
self.available = False
|
||||
@@ -144,17 +145,20 @@ class Blink:
|
||||
self.sync[name] = BlinkSyncModule(self, name, network_id, cameras)
|
||||
self.sync[name].start()
|
||||
|
||||
def setup_owls(self):
|
||||
"""Check for mini cameras."""
|
||||
def get_homescreen(self):
|
||||
"""Get homecreen information."""
|
||||
if self.no_owls:
|
||||
_LOGGER.debug("Skipping owl extraction.")
|
||||
return []
|
||||
response = api.request_homescreen(self)
|
||||
self.homescreen = response
|
||||
self.homescreen = {}
|
||||
return
|
||||
self.homescreen = api.request_homescreen(self)
|
||||
|
||||
def setup_owls(self):
|
||||
"""Check for mini cameras."""
|
||||
network_list = []
|
||||
camera_list = []
|
||||
try:
|
||||
for owl in response["owls"]:
|
||||
for owl in self.homescreen["owls"]:
|
||||
name = owl["name"]
|
||||
network_id = str(owl["network_id"])
|
||||
if network_id in self.network_ids:
|
||||
|
||||
@@ -4,7 +4,7 @@ import os
|
||||
|
||||
MAJOR_VERSION = 0
|
||||
MINOR_VERSION = 16
|
||||
PATCH_VERSION = "0-rc5"
|
||||
PATCH_VERSION = "0-rc7"
|
||||
|
||||
__version__ = f"{MAJOR_VERSION}.{MINOR_VERSION}.{PATCH_VERSION}"
|
||||
|
||||
|
||||
@@ -6,8 +6,8 @@ pre-commit==2.5.1
|
||||
pylint==2.5.3
|
||||
pydocstyle==5.0.2
|
||||
pytest==5.4.3
|
||||
pytest-cov==2.9.0
|
||||
pytest-cov==2.10.0
|
||||
pytest-sugar==0.9.3
|
||||
pytest-timeout==1.3.4
|
||||
pytest-timeout==1.4.1
|
||||
restructuredtext-lint==1.3.1
|
||||
pygments==2.6.1
|
||||
|
||||
@@ -197,12 +197,11 @@ class TestBlinkSetup(unittest.TestCase):
|
||||
self.assertEqual(combined["fizz"], "buzz")
|
||||
self.assertEqual(combined["bar"], "foo")
|
||||
|
||||
@mock.patch("blinkpy.api.request_homescreen")
|
||||
@mock.patch("blinkpy.blinkpy.BlinkOwl.start")
|
||||
def test_initialize_blink_minis(self, mock_start, mock_home):
|
||||
def test_initialize_blink_minis(self, mock_start):
|
||||
"""Test blink mini initialization."""
|
||||
mock_start.return_value = True
|
||||
mock_home.return_value = {
|
||||
self.blink.homescreen = {
|
||||
"owls": [
|
||||
{
|
||||
"enabled": False,
|
||||
@@ -235,11 +234,10 @@ class TestBlinkSetup(unittest.TestCase):
|
||||
self.assertEqual(self.blink.sync["foo"].name, "foo")
|
||||
self.assertEqual(self.blink.sync["bar"].name, "bar")
|
||||
|
||||
@mock.patch("blinkpy.api.request_homescreen")
|
||||
def test_blink_mini_cameras_returned(self, mock_home):
|
||||
def test_blink_mini_cameras_returned(self):
|
||||
"""Test that blink mini cameras are found if attached to sync module."""
|
||||
self.blink.network_ids = ["1234"]
|
||||
mock_home.return_value = {
|
||||
self.blink.homescreen = {
|
||||
"owls": [
|
||||
{
|
||||
"id": 1,
|
||||
@@ -261,16 +259,16 @@ class TestBlinkSetup(unittest.TestCase):
|
||||
|
||||
self.blink.no_owls = True
|
||||
self.blink.network_ids = []
|
||||
self.blink.get_homescreen()
|
||||
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):
|
||||
def test_blink_mini_attached_to_sync(self, mock_usage):
|
||||
"""Test that blink mini cameras are properly attached to sync module."""
|
||||
self.blink.network_ids = ["1234"]
|
||||
mock_home.return_value = {
|
||||
self.blink.homescreen = {
|
||||
"owls": [
|
||||
{
|
||||
"id": 1,
|
||||
|
||||
Reference in New Issue
Block a user