Fix saving attributes for object to DB (#22000)

This commit is contained in:
Nicolas Mowen
2026-02-14 07:40:08 -06:00
committed by GitHub
parent 5f93cee732
commit 73c1e12faf
3 changed files with 32 additions and 2 deletions
+9 -1
View File
@@ -376,7 +376,10 @@ class TrackedObject:
)
return (thumb_update, significant_change, path_update, autotracker_update)
def to_dict(self) -> dict[str, Any]:
def to_dict(
self,
attribute_model_names: list[str] | None = None,
) -> dict[str, Any]:
event = {
"id": self.obj_data["id"],
"camera": self.camera_config.name,
@@ -411,6 +414,11 @@ class TrackedObject:
"path_data": self.path_data.copy(),
"recognized_license_plate": self.obj_data.get("recognized_license_plate"),
}
if attribute_model_names is not None:
for name in attribute_model_names:
value = self.obj_data.get(name)
if value is not None:
event[name] = value
return event