send clip_ready mqtt to event topic

This commit is contained in:
Blake Blackshear 2021-06-14 18:16:41 -05:00
parent 40bf7a0f41
commit 3b695040d1
3 changed files with 13 additions and 3 deletions

View File

@ -32,7 +32,7 @@ Message published for each changed event. The first message is published when th
```json ```json
{ {
"type": "update", // new, update, or end "type": "update", // new, update, end or clip_ready
"before": { "before": {
"id": "1607123955.475377-mxklsc", "id": "1607123955.475377-mxklsc",
"camera": "front_door", "camera": "front_door",

View File

@ -268,7 +268,7 @@ class EventProcessor(threading.Thread):
has_snapshot=event_data["has_snapshot"], has_snapshot=event_data["has_snapshot"],
) )
del self.events_in_process[event_data["id"]] del self.events_in_process[event_data["id"]]
self.event_processed_queue.put((event_data["id"], camera)) self.event_processed_queue.put((event_data["id"], camera, clip_created))
logger.info(f"Exiting event processor...") logger.info(f"Exiting event processor...")

View File

@ -767,7 +767,17 @@ class TrackedObjectProcessor(threading.Thread):
# cleanup event finished queue # cleanup event finished queue
while not self.event_processed_queue.empty(): while not self.event_processed_queue.empty():
event_id, camera = self.event_processed_queue.get() event_id, camera, clip_created = self.event_processed_queue.get()
if clip_created:
obj = self.camera_states[camera].tracked_objects[event_id]
message = {
"before": obj.previous,
"after": obj.to_dict(),
"type": "clip_ready",
}
self.client.publish(
f"{self.topic_prefix}/events", json.dumps(message), retain=False
)
self.camera_states[camera].finished(event_id) self.camera_states[camera].finished(event_id)
logger.info(f"Exiting object processor...") logger.info(f"Exiting object processor...")