You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.rst
+51-24Lines changed: 51 additions & 24 deletions
Original file line number
Diff line number
Diff line change
@@ -45,59 +45,86 @@ This library was built with the intention of allowing easy communication with Bl
45
45
46
46
Quick Start
47
47
=============
48
-
The simplest way to use this package from a terminal is to call ``Blink.start()`` which will prompt for your Blink username and password and then log you in. Alternatively, you can instantiate the Blink class with a username and password, and call ``Blink.start()`` to login and setup without prompt, as shown below. In addition, http requests are throttled internally via use of the ``Blink.refresh_rate`` variable, which can be set at initialization and defaults to 30 seconds.
48
+
The simplest way to use this package from a terminal is to call ``Blink.start()`` which will prompt for your Blink username and password and then log you in. In addition, http requests are throttled internally via use of the ``Blink.refresh_rate`` variable, which can be set at initialization and defaults to 30 seconds.
49
49
50
50
.. code:: python
51
51
52
-
from blinkpy import blinkpy
53
-
blink = blinkpy.Blink(username='YOUR USER NAME', password='YOUR PASSWORD', refresh_rate=30)
52
+
from blinkpy.blinkpy import Blink
53
+
54
+
blink = Blink()
54
55
blink.start()
55
56
56
-
At startup, you may be prompted for a verification key. Just enter this in the command-line prompt. If you just receive a verification email asking to validate access for your device, enter nothing at this prompt. To avoid any command-line interaction, call the ``Blink`` class with the ``no_prompt=True`` flag. Instead, once you receive the verification email, call the following functions:
57
+
58
+
This flow will prompt you for your username and password. Once entered, if you likely will need to send a 2FA key to the blink servers (this pin is sent to your email address). When you receive this pin, enter at the prompt and the Blink library will proceed with setup.
59
+
60
+
Starting blink without a prompt
61
+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
62
+
In some cases, having an interactive command-line session is not desired. In this case, you will need to set the ``Blink.auth.no_prompt`` value to ``True``. In addition, since you will not be prompted with a username and password, you must supply the login data to the blink authentication handler. This is best done by instantiating your own auth handler with a dictionary containing at least your username and password.
Since you will not be prompted for any 2FA pin, you must call the ``blink.auth.send_auth_key`` function. There are two required parameters: the ``blink`` object as well as the ``key`` you received from Blink for 2FA:
77
+
78
+
.. code:: python
79
+
80
+
auth.send_auth_key(blink, <your key>)
61
81
blink.setup_post_verify()
62
82
63
-
In addition, you can also save your credentials in a json file and initialize Blink with the credential file as follows:
83
+
84
+
Supplying credentials from file
85
+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
86
+
Other use cases may involved loading credentials from a file. This file must be ``json`` formatted and contain a minimum of ``username`` and ``password``. A built in function in the ``blinkpy.helpers.util`` module can aid in loading this file. Note, if ``no_prompt`` is desired, a similar flow can be followed as above.
The credential file must be json formatted with a ``username`` and ``password`` key like follows:
72
99
73
-
.. code:: json
100
+
Saving credentials
101
+
~~~~~~~~~~~~~~~~~~~
102
+
This library also allows you to save your credentials to use in future sessions. Saved information includes authentication tokens as well as unique ids which should allow for a more streamlined experience and limits the frequency of login requests. This data can be saved as follows (it can then be loaded by following the instructions above for supplying credentials from a file):
103
+
104
+
.. code:: python
105
+
106
+
blink.save("<File location>")
74
107
75
-
{
76
-
"username": "YOUR USER NAME",
77
-
"password": "YOUR PASSWORD"
78
-
}
79
108
109
+
Getting cameras
110
+
~~~~~~~~~~~~~~~~
80
111
Cameras are instantiated as individual ``BlinkCamera`` classes within a ``BlinkSyncModule`` instance. All of your sync modules are stored within the ``Blink.sync`` dictionary and can be accessed using the name of the sync module as the key (this is the name of your sync module in the Blink App).
81
112
82
113
The below code will display cameras and their available attributes:
83
114
84
115
.. code:: python
85
116
86
-
from blinkpy import blinkpy
87
-
88
-
blink = blinkpy.Blink(username='YOUR USER NAME', password='YOUR PASSWORD')
89
-
blink.start()
90
-
91
117
for name, camera in blink.cameras.items():
92
118
print(name) # Name of the camera
93
119
print(camera.attributes) # Print available attributes of camera
94
120
95
-
The most recent images and videos can be accessed as a bytes-object via internal variables. These can be updated with calls to ``Blink.refresh()`` but will only make a request if motion has been detected or other changes have been found. This can be overridden with the ``force_cache`` flag, but this should be used for debugging only since it overrides the internal request throttling.
121
+
122
+
The most recent images and videos can be accessed as a bytes-object via internal variables. These can be updated with calls to ``Blink.refresh()`` but will only make a request if motion has been detected or other changes have been found. This can be overridden with the ``force`` flag, but this should be used for debugging only since it overrides the internal request throttling.
96
123
97
124
.. code:: python
98
125
99
126
camera = blink.cameras['SOME CAMERA NAME']
100
-
blink.refresh(force_cache=True) # force a cache update USE WITH CAUTION
127
+
blink.refresh(force=True) # force a cache update USE WITH CAUTION
camera.video_from_cache.raw # bytes-like video object (mp4)
103
130
@@ -110,15 +137,15 @@ The ``blinkpy`` api also allows for saving images and videos to a file and snapp
110
137
blink.refresh() # Get new information from server
111
138
camera.image_to_file('/local/path/for/image.jpg')
112
139
camera.video_to_file('/local/path/for/video.mp4')
113
-
140
+
141
+
Download videos
142
+
~~~~~~~~~~~~~~~~
114
143
You can also use this library to download all videos from the server. In order to do this, you must specify a ``path``. You may also specifiy a how far back in time to go to retrieve videos via the ``since=`` variable (a simple string such as ``"2017/09/21"`` is sufficient), as well as how many pages to traverse via the ``page=`` variable. Note that by default, the library will search the first ten pages which is sufficient in most use cases. Additionally, you can specidy one or more cameras via the ``camera=`` property. This can be a single string indicating the name of the camera, or a list of camera names. By default, it is set to the string ``'all'`` to grab videos from all cameras.
115
144
116
145
Example usage, which downloads all videos recorded since July 4th, 2018 at 9:34am to the ``/home/blink`` directory:
117
146
118
147
.. code:: python
119
148
120
-
blink = blinkpy.Blink(username="YOUR USER NAME", password="YOUR PASSWORD")
0 commit comments