From f6f8738a4bfa524d67c3250435e7e9a2e6ea8874 Mon Sep 17 00:00:00 2001 From: dsutanto Date: Wed, 8 Apr 2026 15:01:39 +0700 Subject: [PATCH] Fix some inconsistensy not RELAY OFF --- frigate_counter.py | 22 ++++++++++++++++++++-- karung_masuk.db | Bin 12288 -> 12288 bytes karung_masuk.json | 4 ++-- 3 files changed, 22 insertions(+), 4 deletions(-) diff --git a/frigate_counter.py b/frigate_counter.py index 2b7b78b..f5bb1ff 100644 --- a/frigate_counter.py +++ b/frigate_counter.py @@ -195,7 +195,7 @@ class FrigateCounter: #event_type = data.get('type', '') #label = data.get('label', '') - logger.debug(f"Received message: camera={camera_name}, type={event_type}, label={label}") + logger.debug(f"Received message: camera={camera_name}, type={event_type}, label={label}, zones_after={zones_after}, zones_before={zones_before}, timer_active={self.timer_active}, pintu_buka_timer={self.pintu_buka_timer}") # Handle different object types if label == "pintu-kiri-buka" and not self.timer_active and not self.pintu_kiri_buka_detected: @@ -204,7 +204,8 @@ 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 and self.pintu_tutup_zone_name in zones_after and not self.pintu_buka_timer: + #elif label == "pintu-tutup" and self.timer_active and self.pintu_tutup_zone_name in zones_after and not self.pintu_buka_timer: + elif label == "pintu-tutup" and self.timer_active and not self.pintu_buka_timer: self.handle_pintu_tutup(camera_name) except Exception as e: @@ -283,10 +284,16 @@ class FrigateCounter: """Start Counting""" #logger.info("Starting 60-minute timer") logger.info("Start Counting and Timer pintu-buka 5 minutes") + #logger.info("Start Counting, Timer Counting 30-minutes and Timer pintu-buka 5 minutes") self.timer_active = True self.timer_start_time = datetime.now() self.pintu_buka_timer = True + # Schedule timer expiration check + #timer_thread = threading.Thread(target=self.check_timer_expiration_counting) + #timer_thread.daemon = True + #timer_thread.start() + # Schedule timer expiration check timer_thread = threading.Thread(target=self.check_timer_expiration_pintu_buka) timer_thread.daemon = True @@ -299,6 +306,17 @@ class FrigateCounter: # Call to RPI self.action_relay_on() + def check_timer_expiration_counting(self): + """Check if timer has expired (30 minutes)""" + time.sleep(30 * 60) # Wait 5 minutes + + if self.timer_active: + logger.info("Stop Counting. Timer Counting Expired (30 minutes)") + self.timer_active = False + self.pintu_kiri_buka_detected = False + self.pintu_kanan_buka_detected = False + self.seen_objects = {} + def check_timer_expiration_pintu(self): """Check if timer has expired (5 minutes)""" time.sleep(5 * 60) # Wait 5 minutes diff --git a/karung_masuk.db b/karung_masuk.db index 0b1216e8dbaeda2e30cc99209f758083cc41c45e..a245d0cbc951d11e85ffe31f75f65a3c8e2e73d7 100644 GIT binary patch delta 89 zcmZojXh@hK&B!}Z#+i|KW5N=C86I8}2L2=bo&3K10(@8aX7I)EDe^w!UCmp-YqGIW rgqO*RXR^P%l7xw_fw`uUfsvW60f?z!Xl7+-^X{PY!a delta 55 zcmZojXh@hK&B!xR#+i|4W5N=CDQ?~Z2L2=bo&3K10(@8aX7I)EDe^w!UCmptu`q~t LbAfEX5FcQw diff --git a/karung_masuk.json b/karung_masuk.json index 6c542a5..c18d735 100644 --- a/karung_masuk.json +++ b/karung_masuk.json @@ -1,5 +1,5 @@ { "kandang_1_karung_masuk": { - "karung": 41 + "karung": 109 } -} \ No newline at end of file +}