From 7fa135317364eda2cdf29da729b41132553badc1 Mon Sep 17 00:00:00 2001 From: Kevin Fronczak Date: Wed, 8 Mar 2017 21:26:28 -0500 Subject: [PATCH] Working on updating constants --- blinkpy.py | 14 ++++---------- constants.py | 4 ++-- errors.py | 4 ++++ 3 files changed, 10 insertions(+), 12 deletions(-) create mode 100644 errors.py diff --git a/blinkpy.py b/blinkpy.py index f73aa21..f5b33b7 100644 --- a/blinkpy.py +++ b/blinkpy.py @@ -5,9 +5,7 @@ blinkpy by Kevin Fronczak - A Blink camera Python library https://github.com/fronzbot/blinkpy Original protocol hacking by MattTW : https://github.com/MattTW/BlinkMonitorProtocol - Published under the MIT license - See LICENSE file for more details. - "Blink Wire-Free HS Home Monitoring & Alert Systems" is a trademark owned by Immedia Inc., see www.blinkforhome.com for more information. I am in no way affiliated with Blink, nor Immedia Inc. ''' @@ -185,11 +183,7 @@ class BlinkCamera(object): self._NOTIFICATIONS = values['notifications'] def image_refresh(self): -<<<<<<< HEAD - url = HOME_URL -======= url = BASE_URL + '/homescreen' ->>>>>>> 8206a49dc76913b9f175bb473e17758fd2e26956 response = _request(url, headers=self._HEADER, type='get')['devices'] for element in response: try: @@ -262,7 +256,7 @@ class Blink(object): @property def events(self): """Gets all events on server""" - url = EVENT_URL + self._NETWORKID + url = BASE_URL + '/events/network/' + self._NETWORKID headers = self._AUTH_HEADER self._EVENTS = _request(url, headers=headers, type='get')['event'] return self._EVENTS @@ -270,10 +264,10 @@ class Blink(object): @property def online(self): """Returns True or False depending on if sync module is online/offline""" - url = NETWORK_URL + self._NETWORKID + '/syncmodules' + url = BASE_URL + 'network/' + self._NETWORKID + '/syncmodules' headers = self._AUTH_HEADER online_dict = {'online': True, 'offline': False} - return online_dict[_request(url, headers=headers, type='get')[KEY_SYNCMODULE]['status']] + return online_dict[_request(url, headers=headers, type='get')['syncmodule']['status']] def last_motion(self): """Finds last motion of each camera""" @@ -395,4 +389,4 @@ class Blink(object): response = _request(url, headers=headers, type='get') self._NETWORKID = str(response['networks'][0]['id']) - self._ACCOUNTID = str(response['networks'][0]['account_id']) + self._ACCOUNTID = str(response['networks'][0]['account_id']) \ No newline at end of file diff --git a/constants.py b/constants.py index bd79471..64e9daa 100644 --- a/constants.py +++ b/constants.py @@ -15,6 +15,6 @@ EVENT_URL = BASE_URL + '/events/network/' NETWORK_URL = BASE_URL + '/network/' ''' -DICT KEYS +Dictionaries ''' - +ONLINE = {'online': True, 'offline': False} \ No newline at end of file diff --git a/errors.py b/errors.py new file mode 100644 index 0000000..6d3fd36 --- /dev/null +++ b/errors.py @@ -0,0 +1,4 @@ +USERNAME = (0, "Username must be a string") +PASSWORD = (1, "Password must be a string") +AUTHENTICATE = (2, "Cannot authenticate since either password or username has not been set") + \ No newline at end of file