Fix some inconsistensy not RELAY OFF

This commit is contained in:
2026-04-08 15:01:39 +07:00
parent 6e8dec689c
commit f6f8738a4b
3 changed files with 22 additions and 4 deletions

View File

@@ -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

Binary file not shown.

View File

@@ -1,5 +1,5 @@
{
"kandang_1_karung_masuk": {
"karung": 41
"karung": 109
}
}
}