logging.debug(' @Wc_2 door opened, stop procedure, stop time: %s, Main loop duration: %s', time.strftime("%H:%M:%S"), round((time.time() - start_third_check), 2)) break elif gpio.is_wc2_motion_detected_by_PIR(): logging.debug(' @Wc_2 move detected after: %s seconds ,keep going...', round((time.time() - last_time_move_detected), 2)) last_time_move_detected = time.time() time.sleep(1) elif no_move_time > 240: logging.debug(' @Wc_2 no move detected for 3 minutes, stop procedure') break else: time.sleep(0.1) # Main Loop of the program while True: if WC2_OCCUPIED == False and gpio.is_wc2_door_closed() and gpio.is_wc2_motion_detected_by_PIR(): # change state of the wc2 to occupied WC2_OCCUPIED = True gpio.wc2_led_occupied() # SEND REST detection_counter += 1 logging.debug('#Main Thread | change state of the wc2 (Free --> Occupied) | time: %s | detection counter: %s', time.strftime("%H:%M:%S"), detection_counter) # start new thread start_thread = time.time() t = threading.Thread(target=wc2_worker, args=[]) t.start() t.join() logging.debug('#Main Thread | change state of the wc2 (Occupied --> Free) | thread total time(duration): %.2f \n\n\n', (time.time() - start_thread)) GPIO.remove_event_detect(gpio.WC2_DOOR_sensor)