add enum and change topic name

This commit is contained in:
Josh Hawkins 2024-11-18 12:13:36 -06:00
parent 5b1b6b5be0
commit 36391c844e
3 changed files with 28 additions and 4 deletions

View File

@ -22,7 +22,7 @@ from frigate.const import (
)
from frigate.models import Event, Previews, Recordings, ReviewSegment
from frigate.ptz.onvif import OnvifCommandEnum, OnvifController
from frigate.types import ModelStatusTypesEnum
from frigate.types import ModelStatusTypesEnum, TrackedObjectUpdateTypesEnum
from frigate.util.object import get_camera_regions_grid
from frigate.util.services import restart_frigate
@ -136,9 +136,24 @@ class Dispatcher:
event: Event = Event.get(Event.id == payload["id"])
event.data["description"] = payload["description"]
event.save()
print(
json.dumps(
{
"type": TrackedObjectUpdateTypesEnum.description,
"id": event.id,
"description": event.data["description"],
}
)
)
self.publish(
"event_update",
json.dumps({"id": event.id, "description": event.data["description"]}),
"tracked_object_update",
json.dumps(
{
"type": TrackedObjectUpdateTypesEnum.description,
"id": event.id,
"description": event.data["description"],
}
),
)
def handle_update_model_state():

View File

@ -24,6 +24,7 @@ from frigate.const import CLIPS_DIR, UPDATE_EVENT_DESCRIPTION
from frigate.events.types import EventTypeEnum
from frigate.genai import get_genai_client
from frigate.models import Event
from frigate.types import TrackedObjectUpdateTypesEnum
from frigate.util.builtin import serialize
from frigate.util.image import SharedMemoryFrameManager, calculate_region
@ -287,7 +288,11 @@ class EmbeddingMaintainer(threading.Thread):
# fire and forget description update
self.requestor.send_data(
UPDATE_EVENT_DESCRIPTION,
{"id": event.id, "description": description},
{
"type": TrackedObjectUpdateTypesEnum.description,
"id": event.id,
"description": description,
},
)
# Embed the description

View File

@ -19,3 +19,7 @@ class ModelStatusTypesEnum(str, Enum):
downloading = "downloading"
downloaded = "downloaded"
error = "error"
class TrackedObjectUpdateTypesEnum(str, Enum):
description = "description"