[功能] fam-edge 运动心跳支持 - /api/ss/motion 空 events 心跳刷新, has_motion_in_range_local 按 max_heartbeat_age_sec(900s) fail-open

This commit is contained in:
ericwyuan
2026-08-22 12:08:00 +08:00
parent 7adc32486a
commit 2d9d96de56
2 changed files with 13 additions and 8 deletions

View File

@@ -205,7 +205,10 @@ def ss_motion():
{"event_id": 25349, "camera_id": 2, "event_type": 10,
"start_time": 1787318023, "duration": 149, "thumbnail_url": "107471,12075"}
]}
start_time/duration 为 Unix epoch与 SS 同源,时区无关)。
start_time/duration 为 Unix epoch与 SS 同源,时区无关)。events 可以是空数组
——NAS 侧也会定期用空 events 单纯调一次这个接口当心跳,证明推送链路还活着
(鉴权通过就刷新心跳,不要求 stored>0供 has_motion_in_range_local() 判断
"无运动"结论是否可信。
落库 ss_motion_events按 event_id 幂等),供 video_processor 本地预过滤使用。
"""
if not _check_token():
@@ -218,6 +221,7 @@ def ss_motion():
return jsonify({"error": "events 必须是数组"}), 400
try:
stored = state.get_db().record_motion_events(events)
state.get_db().record_motion_heartbeat()
except Exception as e:
logger.error(f"ss_motion 落库异常: {e}")
return jsonify({"error": str(e)}), 500