mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-02-03 01:35:22 +03:00
Make sure multiple True values aren't published for the same motion
This commit is contained in:
parent
ff5a0aed78
commit
4d81a08597
@ -848,11 +848,15 @@ class TrackedObjectProcessor(threading.Thread):
|
|||||||
def should_mqtt_motion(self, camera, motion_boxes):
|
def should_mqtt_motion(self, camera, motion_boxes):
|
||||||
# publish if motion is currently being detected
|
# publish if motion is currently being detected
|
||||||
if motion_boxes:
|
if motion_boxes:
|
||||||
self.client.publish(
|
# only send True if motion hasn't been detected recently
|
||||||
f"{self.topic_prefix}/{camera}/motion/detected",
|
if self.last_motion_updates[camera] == 0:
|
||||||
True,
|
self.client.publish(
|
||||||
retain=False,
|
f"{self.topic_prefix}/{camera}/motion/detected",
|
||||||
)
|
True,
|
||||||
|
retain=False,
|
||||||
|
)
|
||||||
|
|
||||||
|
# always updated latest motion
|
||||||
self.last_motion_updates[camera] = int(time.time())
|
self.last_motion_updates[camera] = int(time.time())
|
||||||
elif not motion_boxes and self.last_motion_updates.get(camera, 0) != 0:
|
elif not motion_boxes and self.last_motion_updates.get(camera, 0) != 0:
|
||||||
mqtt_delay = self.config.cameras[camera].motion.mqtt_off_delay
|
mqtt_delay = self.config.cameras[camera].motion.mqtt_off_delay
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user