Remove topic prefix (#4515)

This commit is contained in:
Nicolas Mowen 2022-11-25 19:10:09 -07:00 committed by GitHub
parent 4e5512e35d
commit 91982c4f7e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 19 deletions

View File

@ -218,7 +218,6 @@ class FrigateApp:
self.detected_frames_processor = TrackedObjectProcessor( self.detected_frames_processor = TrackedObjectProcessor(
self.config, self.config,
self.dispatcher, self.dispatcher,
self.config.mqtt.topic_prefix,
self.detected_frames_queue, self.detected_frames_queue,
self.event_queue, self.event_queue,
self.event_processed_queue, self.event_processed_queue,

View File

@ -634,7 +634,6 @@ class TrackedObjectProcessor(threading.Thread):
self, self,
config: FrigateConfig, config: FrigateConfig,
dispatcher: Dispatcher, dispatcher: Dispatcher,
topic_prefix,
tracked_objects_queue, tracked_objects_queue,
event_queue, event_queue,
event_processed_queue, event_processed_queue,
@ -646,7 +645,6 @@ class TrackedObjectProcessor(threading.Thread):
self.name = "detected_frames_processor" self.name = "detected_frames_processor"
self.config = config self.config = config
self.dispatcher = dispatcher self.dispatcher = dispatcher
self.topic_prefix = topic_prefix
self.tracked_objects_queue = tracked_objects_queue self.tracked_objects_queue = tracked_objects_queue
self.event_queue = event_queue self.event_queue = event_queue
self.event_processed_queue = event_processed_queue self.event_processed_queue = event_processed_queue
@ -669,9 +667,7 @@ class TrackedObjectProcessor(threading.Thread):
"after": after, "after": after,
"type": "new" if obj.previous["false_positive"] else "update", "type": "new" if obj.previous["false_positive"] else "update",
} }
self.dispatcher.publish( self.dispatcher.publish("events", json.dumps(message), retain=False)
f"{self.topic_prefix}/events", json.dumps(message), retain=False
)
obj.previous = after obj.previous = after
self.event_queue.put( self.event_queue.put(
("update", camera, obj.to_dict(include_thumbnail=True)) ("update", camera, obj.to_dict(include_thumbnail=True))
@ -724,9 +720,7 @@ class TrackedObjectProcessor(threading.Thread):
"after": obj.to_dict(), "after": obj.to_dict(),
"type": "end", "type": "end",
} }
self.dispatcher.publish( self.dispatcher.publish("/events", json.dumps(message), retain=False)
f"{self.topic_prefix}/events", json.dumps(message), retain=False
)
self.event_queue.put(("end", camera, obj.to_dict(include_thumbnail=True))) self.event_queue.put(("end", camera, obj.to_dict(include_thumbnail=True)))
@ -747,15 +741,13 @@ class TrackedObjectProcessor(threading.Thread):
) )
else: else:
self.dispatcher.publish( self.dispatcher.publish(
f"{self.topic_prefix}/{camera}/{obj.obj_data['label']}/snapshot", f"{camera}/{obj.obj_data['label']}/snapshot",
jpg_bytes, jpg_bytes,
retain=True, retain=True,
) )
def object_status(camera, object_name, status): def object_status(camera, object_name, status):
self.dispatcher.publish( self.dispatcher.publish(f"{camera}/{object_name}", status, retain=False)
f"{self.topic_prefix}/{camera}/{object_name}", status, retain=False
)
for camera in self.config.cameras.keys(): for camera in self.config.cameras.keys():
camera_state = CameraState(camera, self.config, self.frame_manager) camera_state = CameraState(camera, self.config, self.frame_manager)
@ -854,7 +846,7 @@ class TrackedObjectProcessor(threading.Thread):
# only send ON if motion isn't already active # only send ON if motion isn't already active
if self.last_motion_detected.get(camera, 0) == 0: if self.last_motion_detected.get(camera, 0) == 0:
self.dispatcher.publish( self.dispatcher.publish(
f"{self.topic_prefix}/{camera}/motion", f"{camera}/motion",
"ON", "ON",
retain=False, retain=False,
) )
@ -867,7 +859,7 @@ class TrackedObjectProcessor(threading.Thread):
# If no motion, make sure the off_delay has passed # If no motion, make sure the off_delay has passed
if frame_time - self.last_motion_detected.get(camera, 0) >= mqtt_delay: if frame_time - self.last_motion_detected.get(camera, 0) >= mqtt_delay:
self.dispatcher.publish( self.dispatcher.publish(
f"{self.topic_prefix}/{camera}/motion", f"{camera}/motion",
"OFF", "OFF",
retain=False, retain=False,
) )
@ -963,7 +955,7 @@ class TrackedObjectProcessor(threading.Thread):
new_count = sum(zone_label.values()) new_count = sum(zone_label.values())
if new_count != current_count: if new_count != current_count:
self.dispatcher.publish( self.dispatcher.publish(
f"{self.topic_prefix}/{zone}/{label}", f"{zone}/{label}",
new_count, new_count,
retain=False, retain=False,
) )
@ -976,7 +968,7 @@ class TrackedObjectProcessor(threading.Thread):
if label in obj_counter: if label in obj_counter:
zone_label[camera] = obj_counter[label] zone_label[camera] = obj_counter[label]
self.dispatcher.publish( self.dispatcher.publish(
f"{self.topic_prefix}/{zone}/{label}", f"{zone}/{label}",
obj_counter[label], obj_counter[label],
retain=False, retain=False,
) )
@ -993,7 +985,7 @@ class TrackedObjectProcessor(threading.Thread):
if new_count != current_count: if new_count != current_count:
self.dispatcher.publish( self.dispatcher.publish(
f"{self.topic_prefix}/{zone}/all", f"{zone}/all",
new_count, new_count,
retain=False, retain=False,
) )
@ -1001,7 +993,7 @@ class TrackedObjectProcessor(threading.Thread):
else: else:
zone_label[camera] = total_label_count zone_label[camera] = total_label_count
self.dispatcher.publish( self.dispatcher.publish(
f"{self.topic_prefix}/{zone}/all", f"{zone}/all",
total_label_count, total_label_count,
retain=False, retain=False,
) )