From 048f66919a330ab0052e92629742b83b646e833e Mon Sep 17 00:00:00 2001 From: dsutanto Date: Thu, 26 Feb 2026 07:20:58 +0700 Subject: [PATCH] Use pintu-tutup --- frigate_counter.py | 30 +++++++++++++++++++++--------- 1 file changed, 21 insertions(+), 9 deletions(-) diff --git a/frigate_counter.py b/frigate_counter.py index e6e8c99..8194e7f 100644 --- a/frigate_counter.py +++ b/frigate_counter.py @@ -178,10 +178,21 @@ class FrigateCounter: self.handle_pintu_kanan_buka(camera_name) elif label == "karung" and self.timer_active: self.handle_karung(camera_name, track_id) + elif label == "pintu-tutup" and self.timer_active: + self.handle_pintu_tutup(camera_name) except Exception as e: logger.error(f"Error processing MQTT message: {e}") + def handle_pintu_tutup(self, camera_name): + """Handle detection of pintu-tutup""" + logger.info(f"Detected pintu-tutup {camera_name}") + + if self.timer_active: + logger.info("Stop Counting Karung") + self.timer_active = False + self.seen_objects = {} + def handle_pintu_kiri_buka(self, camera_name): """Handle detection of pintu-kiri-buka""" logger.info(f"Detected pintu-kiri-buka on {camera_name}") @@ -240,15 +251,16 @@ class FrigateCounter: timer_thread.start() def start_timer(self): - """Start the 30-minute timer""" - logger.info("Starting 30-minute timer") + """Start Counting""" + #logger.info("Starting 60-minute timer") + logger.info("Start Counting...") self.timer_active = True self.timer_start_time = datetime.now() # Schedule timer expiration check - timer_thread = threading.Thread(target=self.check_timer_expiration) - timer_thread.daemon = True - timer_thread.start() + #timer_thread = threading.Thread(target=self.check_timer_expiration) + #timer_thread.daemon = True + #timer_thread.start() # Reset detection flags self.pintu_kiri_buka_detected = False @@ -265,11 +277,11 @@ class FrigateCounter: self.pintu_kanan_buka_detected = False def check_timer_expiration(self): - """Check if timer has expired (30 minutes)""" - time.sleep(30 * 60) # Wait 30 minutes + """Check if timer has expired (60 minutes)""" + time.sleep(60 * 60) # Wait 60 minutes if self.timer_active: - logger.info("Timer expired (30 minutes)") + logger.info("Timer expired (60 minutes)") self.timer_active = False #self.publish_result() #self.reset_counter() @@ -277,7 +289,7 @@ class FrigateCounter: def publish_result(self): """Publish counter result to MQTT topic""" if self.counter > 0: - #topic = f"{self.topic}/{self.camera_name}/karung" + topic = f"{self.topic}/{self.camera_name}/karung" #TESTING topic = f"{self.topic}/{self.camera_name}-check_pintu/karung" message = str(self.counter)