Use pintu-tutup
This commit is contained in:
+21
-9
@@ -178,10 +178,21 @@ class FrigateCounter:
|
|||||||
self.handle_pintu_kanan_buka(camera_name)
|
self.handle_pintu_kanan_buka(camera_name)
|
||||||
elif label == "karung" and self.timer_active:
|
elif label == "karung" and self.timer_active:
|
||||||
self.handle_karung(camera_name, track_id)
|
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:
|
except Exception as e:
|
||||||
logger.error(f"Error processing MQTT message: {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):
|
def handle_pintu_kiri_buka(self, camera_name):
|
||||||
"""Handle detection of pintu-kiri-buka"""
|
"""Handle detection of pintu-kiri-buka"""
|
||||||
logger.info(f"Detected pintu-kiri-buka on {camera_name}")
|
logger.info(f"Detected pintu-kiri-buka on {camera_name}")
|
||||||
@@ -240,15 +251,16 @@ class FrigateCounter:
|
|||||||
timer_thread.start()
|
timer_thread.start()
|
||||||
|
|
||||||
def start_timer(self):
|
def start_timer(self):
|
||||||
"""Start the 30-minute timer"""
|
"""Start Counting"""
|
||||||
logger.info("Starting 30-minute timer")
|
#logger.info("Starting 60-minute timer")
|
||||||
|
logger.info("Start Counting...")
|
||||||
self.timer_active = True
|
self.timer_active = True
|
||||||
self.timer_start_time = datetime.now()
|
self.timer_start_time = datetime.now()
|
||||||
|
|
||||||
# Schedule timer expiration check
|
# Schedule timer expiration check
|
||||||
timer_thread = threading.Thread(target=self.check_timer_expiration)
|
#timer_thread = threading.Thread(target=self.check_timer_expiration)
|
||||||
timer_thread.daemon = True
|
#timer_thread.daemon = True
|
||||||
timer_thread.start()
|
#timer_thread.start()
|
||||||
|
|
||||||
# Reset detection flags
|
# Reset detection flags
|
||||||
self.pintu_kiri_buka_detected = False
|
self.pintu_kiri_buka_detected = False
|
||||||
@@ -265,11 +277,11 @@ class FrigateCounter:
|
|||||||
self.pintu_kanan_buka_detected = False
|
self.pintu_kanan_buka_detected = False
|
||||||
|
|
||||||
def check_timer_expiration(self):
|
def check_timer_expiration(self):
|
||||||
"""Check if timer has expired (30 minutes)"""
|
"""Check if timer has expired (60 minutes)"""
|
||||||
time.sleep(30 * 60) # Wait 30 minutes
|
time.sleep(60 * 60) # Wait 60 minutes
|
||||||
|
|
||||||
if self.timer_active:
|
if self.timer_active:
|
||||||
logger.info("Timer expired (30 minutes)")
|
logger.info("Timer expired (60 minutes)")
|
||||||
self.timer_active = False
|
self.timer_active = False
|
||||||
#self.publish_result()
|
#self.publish_result()
|
||||||
#self.reset_counter()
|
#self.reset_counter()
|
||||||
@@ -277,7 +289,7 @@ class FrigateCounter:
|
|||||||
def publish_result(self):
|
def publish_result(self):
|
||||||
"""Publish counter result to MQTT topic"""
|
"""Publish counter result to MQTT topic"""
|
||||||
if self.counter > 0:
|
if self.counter > 0:
|
||||||
#topic = f"{self.topic}/{self.camera_name}/karung"
|
topic = f"{self.topic}/{self.camera_name}/karung"
|
||||||
#TESTING
|
#TESTING
|
||||||
topic = f"{self.topic}/{self.camera_name}-check_pintu/karung"
|
topic = f"{self.topic}/{self.camera_name}-check_pintu/karung"
|
||||||
message = str(self.counter)
|
message = str(self.counter)
|
||||||
|
|||||||
Reference in New Issue
Block a user