forked from Github/frigate
Add support for stationary and active timeline entires (#7344)
* Add support for stationary and active timeline entires * Be sure to update stored event data copy with stationary
This commit is contained in:
@@ -37,6 +37,14 @@ def should_update_db(prev_event: Event, current_event: Event) -> bool:
|
||||
return False
|
||||
|
||||
|
||||
def should_update_state(prev_event: Event, current_event: Event) -> bool:
|
||||
"""If current event should update state, but not necessarily update the db."""
|
||||
if prev_event["stationary"] != current_event["stationary"]:
|
||||
return True
|
||||
|
||||
return False
|
||||
|
||||
|
||||
class EventProcessor(threading.Thread):
|
||||
def __init__(
|
||||
self,
|
||||
@@ -107,8 +115,11 @@ class EventProcessor(threading.Thread):
|
||||
event_data: Event,
|
||||
) -> None:
|
||||
"""handle tracked object event updates."""
|
||||
updated_db = False
|
||||
|
||||
# if this is the first message, just store it and continue, its not time to insert it in the db
|
||||
if should_update_db(self.events_in_process[event_data["id"]], event_data):
|
||||
updated_db = True
|
||||
camera_config = self.config.cameras[camera]
|
||||
event_config: EventsConfig = camera_config.record.events
|
||||
width = camera_config.detect.width
|
||||
@@ -210,6 +221,10 @@ class EventProcessor(threading.Thread):
|
||||
.execute()
|
||||
)
|
||||
|
||||
# check if the stored event_data should be updated
|
||||
if updated_db or should_update_state(
|
||||
self.events_in_process[event_data["id"]], event_data
|
||||
):
|
||||
# update the stored copy for comparison on future update messages
|
||||
self.events_in_process[event_data["id"]] = event_data
|
||||
|
||||
|
||||
Reference in New Issue
Block a user