Skip to content

Commit 4e6957a

Browse files
authored
Merge pull request #100 from fronzbot/dev
Release 0.10.0
2 parents 07e1759 + e747fb1 commit 4e6957a

16 files changed

+711
-662
lines changed

.travis.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ matrix:
44
include:
55
- python: "3.6"
66
env: TOXENV=lint
7-
- python: "3.5"
7+
- python: "3.5.3"
88
env: TOXENV=py35
99
- python: "3.6"
1010
env: TOXENV=py36
@@ -13,6 +13,9 @@ matrix:
1313
- python: "3.7"
1414
env: TOXENV=py37
1515
dist: xenial
16+
- python: "3.8-dev"
17+
env: TOXENV=py38
18+
dist: xenial
1619

1720
install: pip install -U tox coveralls
1821
language: python

CHANGES.rst

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,44 @@ Changelog
33

44
A list of changes between each release
55

6-
0.9.0.dev (Development Version)
6+
0.10.0 (2018-10-16)
77
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
8+
- Moved all API calls to own module for easier maintainability
9+
- Added network ids to sync module and cameras to allow for multi-network use
10+
- Removed dependency on video existance prior to camera setup (fixes `#93 <https://github.com/fronzbot/blinkpy/issues/#93>`_)
11+
- Camera wifi_strength now reported in wifi "bars" rather than dBm due to API endpoint change
12+
- Use homescreen thumbnail as fallback in case it's not in the camera endpoint
13+
- Removed "armed" and "status" attributes from camera (status of camera only reported by "motion_enabled" now)
14+
- Added serial number attributes to sync module and cameras
15+
- Check network_id from login response and verify that network is onboarded (fixes `#90 <https://github.com/fronzbot/#90>`_)
16+
- Check if retrieved clip is "None" prior to storing in cache
17+
18+
0.9.0 (2018-09-27)
19+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
20+
- Complete code refactoring to enable future multi-sync module support
21+
- Add image and video caching to the cameras
22+
- Add internal throttling of system refresh
23+
- Use session for http requests
24+
25+
**Breaking change:**
26+
- Cameras now accessed through sync module Blink.sync.cameras
27+
28+
29+
0.8.1 (2018-09-24)
30+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
31+
- Update requirements_test.txt
32+
- Update linter versions
33+
- Fix pylint warnings
34+
- Remove object from class declarations
35+
- Remove useless returns from functions
36+
- Fix pylint errors
37+
- change if comparison to fix (consider-using-in)
38+
- Disabled no else-if-return check
39+
- Fix useless-import-alias
40+
- Disable no-else-return
41+
- Fix motion detection
42+
- Use an array of recent video clips to determine if motion has been detected.
43+
- Reset the value every system refresh
844

945
0.8.0 (2018-05-21)
1046
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

blinkpy/api.py

Lines changed: 159 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,159 @@
1+
"""Implements known blink API calls."""
2+
3+
import logging
4+
from json import dumps
5+
import blinkpy.helpers.errors as ERROR
6+
from blinkpy.helpers.util import http_req, BlinkException
7+
from blinkpy.helpers.constants import DEFAULT_URL
8+
9+
_LOGGER = logging.getLogger(__name__)
10+
11+
12+
def request_login(blink, url, username, password):
13+
"""Login request."""
14+
headers = {
15+
'Host': DEFAULT_URL,
16+
'Content-Type': 'application/json'
17+
}
18+
data = dumps({
19+
'email': username,
20+
'password': password,
21+
'client_specifier': 'iPhone 9.2 | 2.2 | 222'
22+
})
23+
return http_req(blink, url=url, headers=headers, data=data,
24+
json_resp=False, reqtype='post')
25+
26+
27+
def request_networks(blink):
28+
"""Request network information."""
29+
url = "{}/networks".format(blink.urls.base_url)
30+
return http_get(blink, url)
31+
32+
33+
def request_syncmodule(blink, network):
34+
"""Request sync module info."""
35+
url = "{}/network/{}/syncmodules".format(blink.urls.base_url, network)
36+
return http_get(blink, url)
37+
38+
39+
def request_system_arm(blink, network):
40+
"""Arm system."""
41+
url = "{}/network/{}/arm".format(blink.urls.base_url, network)
42+
return http_post(blink, url)
43+
44+
45+
def request_system_disarm(blink, network):
46+
"""Disarm system."""
47+
url = "{}/network/{}/disarm".format(blink.urls.base_url, network)
48+
return http_post(blink, url)
49+
50+
51+
def request_command_status(blink, network, command_id):
52+
"""Request command status."""
53+
url = "{}/network/{}/command_id/{}".format(blink.urls.base_url,
54+
network,
55+
command_id)
56+
return http_get(blink, url)
57+
58+
59+
def request_homescreen(blink):
60+
"""Request homescreen info."""
61+
url = "{}/homescreen".format(blink.urls.base_url)
62+
return http_get(blink, url)
63+
64+
65+
def request_sync_events(blink, network):
66+
"""Request events from sync module."""
67+
url = "{}/events/network/{}".format(blink.urls.base_url, network)
68+
return http_get(blink, url)
69+
70+
71+
def request_new_image(blink, network, camera_id):
72+
"""Request to capture new thumbnail for camera."""
73+
url = "{}/network/{}/camera/{}/thumbnail".format(blink.urls.base_url,
74+
network,
75+
camera_id)
76+
return http_post(blink, url)
77+
78+
79+
def request_new_video(blink, network, camera_id):
80+
"""Request to capture new video clip."""
81+
url = "{}/network/{}/camera/{}/clip".format(blink.urls.base_url,
82+
network,
83+
camera_id)
84+
return http_post(blink, url)
85+
86+
87+
def request_video_count(blink, headers):
88+
"""Request total video count."""
89+
url = "{}/api/v2/videos/count".format(blink.urls.base_url)
90+
return http_get(blink, url)
91+
92+
93+
def request_videos(blink, page=0):
94+
"""Perform a request for videos."""
95+
url = "{}/api/v2/videos/page/{}".format(blink.urls.base_url, page)
96+
return http_get(blink, url)
97+
98+
99+
def request_cameras(blink, network):
100+
"""Request all camera information."""
101+
url = "{}/network/{}/cameras".format(blink.urls.base_url, network)
102+
return http_get(blink, url)
103+
104+
105+
def request_camera_info(blink, network, camera_id):
106+
"""Request camera info for one camera."""
107+
url = "{}/network/{}/camera/{}".format(blink.urls.base_url,
108+
network,
109+
camera_id)
110+
return http_get(blink, url)
111+
112+
113+
def request_camera_sensors(blink, network, camera_id):
114+
"""Request camera sensor info for one camera."""
115+
url = "{}/network/{}/camera/{}/signals".format(blink.urls.base_url,
116+
network,
117+
camera_id)
118+
return http_get(blink, url)
119+
120+
121+
def request_motion_detection_enable(blink, network, camera_id):
122+
"""Enable motion detection for a camera."""
123+
url = "{}/network/{}/camera/{}/enable".format(blink.urls.base_url,
124+
network,
125+
camera_id)
126+
return http_post(blink, url)
127+
128+
129+
def request_motion_detection_disable(blink, network, camera_id):
130+
"""Disable motion detection for a camera."""
131+
url = "{}/network/{}/camera/{}/disable".format(blink.urls.base_url,
132+
network,
133+
camera_id)
134+
return http_post(blink, url)
135+
136+
137+
def http_get(blink, url, stream=False, json=True):
138+
"""
139+
Perform an http get request.
140+
141+
:param url: URL to perform get request.
142+
:param stream: Stream response? True/FALSE
143+
:param json: Return json response? TRUE/False
144+
"""
145+
if blink.auth_header is None:
146+
raise BlinkException(ERROR.AUTH_TOKEN)
147+
return http_req(blink, url=url, headers=blink.auth_header,
148+
reqtype='get', stream=stream, json_resp=json)
149+
150+
151+
def http_post(blink, url):
152+
"""
153+
Perform an http post request.
154+
155+
:param url: URL to perfom post request.
156+
"""
157+
if blink.auth_header is None:
158+
raise BlinkException(ERROR.AUTH_TOKEN)
159+
return http_req(blink, url=url, headers=blink.auth_header, reqtype='post')

0 commit comments

Comments
 (0)