add backend trigger actions

This commit is contained in:
Josh Hawkins 2025-10-28 14:36:25 -05:00
parent 6ccf8cd2b8
commit c6f21527c1
2 changed files with 39 additions and 2 deletions

View File

@ -10,6 +10,10 @@ import cv2
import numpy as np import numpy as np
from peewee import DoesNotExist from peewee import DoesNotExist
from frigate.comms.event_metadata_updater import (
EventMetadataPublisher,
EventMetadataTypeEnum,
)
from frigate.comms.inter_process import InterProcessRequestor from frigate.comms.inter_process import InterProcessRequestor
from frigate.config import FrigateConfig from frigate.config import FrigateConfig
from frigate.const import CONFIG_DIR from frigate.const import CONFIG_DIR
@ -34,6 +38,7 @@ class SemanticTriggerProcessor(PostProcessorApi):
db: SqliteVecQueueDatabase, db: SqliteVecQueueDatabase,
config: FrigateConfig, config: FrigateConfig,
requestor: InterProcessRequestor, requestor: InterProcessRequestor,
sub_label_publisher: EventMetadataPublisher,
metrics: DataProcessorMetrics, metrics: DataProcessorMetrics,
embeddings, embeddings,
): ):
@ -41,6 +46,7 @@ class SemanticTriggerProcessor(PostProcessorApi):
self.db = db self.db = db
self.embeddings = embeddings self.embeddings = embeddings
self.requestor = requestor self.requestor = requestor
self.sub_label_publisher = sub_label_publisher
self.trigger_embeddings: list[np.ndarray] = [] self.trigger_embeddings: list[np.ndarray] = []
self.thumb_stats = ZScoreNormalization() self.thumb_stats = ZScoreNormalization()
@ -184,14 +190,44 @@ class SemanticTriggerProcessor(PostProcessorApi):
), ),
) )
friendly_name = (
self.config.cameras[camera]
.semantic_search.triggers[trigger["name"]]
.friendly_name
)
if ( if (
self.config.cameras[camera] self.config.cameras[camera]
.semantic_search.triggers[trigger["name"]] .semantic_search.triggers[trigger["name"]]
.actions .actions
): ):
# TODO: handle actions for the trigger # handle actions for the trigger
# notifications already handled by webpush # notifications already handled by webpush
pass if (
"sub_label"
in self.config.cameras[camera]
.semantic_search.triggers[trigger["name"]]
.actions
):
self.sub_label_publisher.publish(
(event_id, friendly_name, similarity),
EventMetadataTypeEnum.sub_label,
)
if (
"attribute"
in self.config.cameras[camera]
.semantic_search.triggers[trigger["name"]]
.actions
):
self.sub_label_publisher.publish(
(
event_id,
trigger["name"],
trigger["type"],
similarity,
),
EventMetadataTypeEnum.attribute.value,
)
if WRITE_DEBUG_IMAGES: if WRITE_DEBUG_IMAGES:
try: try:

View File

@ -233,6 +233,7 @@ class EmbeddingMaintainer(threading.Thread):
db, db,
self.config, self.config,
self.requestor, self.requestor,
self.event_metadata_publisher,
metrics, metrics,
self.embeddings, self.embeddings,
) )