def post(self):
event = self.get_argument('event')
thread_id = int(self.get_argument('thread_id'))
- logging.debug('recevied relayed event %(event)s for thread id %(id)s' % {'event': event, 'id': thread_id})
-
+
camera_id = motionctl.thread_id_to_camera_id(thread_id)
if camera_id is None:
logging.debug('ignoring event for unknown thread id %s' % thread_id)
return self.finish_json()
+
+ else:
+ logging.debug('recevied relayed event %(event)s for thread id %(id)s (camera id %(cid)s)' % {
+ 'event': event, 'id': thread_id, 'cid': camera_id})
camera_config = config.get_camera(camera_id)
if not utils.local_motion_camera(camera_config):
def thread_id_to_camera_id(thread_id):
- # find the corresponding camera_id
- # (which can be different from thread_id)
- camera_ids = config.get_camera_ids()
- tid = 0
- for cid in camera_ids:
- camera_config = config.get_camera(cid)
- if utils.local_motion_camera(camera_config):
- tid += 1
- if tid == thread_id:
- return cid
-
- return None
+ main_config = config.get_main()
+ threads = main_config.get('thread', '')
+
+ return int(re.search('thread-(\d+).conf', threads[thread_id - 1]).group(1))
def _disable_initial_motion_detection():