Skip to content
This repository has been archived by the owner on Dec 4, 2020. It is now read-only.

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
gieljnssns authored and Hugo Dupras committed Jul 17, 2018
1 parent ed74596 commit 98ffa3e
Showing 1 changed file with 15 additions and 14 deletions.
29 changes: 15 additions & 14 deletions smart_home/Camera.py
Expand Up @@ -47,18 +47,19 @@ def __init__(self, authData, size=15):
self.types[nameHome] = dict()
for p in self.rawData['homes'][i]['persons']:
self.persons[p['id']] = p
for e in self.rawData['homes'][i]['events']:
if e['type'] == 'outdoor':
if e['camera_id'] not in self.outdoor_events:
self.outdoor_events[e['camera_id']] = dict()
self.outdoor_events[e['camera_id']][e['time']] = e
elif e['type'] != 'outdoor':
if e['camera_id'] not in self.events:
self.events[e['camera_id']] = dict()
self.events[e['camera_id']][e['time']] = e
if 'events' in self.rawData['homes'][i]:
for e in self.rawData['homes'][i]['events']:
if e['type'] == 'outdoor':
if e['camera_id'] not in self.outdoor_events:
self.outdoor_events[e['camera_id']] = dict()
self.outdoor_events[e['camera_id']][e['time']] = e
elif e['type'] != 'outdoor':
if e['camera_id'] not in self.events:
self.events[e['camera_id']] = dict()
self.events[e['camera_id']][e['time']] = e
for c in self.rawData['homes'][i]['cameras']:
self.cameras[nameHome][c['id']] = c
if c['type'] == 'NACamera' and 'modules' in c :
if c['type'] == 'NACamera' and 'modules' in c:
for m in c['modules']:
self.modules[m['id']] = m
self.modules[m['id']]['cam_id'] = c['id']
Expand Down Expand Up @@ -300,7 +301,7 @@ def _knownPersons(self):

def knownPersonsNames(self):
names = []
for p_id,p in self._knownPersons().items():
for p_id, p in self._knownPersons().items():
names.append(p['pseudo'])
return names

Expand Down Expand Up @@ -474,7 +475,7 @@ def moduleMotionDetected(self, module=None, home=None,
return True
elif (self.lastEvent[cam_id]['type'] == 'tag_big_move' or
self.lastEvent[cam_id]['type'] == 'tag_small_move') and\
self.lastEvent[cam_id]['module_id'] == mod_id:
self.lastEvent[cam_id]['module_id'] == mod_id:
return True
return False

Expand All @@ -498,9 +499,9 @@ def moduleOpened(self, module=None, home=None, camera=None, exclude=0):
if time_ev < limit:
return False
elif self.events[cam_id][time_ev]['type'] == 'tag_open' and\
self.events[cam_id][time_ev]['module_id'] == mod_id:
self.events[cam_id][time_ev]['module_id'] == mod_id:
return True
elif self.lastEvent[cam_id]['type'] == 'tag_open' and\
self.lastEvent[cam_id]['module_id'] == mod_id:
self.lastEvent[cam_id]['module_id'] == mod_id:
return True
return False

0 comments on commit 98ffa3e

Please sign in to comment.