From afb70f11a859e5fd62b72a0d3f5cffc4b4fc8a44 Mon Sep 17 00:00:00 2001 From: blakeblackshear Date: Tue, 12 Mar 2019 20:54:43 -0500 Subject: [PATCH] switch mqtt to a binary on/off instead of sending a message for each score --- frigate/mqtt.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/frigate/mqtt.py b/frigate/mqtt.py index d72c7deb8..fbd401776 100644 --- a/frigate/mqtt.py +++ b/frigate/mqtt.py @@ -43,11 +43,11 @@ class MqttObjectPublisher(threading.Thread): with self.objects_parsed: self.objects_parsed.wait() - # add all the person scores in detected objects and - # average over past 1 seconds (5fps) + # add all the person scores in detected objects detected_objects = self._detected_objects.copy() - avg_person_score = sum([obj['score'] for obj in detected_objects if obj['name'] == 'person'])/5 - payload['person'] = int(avg_person_score*100) + person_score = sum([obj['score'] for obj in detected_objects if obj['name'] == 'person']) + # if the person score is more than 100, set person to ON + payload['person'] = 'ON' if int(person_score*100) > 100 else 'OFF' # send message for objects if different new_payload = json.dumps(payload, sort_keys=True)