Logging, timeout

This commit is contained in:
Tanner Collin 2022-04-01 17:53:37 -06:00
parent 8fa91a9c55
commit a0e0651703

View File

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