Compare commits

..
24 Commits
Author SHA1 Message Date
Kevin FronczakandGitHub ae946dbb53 Merge pull request #121 from fronzbot/dev
0.10.3
2018-11-20 21:47:42 -05:00
Kevin Fronczak 7ee57b2c6b Version bump 2018-11-20 21:40:18 -05:00
Kevin FronczakandGitHub ccd393a533 Merge pull request #120 from fronzbot/fix-bad-logging
Logging fixes
2018-11-20 21:26:32 -05:00
Kevin Fronczak 1b571c7d4b Fix logging string format 2018-11-20 21:21:42 -05:00
Kevin Fronczak 4b91fcb615 Improved video page debug logging 2018-11-20 21:20:35 -05:00
Kevin Fronczak 1e0d069dcd Fix linting errors 2018-11-20 21:16:41 -05:00
Kevin Fronczak 92088779e0 Added debug logging 2018-11-20 21:15:01 -05:00
Kevin Fronczak a6e02433b6 Fix #113 2018-11-20 21:12:12 -05:00
Kevin FronczakandGitHub 1aa5dc1c71 Merge pull request #119 from md-reddevil/dev
Use network_status instead of homescreen
2018-11-19 12:49:47 -05:00
Kevin Fronczak 3c78923853 Fix linting error (line was too long) 2018-11-19 12:46:01 -05:00
Kevin Fronczak d17183a152 Fixed broken sync module test 2018-11-19 12:42:54 -05:00
2e5e343913 Update blinkpy/sync_module.py fix linting
Co-Authored-By: md-reddevil <16707502+md-reddevil@users.noreply.github.com>
2018-11-18 14:06:21 +02:00
md-reddevilandGitHub cec6035d23 fix tests after API changes 2018-11-18 14:01:22 +02:00
md-reddevil bdc760608e fix indentation 2018-11-17 18:20:28 +02:00
md-reddevil 4f41899338 fix indentation 2018-11-17 18:18:57 +02:00
md-reddevil 557f21b637 Use network_status instead of homescreen
Use network_status to check if System is armed or disarmed
2018-11-17 18:12:26 +02:00
Kevin FronczakandGitHub 4241b50002 Merge pull request #118 from md-reddevil/dev
API: Fix Command Status method add a new method to manage correctly the System status
2018-11-14 09:01:10 -05:00
md-reddevilandGitHub 8b0507f1a7 fix indentation for method request_command_status 2018-11-14 15:57:46 +02:00
md-reddevilandGitHub d62429189e Fix formatting issue in api.py 2018-11-14 11:04:40 +02:00
md-reddevilandGitHub c83b173a17 update description of the networks method 2018-11-14 09:55:17 +02:00
md-reddevilandGitHub 9c1974c227 Add method to request the Network/System status
Home screen method returns just the information about last added System(network). The method "request_network_status", should replace the homescreen method in order to obtain all the information about a system.
2018-11-14 09:39:44 +02:00
md-reddevilandGitHub c621ba3150 fix check command status 2018-11-14 09:34:25 +02:00
Kevin FronczakandGitHub 7710e3f972 Errant whitespace 2018-10-30 21:08:43 -04:00
Kevin Fronczak a4f65c1102 dev version bump 2018-10-30 20:24:39 -04:00
8 changed files with 54 additions and 31 deletions
+18 -10
View File
@@ -3,6 +3,14 @@ Changelog
A list of changes between each release
0.10.3 (2018-11-18)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
- Use networks endpoint rather than homecreen to retrieve arm/disarm status (`@md-reddevil <https://github.com/fronzbot/blinkpy/pull/119>`__)
- Fix incorrect command status endpoint (`@md-reddevil <https://github.com/fronzbot/blinkpy/pull/118>`__)
- Add extra debug logging
- Remove error prior to re-authorization (only log error when re-auth failed)
0.10.2 (2018-10-30)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
- Set minimum required version of the requests library to 2.20.0 due to vulnerability in earlier releases.
@@ -11,19 +19,19 @@ A list of changes between each release
0.10.1 (2018-10-18)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
- Fix re-authorization bug (fixes `#101 <https://github.com/fronzbot/blinkpy/issues/#101>`_)
- Fix re-authorization bug (fixes `#101 <https://github.com/fronzbot/blinkpy/issues/#101>`__)
- Log an error if saving video that doesn't exist
0.10.0 (2018-10-16)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
- Moved all API calls to own module for easier maintainability
- Added network ids to sync module and cameras to allow for multi-network use
- Removed dependency on video existance prior to camera setup (fixes `#93 <https://github.com/fronzbot/blinkpy/issues/#93>`_)
- Removed dependency on video existance prior to camera setup (fixes `#93 <https://github.com/fronzbot/blinkpy/issues/#93>`__)
- Camera wifi_strength now reported in wifi "bars" rather than dBm due to API endpoint change
- Use homescreen thumbnail as fallback in case it's not in the camera endpoint
- Removed "armed" and "status" attributes from camera (status of camera only reported by "motion_enabled" now)
- Added serial number attributes to sync module and cameras
- Check network_id from login response and verify that network is onboarded (fixes `#90 <https://github.com/fronzbot/#90>`_)
- Check network_id from login response and verify that network is onboarded (fixes `#90 <https://github.com/fronzbot/#90>`__)
- Check if retrieved clip is "None" prior to storing in cache
0.9.0 (2018-09-27)
@@ -55,26 +63,26 @@ A list of changes between each release
0.8.0 (2018-05-21)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
- Added support for battery voltage level (fixes `#64 <https://github.com/fronzbot/blinkpy/issues/64>`_)
- Added support for battery voltage level (fixes `#64 <https://github.com/fronzbot/blinkpy/issues/64>`__)
- Added motion detection per camera
- Added fully accessible camera configuration dict
- Added celcius property to camera (fixes `#60 <https://github.com/fronzbot/blinkpy/issues/60>`_)
- Added celcius property to camera (fixes `#60 <https://github.com/fronzbot/blinkpy/issues/60>`__)
0.7.1 (2018-05-09)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
- Fixed pip 10 import issue during setup (`@fronzbot <https://github.com/fronzbot/blinkpy/pull/61>`_)
- Fixed pip 10 import issue during setup (`@fronzbot <https://github.com/fronzbot/blinkpy/pull/61>`__)
0.7.0 (2018-02-08)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
- Fixed style errors for bumped pydocstring and pylint versions
- Changed Blink.cameras dictionary to be case-insensitive (fixes `#35 <https://github.com/fronzbot/blinkpy/issues/35>`_)
- Changed api endpoint for video extraction (fixes `#35 <https://github.com/fronzbot/blinkpy/issues/35>`_ and `#41 <https://github.com/fronzbot/blinkpy/issues/41>`_)
- Changed Blink.cameras dictionary to be case-insensitive (fixes `#35 <https://github.com/fronzbot/blinkpy/issues/35>`__)
- Changed api endpoint for video extraction (fixes `#35 <https://github.com/fronzbot/blinkpy/issues/35>`__ and `#41 <https://github.com/fronzbot/blinkpy/issues/41>`__)
- Removed last_motion() function from Blink class
- Refactored code for better organization
- Moved some request calls out of @property methods (enables future CLI support)
- Renamed get_summary() method to summary and changed to @property
- Added ability to download most recent video clip
- Improved camera arm/disarm handling (`@b10m <https://github.com/fronzbot/blinkpy/pull/50>`_)
- Improved camera arm/disarm handling (`@b10m <https://github.com/fronzbot/blinkpy/pull/50>`__)
- Added authentication to ``login()`` function and deprecated ``setup_system()`` in favor of ``start()``
- Added ``attributes`` dictionary to camera object
@@ -83,7 +91,7 @@ A list of changes between each release
- Removed redundent properties that only called hidden variables
- Revised request wrapper function to be more intelligent
- Added tests to ensure exceptions are caught and handled (100% coverage!)
- Added auto-reauthorization (token refresh) when a request fails due to an expired token (`@tySwift93 <https://github.com/fronzbot/blinkpy/pull/24>`_)
- Added auto-reauthorization (token refresh) when a request fails due to an expired token (`@tySwift93 <https://github.com/fronzbot/blinkpy/pull/24>`__)
- Added battery level string to reduce confusion with the way Blink reports battery level as integer from 0 to 3
0.5.2 (2017-03-12)
+12 -4
View File
@@ -25,11 +25,17 @@ def request_login(blink, url, username, password):
def request_networks(blink):
"""Request network information."""
"""Request all networks information."""
url = "{}/networks".format(blink.urls.base_url)
return http_get(blink, url)
def request_network_status(blink, network):
"""Request network information."""
url = "{}/network/{}".format(blink.urls.base_url, network)
return http_get(blink, url)
def request_syncmodule(blink, network):
"""Request sync module info."""
url = "{}/network/{}/syncmodules".format(blink.urls.base_url, network)
@@ -50,9 +56,9 @@ def request_system_disarm(blink, network):
def request_command_status(blink, network, command_id):
"""Request command status."""
url = "{}/network/{}/command_id/{}".format(blink.urls.base_url,
network,
command_id)
url = "{}/network/{}/command/{}".format(blink.urls.base_url,
network,
command_id)
return http_get(blink, url)
@@ -144,6 +150,7 @@ def http_get(blink, url, stream=False, json=True):
"""
if blink.auth_header is None:
raise BlinkException(ERROR.AUTH_TOKEN)
_LOGGER.debug("Making GET request to %s", url)
return http_req(blink, url=url, headers=blink.auth_header,
reqtype='get', stream=stream, json_resp=json)
@@ -156,4 +163,5 @@ def http_post(blink, url):
"""
if blink.auth_header is None:
raise BlinkException(ERROR.AUTH_TOKEN)
_LOGGER.debug("Making POST request to %s", url)
return http_req(blink, url=url, headers=blink.auth_header, reqtype='post')
+1 -1
View File
@@ -4,7 +4,7 @@ import os
MAJOR_VERSION = 0
MINOR_VERSION = 10
PATCH_VERSION = 2
PATCH_VERSION = 3
__version__ = '{}.{}.{}'.format(MAJOR_VERSION, MINOR_VERSION, PATCH_VERSION)
+5 -5
View File
@@ -2,7 +2,7 @@
import logging
from requests import Request, Session, exceptions
from blinkpy.helpers.constants import BLINK_URL, PROJECT_URL
from blinkpy.helpers.constants import BLINK_URL
import blinkpy.helpers.errors as ERROR
@@ -50,8 +50,7 @@ def http_req(blink, url='http://example.com', data=None, headers=None,
response = blink.session.send(prepped, stream=stream)
if json_resp and 'code' in response.json():
if is_retry:
_LOGGER.error(("Cannot obtain new token for server auth. "
"Please report this issue on %s"), PROJECT_URL)
_LOGGER.error("Cannot obtain new token for server auth.")
return None
else:
headers = attempt_reauthorization(blink)
@@ -59,13 +58,14 @@ def http_req(blink, url='http://example.com', data=None, headers=None,
reqtype=reqtype, stream=stream,
json_resp=json_resp, is_retry=True)
except (exceptions.ConnectionError, exceptions.Timeout):
_LOGGER.error("Cannot connect to server with url %s.", url)
_LOGGER.info("Cannot connect to server with url %s.", url)
if not is_retry:
headers = attempt_reauthorization(blink)
return http_req(blink, url=url, data=data, headers=headers,
reqtype=reqtype, stream=stream,
json_resp=json_resp, is_retry=True)
_LOGGER.error("Possible issue with Blink servers.")
_LOGGER.error("Endpoint %s failed. Possible issue with Blink servers.",
url)
return None
if json_resp:
+11 -4
View File
@@ -31,6 +31,7 @@ class BlinkSyncModule():
self.host = None
self.summary = None
self.homescreen = None
self.network_info = None
self.record_dates = {}
self.videos = {}
self.events = []
@@ -64,7 +65,7 @@ class BlinkSyncModule():
@property
def arm(self):
"""Return status of sync module: armed/disarmed."""
return self.homescreen['network']['armed']
return self.network_info['network']['armed']
@arm.setter
def arm(self, value):
@@ -88,6 +89,9 @@ class BlinkSyncModule():
self.homescreen = api.request_homescreen(self.blink)
self.network_info = api.request_network_status(self.blink,
self.network_id)
camera_info = self.get_camera_info()
for camera_config in camera_info:
name = camera_config['name']
@@ -114,6 +118,8 @@ class BlinkSyncModule():
self.events = self.get_events()
self.videos = self.get_videos()
self.homescreen = api.request_homescreen(self.blink)
self.network_info = api.request_network_status(self.blink,
self.network_id)
camera_info = self.get_camera_info()
for camera_config in camera_info:
name = camera_config['name']
@@ -135,9 +141,10 @@ class BlinkSyncModule():
if not this_page:
break
videos.append(this_page)
_LOGGER.debug("Getting videos from page %s through %s",
start_page,
end_page)
for page in videos:
_LOGGER.debug("Retrieved video page %s", page)
for entry in page:
camera_name = entry['camera_name']
clip_addr = entry['address']
@@ -168,5 +175,5 @@ class BlinkSyncModule():
}
]
self.record_dates = all_dates
_LOGGER.debug("Retrieved a total of %s records", len(all_dates))
return self.videos
+5 -4
View File
@@ -25,13 +25,14 @@ class TestBlinkAPI(unittest.TestCase):
def test_http_req_connect_error(self, mock_auth):
"""Test http_get error condition."""
mock_auth.return_value = {'foo': 'bar'}
firstlog = ("ERROR:blinkpy.helpers.util:"
"Cannot connect to server with url {}").format(
'http://notreal.fake.')
firstlog = ("INFO:blinkpy.helpers.util:"
"Cannot connect to server with url {}.").format(
'http://notreal.fake')
nextlog = ("INFO:blinkpy.helpers.util:"
"Auth token expired, attempting reauthorization.")
lastlog = ("ERROR:blinkpy.helpers.util:"
"Possible issue with Blink servers.")
"Endpoint {} failed. Possible issue with "
"Blink servers.").format('http://notreal.fake')
expected = [firstlog, nextlog, firstlog, lastlog]
with self.assertLogs() as getlog:
api.http_get(self.blink, 'http://notreal.fake')
+1 -3
View File
@@ -14,7 +14,6 @@ from blinkpy.sync_module import BlinkSyncModule
from blinkpy.helpers.util import (
http_req, create_session, BlinkAuthenticationException,
BlinkException, BlinkURLHandler)
from blinkpy.helpers.constants import PROJECT_URL
import tests.mock_responses as mresp
USERNAME = 'foobar'
@@ -79,8 +78,7 @@ class TestBlinkSetup(unittest.TestCase):
"""Check that we raise an Exception with a bad request."""
self.blink.session = create_session()
explog = ("ERROR:blinkpy.helpers.util:"
"Cannot obtain new token for server auth. "
"Please report this issue on {}").format(PROJECT_URL)
"Cannot obtain new token for server auth.")
with self.assertRaises(BlinkException):
http_req(self.blink, reqtype='bad')
+1
View File
@@ -88,6 +88,7 @@ class TestBlinkSyncModule(unittest.TestCase):
'status': 'foobar'}},
{'event': True},
{},
{},
{'devicestatus': {}},
None,
None