Files
zenai-apc-ngoro/docs/RECOUNTING_CONNECT.md
2026-10-21 10:01:25 +07:00

4.2 KiB
Raw Permalink Blame History

Recounting — Device Connection Checklist (Phase 0)

Topology (ZeroTier 192.168.192.0/24)

Role Host Endpoints
NanoPi 1 (dashboard + live counter) 192.168.192.208 Dashboard :5000
MotionEye 192.168.192.251 UI :8081, ingest :8090
NanoPi 2 (recount engine) 192.168.192.16 Recount API :8765

Checklist

  1. From NanoPi 1: ping -c1 192.168.192.251 and ping -c1 192.168.192.16
  2. Open MotionEye UI: http://192.168.192.251:8081 — set MOTIONEYE_USER / MOTIONEYE_PASSWORD in .env if needed
  3. SSH to MotionEye as support (not root): ssh support@192.168.192.251
  4. Locate media dir (e.g. /data/media/Camera1). Set MOTIONEYE_MEDIA_DIR, MOTIONEYE_CAMERA_ID=1, MOTIONEYE_SSH_USER=support
  5. Authorize NanoPi 1 key for support on ME (/home/support/.ssh/authorized_keys) and for NP2
  6. Deploy ingest: bash scripts/deploy-motioneye-ingest.sh
  7. Deploy recount: bash scripts/deploy-recount-to-nanopi2.sh
  8. Manual test file name: batch_YYYY-MM-DD-N.mp4 in media dir (or upload via ingest)
  9. Set on NanoPi 1 .env: RECOUNT_STUB=false, corrected URLs below

Required .env keys (NanoPi 1)

NANOPI2_URL=http://192.168.192.16:8765
MOTIONEYE_URL=http://192.168.192.251:8081
MOTIONEYE_INGEST_URL=http://192.168.192.251:8090
MOTIONEYE_INGEST_TOKEN=<shared-secret>
MOTIONEYE_MEDIA_DIR=/data/media/Camera1
MOTIONEYE_CAMERA_ID=1
MOTIONEYE_USER=support
MOTIONEYE_SSH_USER=support
BATCH_RECORD_ENABLED=true
BATCH_RECORD_FPS=0
BATCH_RECORD_QUEUE=120
RECOUNT_STUB=false

Status notes (this host)

  • MotionEye :8081 HTTP responds (200).
  • MotionEye SSH user is support (default in deploy script).
  • SSH to ME/NP2 with nanopi_agent key was not authorized at implementation time.
  • Local ingest smoke-tested on NanoPi 1 at :8090 writing to /opt/apc-ngoro/motioneye_media/ (temporary until ME deploy).
  • Dashboard RECOUNT_STUB=false proxies to NanoPi 2; until recount is deployed, status shows connection refused (expected).

Current status (post-deploy)

  • MotionEye ingest: OK (http://192.168.192.251:8090/health)
  • NanoPi 2 recount service: running, but first E2E failed with missing model file
  • Fix model then retest:
# Option A — copy model only
bash /opt/apc-ngoro/scripts/copy-model-to-nanopi2.sh

# Option B — redeploy recount (now bundles the .rknn)
bash /opt/apc-ngoro/scripts/deploy-recount-to-nanopi2.sh

# Remove deprecated MotionEye-side calendar cleanup, then install new retention cron
bash /opt/apc-ngoro/scripts/deploy-motioneye-cleanup-cron.sh
bash /opt/apc-ngoro/scripts/deploy-retention-cron.sh
# Verify local active-day cron
cat /etc/cron.d/apc-retention
# Dry-run active-day cleanup from NP1
/opt/apc-ngoro/venv/bin/python /opt/apc-ngoro/scripts/retention_active_days.py --dry-run
# Dry-run overlay cleanup on NP2
ssh root@192.168.192.16 'cd /opt/apc-ngoro && /opt/apc-ngoro/venv/bin/python scripts/recount_overlay_cleanup.py --dry-run'

# Retest recount (batch 2026-09-09-19 already has video on ME)
curl -X POST http://127.0.0.1:5000/api/v1/recount/start \
  -H 'Content-Type: application/json' \
  -d '{"batch_id":"2026-09-09-19"}'
curl -sS http://127.0.0.1:5000/api/v1/recount/status

Next actions for you

  1. Append ~/.ssh/nanopi_agent.pub to support’s authorized_keys on MotionEye (/home/support/.ssh/authorized_keys) and to NanoPi 2.
  2. On MotionEye, set real MOTIONEYE_MEDIA_DIR, then run: bash /opt/apc-ngoro/scripts/deploy-motioneye-ingest.sh
  3. On NanoPi 2 (after copying RKNN model to /opt/models/...), run: bash /opt/apc-ngoro/scripts/deploy-recount-to-nanopi2.sh
  4. Remove deprecated MotionEye cron with scripts/deploy-motioneye-cleanup-cron.sh, then install the new retention automation with scripts/deploy-retention-cron.sh. Batch files now keep only the last 3 active counting dates (ACTIVE_RETENTION_DAYS=3), while NP2 overlay outputs are deleted after 6 hours (RECOUNT_OVERLAY_TTL_HOURS=6).
  5. Place today’s test file as batch_YYYY-MM-DD-N.mp4 (or upload via ingest) and set that batch’s video_url in DB / via live recording.
  6. Restart counter after .env changes: systemctl restart apc-ngoro-counter