Differentiate PET_ESCAPE and UNKNOWN_ANIMAL events by zone and identity

Replace the flat pet/detected handler with context-aware classification:
unknown animals (no pet_id) → UNKNOWN_ANIMAL/WARNING, known pets in
exterior/transition zones → PET_ESCAPE/ALERT, known pets indoors →
PET_DETECTED/INFO. Adds four new unit tests covering all three paths.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Aaron D. Lee
2026-04-03 13:45:15 -04:00
parent 713d16d445
commit c77f732ac7
2 changed files with 58 additions and 1 deletions

View File

@@ -129,6 +129,15 @@ class EventProcessor:
# Pet detection
if suffix == "pet/detected":
pet_id = payload.get("pet_id")
camera_location = payload.get("camera_location", "INTERIOR")
if not pet_id:
return EventType.UNKNOWN_ANIMAL, Severity.WARNING, camera_id
if camera_location in ("EXTERIOR", "TRANSITION"):
return EventType.PET_ESCAPE, Severity.ALERT, camera_id
return EventType.PET_DETECTED, Severity.INFO, camera_id
# Wildlife detection — severity depends on threat_level in payload