From a0e0651703bfe71adbb559261716ed8ec7a1b484 Mon Sep 17 00:00:00 2001 From: Tanner Collin Date: Fri, 1 Apr 2022 17:53:37 -0600 Subject: [PATCH] Logging, timeout --- main.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/main.py b/main.py index ea9402e..588de1e 100644 --- a/main.py +++ b/main.py @@ -14,6 +14,7 @@ try: import RPi.GPIO as GPIO IS_PI = True except ModuleNotFoundError: + logging.info('RPi.GPIO not found, running without GPIO.') IS_PI = False import time @@ -33,7 +34,7 @@ def set_relay(pin, state): def pulse_relay(pin): set_relay(pin, RELAY_ON) - time.sleep(0.5) # atomic + time.sleep(0.25) # atomic set_relay(pin, RELAY_OFF) def ring_bell(camera): @@ -66,8 +67,8 @@ async def main(): async for msg in unifi.connect(): await process_message(msg) except BaseException as e: - logging.error('Error connecting to Unifi Protect: %s. Trying again...', str(e)) - await asyncio.sleep(3) + logging.exception('Error connecting to Unifi Protect: %s. Trying again...', str(e)) + await asyncio.sleep(5) def disable_relays_on_exit(*args):