Files
labFusion/services/service-adapters/routes/frigate.py

64 lines
2.2 KiB
Python

from fastapi import APIRouter, HTTPException
from models.schemas import FrigateEventsResponse, FrigateEvent
from services.config import SERVICES
from datetime import datetime
router = APIRouter()
@router.get("/frigate/events",
response_model=FrigateEventsResponse,
summary="Get Frigate Events",
description="Retrieve detection events from Frigate NVR",
responses={
200: {"description": "Successfully retrieved events"},
503: {"description": "Frigate integration not configured"}
},
tags=["Frigate"])
async def get_frigate_events():
"""Get Frigate detection events including person, vehicle, and object detections"""
if not SERVICES["frigate"]["enabled"]:
raise HTTPException(
status_code=503,
detail="Frigate integration not configured. Please set FRIGATE_TOKEN environment variable."
)
# This would make actual API calls to Frigate
# For now, return mock data
return FrigateEventsResponse(
events=[
FrigateEvent(
id="event_123",
timestamp=datetime.now().isoformat(),
camera="front_door",
label="person",
confidence=0.95
)
]
)
@router.get("/frigate/cameras",
summary="Get Frigate Cameras",
description="Get list of Frigate cameras",
responses={
200: {"description": "Successfully retrieved cameras"},
503: {"description": "Frigate integration not configured"}
},
tags=["Frigate"])
async def get_frigate_cameras():
"""Get list of available Frigate cameras"""
if not SERVICES["frigate"]["enabled"]:
raise HTTPException(
status_code=503,
detail="Frigate integration not configured. Please set FRIGATE_TOKEN environment variable."
)
# This would make actual API calls to Frigate
# For now, return mock data
return {
"cameras": [
{"name": "front_door", "enabled": True},
{"name": "back_yard", "enabled": True},
{"name": "garage", "enabled": False}
]
}