ทำไม Smart Perimeter Defense ถึงสำคัญ
ระบบกล้องวงจรปิดทั่วไปบันทึกเหตุการณ์ได้ แต่ไม่ได้ป้องกันเชิงรุก การผสาน Frigate NVR กับ Home Assistant ทำให้บ้านสามารถ ตอบสนองทันที เมื่อตรวจจับคนในโซนที่กำหนด — ทำให้ผู้บุกรุกรู้ว่าถูกสังเกตเห็น และแจ้งเจ้าของบ้านพร้อมกัน
สถาปัตยกรรม Zone-Based Perimeter
โซน 1 (ประตูรั้ว) → ไฟกะพริบ 3 ครั้ง + บันทึกกล้อง โซน 2 (ทางรถ) → ไฟ Flood สว่าง 100% + LINE แจ้งเตือน โซน 3 (ระเบียง) → ไซเรน + PTZ pan + push notification
แต่ละโซนกำหนดใน Frigate เป็น polygon บน frame ของกล้อง และ Home Assistant automation ทำงานแตกต่างกันตาม zone_id ที่ Frigate ส่งมา
ตั้งค่า Frigate config.yml สำหรับ Zone Detection
yaml cameras: front_gate: ffmpeg: inputs: - path: rtsp://192.168.1.201:554/stream1 roles: [detect, record] detect: width: 1920 height: 1080 fps: 5 zones: gate_zone: coordinates: 100,300,500,300,500,800,100,800 objects: - person driveway_zone: coordinates: 500,200,1400,200,1400,900,500,900 objects: - person record: enabled: true events: retain: default: 10 snapshots: enabled: true bounding_box: true
Home Assistant Automation: Zone Entry Sequence
yaml alias: Perimeter Defense — Gate Zone Person trigger: - platform: mqtt topic: frigate/events value_template: >- {{ value_json.after.camera == 'front_gate' and 'gate_zone' in value_json.after.current_zones and value_json.after.label == 'person' }} payload: 'true' condition: - condition: time after: "18:00:00" before: "06:00:00" action: - service: light.turn_on target: entity_id: light.gate_flood data: brightness_pct: 100 flash: short - delay: "00:00:02" - service: light.turn_on data: brightness_pct: 100 flash: short target: entity_id: light.gate_flood - service: notify.line_notify data: message: >- ⚠️ ตรวจพบคนที่ประตูรั้ว {{ now().strftime('%H:%M') }} ภาพ: http://frigate.local/api/events/{{ trigger.payload_json.after.id }}/snapshot.jpg mode: single
yaml alias: Perimeter Defense — Driveway Person trigger: - platform: mqtt topic: frigate/events value_template: >- {{ value_json.after.camera == 'front_gate' and 'driveway_zone' in value_json.after.current_zones and value_json.after.label == 'person' and value_json.after.id != value_json.before.id }} payload: 'true' action: - service: light.turn_on target: entity_id: - light.driveway_left - light.driveway_right data: brightness_pct: 100 color_temp: 153 - service: siren.turn_on target: entity_id: siren.outdoor_horn data: duration: 5 - service: camera.turn_on target: entity_id: camera.porch_ptz - service: onvif.ptz target: entity_id: camera.porch_ptz data: move_mode: GotoPreset preset: "1" mode: queued max: 3
PTZ Camera Integration ผ่าน ONVIF
กล้อง PTZ ที่รองรับ ONVIF (Hikvision, Dahua, Reolink) สามารถสั่ง pan/tilt/zoom ผ่าน Home Assistant:
yaml # configuration.yaml camera: - platform: onvif host: 192.168.1.202 username: admin password: !secret ptz_password name: Porch PTZ extra_arguments: -q:v 2
Preset ของกล้อง (Pan ไปทิศทางประตู, ทางเดิน ฯลฯ) ตั้งค่าผ่านหน้าเว็บกล้อง แล้วเรียกใช้ใน automation ด้วย ถึง
ตาราง Zone vs. การตอบสนอง
| โซน | เวลากลางวัน | เวลากลางคืน | การแจ้งเตือน | |---|---|---|---| | ประตูรั้ว | บันทึก + snapshot | ไฟกะพริบ + LINE | ทุกครั้ง | | ทางรถ | LINE photo | Flood + ไซเรน 5s | ทุกครั้ง | | ระเบียง | Push + snapshot | PTZ + ไซเรน 10s + Strobe | ทุกครั้ง |
ป้องกัน False Positive
Frigate ใช้ object tracking ทำให้ event เดียวไม่ trigger ซ้ำ แต่ควรเพิ่ม หรือ cooldown timer เพื่อป้องกันสัตว์เลี้ยงหรือรถที่ผ่าน:
yaml condition: - condition: template value_template: >- {{ (now() - states.automation.perimeter_driveway.last_triggered).seconds > 60 if states.automation.perimeter_driveway.last_triggered else true }}
สรุป ROI
ระบบ Smart Perimeter Defense ที่ใช้ Frigate + HA ช่วยลดเวลาตอบสนองต่อการบุกรุกจาก ~3 นาที (ดูกล้องย้อนหลัง) เหลือ ทันที และต้นทุนอุปกรณ์ต่ำกว่าระบบ CCTV commercial 60–80%