Changed motion check to look at sorted date list
- Previous method using clips resulted in an unsorted array, so the newest clip wasn't always added during check
This commit is contained in:
+11
-1
@@ -221,7 +221,8 @@ class BlinkCamera():
|
||||
# Check if the most recent clip is included in the last_record list
|
||||
# and that the last_record list is populated
|
||||
try:
|
||||
new_clip = self.blink.videos[self.name][0]['clip']
|
||||
records = sorted(self.blink.record_dates[self.name])
|
||||
new_clip = records.pop()
|
||||
if new_clip not in self.last_record and self.last_record:
|
||||
self.motion_detected = True
|
||||
self.last_record.insert(0, new_clip)
|
||||
@@ -293,6 +294,7 @@ class Blink():
|
||||
self._video_count = 0
|
||||
self._all_videos = {}
|
||||
self._summary = None
|
||||
self.record_dates = list()
|
||||
|
||||
@property
|
||||
def camera_thumbs(self):
|
||||
@@ -376,6 +378,7 @@ class Blink():
|
||||
def get_videos(self, start_page=0, end_page=1):
|
||||
"""Retrieve last recorded videos per camera."""
|
||||
videos = list()
|
||||
all_dates = dict()
|
||||
for page_num in range(start_page, end_page + 1):
|
||||
this_page = self._video_request(page_num)
|
||||
if not this_page:
|
||||
@@ -388,6 +391,12 @@ class Blink():
|
||||
camera_name = entry['camera_name']
|
||||
clip_addr = entry['address']
|
||||
thumb_addr = entry['thumbnail']
|
||||
clip_date = clip_addr.split('_')[-6:]
|
||||
clip_date = '_'.join(clip_date)
|
||||
clip_date = clip_date.split('.')[0]
|
||||
if camera_name not in all_dates:
|
||||
all_dates[camera_name] = list()
|
||||
all_dates[camera_name].append(clip_date)
|
||||
try:
|
||||
self._all_videos[camera_name].append(
|
||||
{
|
||||
@@ -402,6 +411,7 @@ class Blink():
|
||||
'thumb': thumb_addr,
|
||||
}
|
||||
]
|
||||
self.record_dates = all_dates
|
||||
|
||||
def get_cameras(self):
|
||||
"""Find and creates cameras."""
|
||||
|
||||
Reference in New Issue
Block a user