Skip to content

Commit 853ccbc

Browse files
authored
Merge pull request #136 from fronzbot/dev
0.11.1
2 parents 1a24e18 + 8153fab commit 853ccbc

File tree

5 files changed

+71
-41
lines changed

5 files changed

+71
-41
lines changed

API.md

Lines changed: 36 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,12 @@
11
# BlinkMonitorProtocol
2-
Unofficial documentation for the Client API of the Blink Wire-Free HD Home Monitoring and Alert System.
2+
Unofficial documentation for the Client API of the Blink Wire-Free HD Home Monitoring & Alert System.
33

44
Copied from https://github.com/MattTW/BlinkMonitorProtocol
55

66
I am not affiliated with the company in any way - this documentation is strictly **"AS-IS"**. My goal was to uncover enough to arm and disarm the system programatically so that I can issue those commands in sync with my home alarm system arm/disarm. Just some raw notes at this point but should be enough for creating programmatic APIs. Lots more to be discovered and documented - feel free to contribute!
77

88
The Client API is a straightforward REST API using JSON and HTTPS.
99

10-
## This Document
11-
The purpose here is to describe what is going on behind the scenes, and what commands we know are available to communicate with Blink servers. This is NOT a description of the blinkpy module, but a description of the commands blinkpy relies on to effectively communicate.
12-
1310
## Login
1411

1512
Client login to the Blink Servers.
@@ -19,20 +16,25 @@ Client login to the Blink Servers.
1916
> "password" : "*your blink password*",
2017
> "client_specifier" : "iPhone 9.2 | 2.2 | 222",
2118
> "email" : "*your blink login/email*"
22-
>}' --compressed https://prod.immedia-semi.com/login
19+
>}' --compressed https://rest.prod.immedia-semi.com/login
2320
2421
**Response:**
25-
>{"authtoken":{"authtoken":"*an auth token*","message":"auth"}}
22+
>{"authtoken":{"authtoken":"*an auth token*","message":"auth"},"networks":{"*network id*":{"name":"*name*","onboarded":true}},"region":{"*regioncode for endpoint*":"*region name"}}
2623
2724
**Notes:**
2825
The authtoken value is passed in a header in future calls.
26+
The region code for endpoint is required to form the URL of the REST endpoint for future calls.
27+
Depending on the region you are registered you will need to change the REST endpoints below:
28+
- from `https://rest.prod.immedia-semi.com`
29+
- to `https://rest.prde.immedia-semi.com` if e.g. your device is registered in Germany
30+
Please note that at this moment it seems that all regions are not implemented equally: not all endpoints are available in all regions
2931

30-
##Networks
32+
## Networks
3133

3234
Obtain information about the Blink networks defined for the logged in user.
3335

3436
**Request:**
35-
>curl -H "Host: prod.immedia-semi.com" -H "TOKEN_AUTH: *authtoken from login*" --compressed https://prod.immedia-semi.com/networks
37+
>curl -H "Host: prod.immedia-semi.com" -H "TOKEN_AUTH: *authtoken from login*" --compressed https://rest.prod.immedia-semi.com/networks
3638
3739
**Response:**
3840
JSON response containing information including Network ID and Account ID.
@@ -46,7 +48,7 @@ Network ID is needed to issue arm/disarm calls
4648
Obtain information about the Blink Sync Modules on the given network.
4749

4850
**Request:**
49-
>curl -H "Host: prod.immedia-semi.com" -H "TOKEN_AUTH: *authtoken from login*" --compressed https://prod.immedia-semi.com/network/*network_id_from_networks_call*/syncmodules
51+
>curl -H "Host: prod.immedia-semi.com" -H "TOKEN_AUTH: *authtoken from login*" --compressed https://rest.prod.immedia-semi.com/network/*network_id_from_networks_call*/syncmodules
5052
5153
**Response:**
5254
JSON response containing information about the known state of the Sync module, most notably if it is online
@@ -56,11 +58,11 @@ Probably not strictly needed but checking result can verify that the sync module
5658

5759

5860
## Arm
59-
61+
6062
Arm the given network (start recording/reporting motion events)
6163

6264
**Request:**
63-
>curl -H "Host: prod.immedia-semi.com" -H "TOKEN_AUTH: *authtoken from login*" --data-binary --compressed https://prod.immedia-semi.com/network/*network_id_from_networks_call*/arm
65+
>curl -H "Host: prod.immedia-semi.com" -H "TOKEN_AUTH: *authtoken from login*" --data-binary --compressed https://rest.prod.immedia-semi.com/network/*network_id_from_networks_call*/arm
6466
6567
**Response:**
6668
JSON response containing information about the arm command request, including the command/request ID
@@ -73,7 +75,7 @@ When this call returns, it does not mean the arm request is complete, the clien
7375
Disarm the given network (stop recording/reporting motion events)
7476

7577
**Request:**
76-
>curl -H "Host: prod.immedia-semi.com" -H "TOKEN_AUTH: *authtoken from login*" --data-binary --compressed https://prod.immedia-semi.com/network/*network_id_from_networks_call*/disarm
78+
>curl -H "Host: prod.immedia-semi.com" -H "TOKEN_AUTH: *authtoken from login*" --data-binary --compressed https://rest.prod.immedia-semi.com/network/*network_id_from_networks_call*/disarm
7779
7880
**Response:**
7981
JSON response containing information about the disarm command request, including the command/request ID
@@ -87,7 +89,7 @@ When this call returns, it does not mean the disarm request is complete, the cl
8789
Get status info on the given command
8890

8991
**Request:**
90-
>curl -H "Host: prod.immedia-semi.com" -H "TOKEN_AUTH: *authtoken from login*" --compressed https://prod.immedia-semi.com/network/*network_id*/command/*command_id*
92+
>curl -H "Host: prod.immedia-semi.com" -H "TOKEN_AUTH: *authtoken from login*" --compressed https://rest.prod.immedia-semi.com/network/*network_id*/command/*command_id*
9193
9294
**Response:**
9395
JSON response containing state information of the given command, most notably whether it has completed and was successful.
@@ -103,20 +105,20 @@ lv_relay, arm, disarm, thumbnail, clip
103105
Return information displayed on the home screen of the mobile client
104106

105107
**Request:**
106-
>curl -H "Host: prod.immedia-semi.com" -H "TOKEN_AUTH: *authtoken from login*" --compressed https://prod.immedia-semi.com/homescreen
108+
>curl -H "Host: prod.immedia-semi.com" -H "TOKEN_AUTH: *authtoken from login*" --compressed https://rest.prod.immedia-semi.com/homescreen
107109
108110
**Response:**
109111
JSON response containing information that the mobile client displays on the home page, including: status, armed state, links to thumbnails for each camera, etc.
110112

111113
**Notes:**
112114
Not necessary to as part of issuing arm/disarm commands, but contains good summary info.
113115

114-
##Events, thumbnails & video captures
116+
## Events, thumbnails & video captures
115117

116118
**Request**
117119
Get events for a given network (sync module) -- Need network ID from home
118120

119-
>curl -H "Host: prod.immedia-semi.com" -H "TOKEN_AUTH: *authtoken from login*" --compressed https://prod.immedia-semi.com/events/network/*network__id*
121+
>curl -H "Host: prod.immedia-semi.com" -H "TOKEN_AUTH: *authtoken from login*" --compressed https://rest.prod.immedia-semi.com/events/network/*network__id*
120122
121123
**Response**
122124
A json list of evets incluing URL's. Replace the "mp4" with "jpg" extension to get the thumbnail of each clip
@@ -144,65 +146,65 @@ Note that you replace the 'mp4' with a 'jpg' to get the thumbnail
144146
**Request**
145147
Captures a new thumbnail for a camera
146148

147-
>curl -H "Host: prod.immedia-semi.com" -H "TOKEN_AUTH: *authtoken from login*" --data-binary --compressed https://prod.immedia-semi.com/network/*network_id*/camera/*camera_id*/thumbnail
149+
>curl -H "Host: prod.immedia-semi.com" -H "TOKEN_AUTH: *authtoken from login*" --data-binary --compressed https://rest.prod.immedia-semi.com/network/*network_id*/camera/*camera_id*/thumbnail
148150
149151
**Response**
150152
Command information.
151153

152154
**Request**
153155
Captures a new video for a camera
154156

155-
>curl -H "Host: prod.immedia-semi.com" -H "TOKEN_AUTH: *authtoken from login*" --data-binary --compressed https://prod.immedia-semi.com/network/*network_id*/camera/*camera_id*/clip
157+
>curl -H "Host: prod.immedia-semi.com" -H "TOKEN_AUTH: *authtoken from login*" --data-binary --compressed https://rest.prod.immedia-semi.com/network/*network_id*/camera/*camera_id*/clip
156158
157159
**Response**
158160
Command information.
159161

160-
##Video Information
162+
## Video Information
161163

162164
**Request**
163165
Get the total number of videos in the system
164166

165-
>curl -H "Host: prod.immedia-semi.com" -H "TOKEN_AUTH: *authtoken from login*" --compressed https://prod.immedia-semi.com/api/v2/videos/count
167+
>curl -H "Host: prod.immedia-semi.com" -H "TOKEN_AUTH: *authtoken from login*" --compressed https://rest.prod.immedia-semi.com/api/v2/videos/count
166168
167169
**Response**
168170
JSON response containing the total video count.
169171

170172
**Request**
171173
Gets a paginated set of video information
172174

173-
>curl -H "Host: prod.immedia-semi.com" -H "TOKEN_AUTH: *authtoken from login*" --compressed https://prod.immedia-semi.com/api/v2/videos/page/0
175+
>curl -H "Host: prod.immedia-semi.com" -H "TOKEN_AUTH: *authtoken from login*" --compressed https://rest.prod.immedia-semi.com/api/v2/videos/page/0
174176
175177
**Response**
176178
JSON response containing a set of video information, including: camera name, creation time, thumbnail URI, size, length
177179

178180
**Request**
179181
Gets information for a specific video by ID
180182

181-
>curl -H "Host: prod.immedia-semi.com" -H "TOKEN_AUTH: *authtoken from login*" --compressed https://prod.immedia-semi.com/api/v2/video/*video_id*
183+
>curl -H "Host: prod.immedia-semi.com" -H "TOKEN_AUTH: *authtoken from login*" --compressed https://rest.prod.immedia-semi.com/api/v2/video/*video_id*
182184
183185
**Response**
184186
JSON response containing video information
185187

186188
**Request**
187189
Gets a list of unwatched videos
188190

189-
>curl -H "Host: prod.immedia-semi.com" -H "TOKEN_AUTH: *authtoken from login*" --compressed https://prod.immedia-semi.com/api/v2/videos/unwatched
191+
>curl -H "Host: prod.immedia-semi.com" -H "TOKEN_AUTH: *authtoken from login*" --compressed https://rest.prod.immedia-semi.com/api/v2/videos/unwatched
190192
191193
**Response**
192194
JSON response containing unwatched video information
193195

194196
**Request**
195197
Deletes a video
196198

197-
>curl -H "Host: prod.immedia-semi.com" -H "TOKEN_AUTH: *authtoken from login*" --data-binary --compressed https://prod.immedia-semi.com/api/v2/video/*video_id*/delete
199+
>curl -H "Host: prod.immedia-semi.com" -H "TOKEN_AUTH: *authtoken from login*" --data-binary --compressed https://rest.prod.immedia-semi.com/api/v2/video/*video_id*/delete
198200
199201
**Response**
200202
Unknown - not tested
201203

202204
**Request**
203205
Deletes all videos
204206

205-
>curl -H "Host: prod.immedia-semi.com" -H "TOKEN_AUTH: *authtoken from login*" --data-binary --compressed https://prod.immedia-semi.com/api/v2/videos/deleteall
207+
>curl -H "Host: prod.immedia-semi.com" -H "TOKEN_AUTH: *authtoken from login*" --data-binary --compressed https://rest.prod.immedia-semi.com/api/v2/videos/deleteall
206208
207209
**Response**
208210
Unknown - not tested
@@ -212,39 +214,39 @@ Unknown - not tested
212214
**Request**
213215
Gets a list of cameras
214216

215-
>curl -H "Host: prod.immedia-semi.com" -H "TOKEN_AUTH: *authtoken from login*" --compressed https://prod.immedia-semi.com/network/*network_id*/cameras
217+
>curl -H "Host: prod.immedia-semi.com" -H "TOKEN_AUTH: *authtoken from login*" --compressed https://rest.prod.immedia-semi.com/network/*network_id*/cameras
216218
217219
**Response**
218220
JSON response containing camera information
219221

220222
**Request**
221223
Gets information for one camera
222224

223-
>curl -H "Host: prod.immedia-semi.com" -H "TOKEN_AUTH: *authtoken from login*" --compressed https://prod.immedia-semi.com/network/*network_id*/camera/*camera_id*
225+
>curl -H "Host: prod.immedia-semi.com" -H "TOKEN_AUTH: *authtoken from login*" --compressed https://rest.prod.immedia-semi.com/network/*network_id*/camera/*camera_id*
224226
225227
**Response**
226228
JSON response containing camera information
227229

228230
**Request**
229231
Gets camera sensor information
230232

231-
>curl -H "Host: prod.immedia-semi.com" -H "TOKEN_AUTH: *authtoken from login*" --compressed https://prod.immedia-semi.com/network/*network_id*/camera/*camera_id*/signals
233+
>curl -H "Host: prod.immedia-semi.com" -H "TOKEN_AUTH: *authtoken from login*" --compressed https://rest.prod.immedia-semi.com/network/*network_id*/camera/*camera_id*/signals
232234
233235
**Response**
234236
JSON response containing camera sensor information, such as wifi strength, temperature, and battery level
235237

236238
**Request**
237239
Enables motion detection for one camera
238240

239-
>curl -H "Host: prod.immedia-semi.com" -H "TOKEN_AUTH: $auth_token" --data-binary --compressed https://prod.immedia-semi.com/network/*network_id*/camera/*camera_id*/enable
241+
>curl -H "Host: prod.immedia-semi.com" -H "TOKEN_AUTH: $auth_token" --data-binary --compressed https://rest.prod.immedia-semi.com/network/*network_id*/camera/*camera_id*/enable
240242
241243
**Response**
242244
JSON response containing camera information
243245

244246
**Request**
245247
Disables motion detection for one camera
246248

247-
>curl -H "Host: prod.immedia-semi.com" -H "TOKEN_AUTH: $auth_token" --data-binary --compressed https://prod.immedia-semi.com/network/*network_id*/camera/*camera_id*/disable
249+
>curl -H "Host: prod.immedia-semi.com" -H "TOKEN_AUTH: $auth_token" --data-binary --compressed https://rest.prod.immedia-semi.com/network/*network_id*/camera/*camera_id*/disable
248250
249251
**Response**
250252
JSON response containing camera information
@@ -257,31 +259,31 @@ JSON response containing camera information
257259
**Request**
258260
Gets information about devices that have connected to the blink service
259261

260-
>curl -H "Host: prod.immedia-semi.com" -H "TOKEN_AUTH: *authtoken from login*" --compressed https://prod.immedia-semi.com/account/clients
262+
>curl -H "Host: prod.immedia-semi.com" -H "TOKEN_AUTH: *authtoken from login*" --compressed https://rest.prod.immedia-semi.com/account/clients
261263
262264
**Response**
263265
JSON response containing client information, including: type, name, connection time, user ID
264266

265267
**Request**
266268
Gets information about supported regions
267269

268-
>curl -H "Host: prod.immedia-semi.com" -H "TOKEN_AUTH: *authtoken from login*" --compressed https://prod.immedia-semi.com/regions
270+
>curl -H "Host: prod.immedia-semi.com" -H "TOKEN_AUTH: *authtoken from login*" --compressed https://rest.prod.immedia-semi.com/regions
269271
270272
**Response**
271273
JSON response containing region information
272274

273275
**Request**
274276
Gets information about system health
275277

276-
>curl -H "Host: prod.immedia-semi.com" -H "TOKEN_AUTH: *authtoken from login*" --compressed https://prod.immedia-semi.com/health
278+
>curl -H "Host: prod.immedia-semi.com" -H "TOKEN_AUTH: *authtoken from login*" --compressed https://rest.prod.immedia-semi.com/health
277279
278280
**Response**
279281
"all ports tested are open"
280282

281283
**Request**
282284
Gets information about programs
283285

284-
>curl -H "Host: prod.immedia-semi.com" -H "TOKEN_AUTH: *authtoken from login*" --compressed https://prod.immedia-semi.com/api/v1/networks/*network_id*/programs
286+
>curl -H "Host: prod.immedia-semi.com" -H "TOKEN_AUTH: *authtoken from login*" --compressed https://rest.prod.immedia-semi.com/api/v1/networks/*network_id*/programs
285287
286288
**Response**
287289
Unknown.

CHANGES.rst

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,16 @@ Changelog
33

44
A list of changes between each release
55

6+
0.11.1 (2019-01-02)
7+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
8+
- Fixed incorrect backup login url
9+
- Added calibrated temperature property for cameras
10+
11+
12+
0.11.0 (2018-11-23)
13+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
14+
- Added support for multiple sync modules
15+
616
0.10.3 (2018-11-18)
717
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
818
- Use networks endpoint rather than homecreen to retrieve arm/disarm status (`@md-reddevil <https://github.com/fronzbot/blinkpy/pull/119>`__)

blinkpy/camera.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ def __init__(self, sync):
2424
self.battery_voltage = None
2525
self.clip = None
2626
self.temperature = None
27+
self.temperature_calibrated = None
2728
self.battery_state = None
2829
self.motion_detected = None
2930
self.wifi_strength = None
@@ -40,6 +41,7 @@ def attributes(self):
4041
'serial': self.serial,
4142
'temperature': self.temperature,
4243
'temperature_c': self.temperature_c,
44+
'temperature_calibrated': self.temperature_calibrated,
4345
'battery': self.battery,
4446
'thumbnail': self.thumbnail,
4547
'video': self.clip,
@@ -104,6 +106,15 @@ def update(self, config, force_cache=False):
104106
self.temperature = config['temperature']
105107
self.wifi_strength = config['wifi_strength']
106108

109+
# Retrieve calibrated temperature from special endpoint
110+
resp = api.request_camera_sensors(self.sync.blink,
111+
self.network_id,
112+
self.camera_id)
113+
try:
114+
self.temperature_calibrated = resp['temp']
115+
except KeyError:
116+
_LOGGER.error("Could not retrieve calibrated temperature.")
117+
107118
# Check if thumbnail exists in config, if not try to
108119
# get it from the homescreen info in teh sync module
109120
# otherwise set it to None and log an error

blinkpy/helpers/constants.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
MAJOR_VERSION = 0
66
MINOR_VERSION = 11
7-
PATCH_VERSION = 0
7+
PATCH_VERSION = 1
88

99
__version__ = '{}.{}.{}'.format(MAJOR_VERSION, MINOR_VERSION, PATCH_VERSION)
1010

@@ -45,10 +45,10 @@
4545
URLS
4646
'''
4747
BLINK_URL = 'immedia-semi.com'
48-
LOGIN_URL = 'https://prod.' + BLINK_URL + '/login'
49-
LOGIN_BACKUP_URL = 'https://rest.piri/' + BLINK_URL + '/login'
50-
BASE_URL = 'https://prod.' + BLINK_URL
51-
DEFAULT_URL = 'prod.' + BLINK_URL
48+
DEFAULT_URL = "{}.{}".format('prod', BLINK_URL)
49+
BASE_URL = "https://{}".format(DEFAULT_URL)
50+
LOGIN_URL = "{}/login".format(BASE_URL)
51+
LOGIN_BACKUP_URL = "https://{}.{}/login".format('rest.piri', BLINK_URL)
5252

5353
'''
5454
Dictionaries

tests/test_cameras.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ def test_camera_update(self, mock_sess):
9898
self.camera.last_record = ['1']
9999
self.camera.sync.all_clips = {'new': {'1': '/test.mp4'}}
100100
mock_sess.side_effect = [
101+
mresp.MockResponse({'temp': 71}, 200),
101102
'test',
102103
'foobar'
103104
]
@@ -110,6 +111,7 @@ def test_camera_update(self, mock_sess):
110111
self.assertEqual(self.camera.battery, 50)
111112
self.assertEqual(self.camera.temperature, 68)
112113
self.assertEqual(self.camera.temperature_c, 20)
114+
self.assertEqual(self.camera.temperature_calibrated, 71)
113115
self.assertEqual(self.camera.wifi_strength, 4)
114116
self.assertEqual(self.camera.thumbnail,
115117
'https://rest.test.immedia-semi.com/thumb.jpg')
@@ -120,7 +122,11 @@ def test_camera_update(self, mock_sess):
120122

121123
def test_thumbnail_not_in_info(self, mock_sess):
122124
"""Test that we grab thumbanil if not in camera_info."""
123-
mock_sess.side_effect = ['foobar', 'barfoo']
125+
mock_sess.side_effect = [
126+
mresp.MockResponse({'temp': 71}, 200),
127+
'foobar',
128+
'barfoo'
129+
]
124130
self.camera.last_record = ['1']
125131
self.camera.sync.record_dates['new'] = ['1']
126132
self.camera.sync.all_clips = {'new': {'1': '/test.mp4'}}
@@ -175,7 +181,8 @@ def test_no_thumbnails(self, mock_sess):
175181
self.assertEqual(self.camera.thumbnail, None)
176182
self.assertEqual(
177183
logrecord.output,
178-
["ERROR:blinkpy.camera:Could not find thumbnail for camera new"]
184+
["ERROR:blinkpy.camera:Could not retrieve calibrated temperature.",
185+
"ERROR:blinkpy.camera:Could not find thumbnail for camera new"]
179186
)
180187

181188
def test_no_video_clips(self, mock_sess):

0 commit comments

Comments
 (0)