diff --git a/conf/docker-compose.yaml b/conf/docker-compose.yaml index c7fbcba..29c135c 100644 --- a/conf/docker-compose.yaml +++ b/conf/docker-compose.yaml @@ -115,11 +115,17 @@ services: environment: IPGEOLOCATION_API_KEY: ${IPGEOLOCATION_API_KEY} FRIGATE_CONFIG_FILE: /frigate_config/config.yaml + REQUESTS_CA_BUNDLE: /etc/ssl/certs/ca-certificates.crt + SUNSET_DETECTION_RESET_HEALTHCHECKS_URL: 'https://healthchecks.homelab.net/ping/bee0e8ca-be23-41ba-aa30-478fc5f502f2' volumes: - type: volume source: config target: /frigate_config read_only: true + - type: bind + source: /data/certs/homelab_ca.crt + target: /usr/local/share/ca-certificates/homelab_ca.crt + read_only: true - type: bind source: /etc/localtime target: /etc/localtime diff --git a/start.yaml b/start.yaml index 98a2883..9033781 100644 --- a/start.yaml +++ b/start.yaml @@ -62,3 +62,9 @@ container: frigate-notifier command: update-ca-certificates user: root + + - name: Update CA certificates for frigate-webcontrol + community.docker.docker_container_exec: + container: frigate-webcontrol + command: update-ca-certificates + user: root diff --git a/webcontrol/requirements.txt b/webcontrol/requirements.txt index b38d166..c65eb18 100644 --- a/webcontrol/requirements.txt +++ b/webcontrol/requirements.txt @@ -4,3 +4,4 @@ fastapi==0.110.0 uvicorn[standard]==0.29.0 aiohttp==3.8.6 paho-mqtt==1.6.1 +requests==2.30.0 diff --git a/webcontrol/src/webcontrol/detection.py b/webcontrol/src/webcontrol/detection.py index 84a75af..bd1d33b 100644 --- a/webcontrol/src/webcontrol/detection.py +++ b/webcontrol/src/webcontrol/detection.py @@ -4,6 +4,7 @@ import logging import os import paho.mqtt.publish as mqtt_publish +import requests from webcontrol.frigate_config import FrigateConfigFile from webcontrol.nighttime import get_nighttimes @@ -27,7 +28,20 @@ async def reset_all_cameras_detection_after_sunset() -> None: logger.info(f"Waiting until {nighttime} to reset detection for all cameras") await asyncio.sleep((nighttime - dt.datetime.now()).total_seconds()) - await frigate_config_file.reload() - active_and_detection_enabled_cameras = set(frigate_config_file.active_cameras).intersection(frigate_config_file.detection_enabled_cameras) - for camera in active_and_detection_enabled_cameras: - await set_camera_detection(camera, True) + healthchecks_url = os.getenv("SUNSET_DETECTION_RESET_HEALTHCHECKS_URL") + try: + if healthchecks_url: + requests.post(os.path.join(healthchecks_url, "start")) + + await frigate_config_file.reload() + active_and_detection_enabled_cameras = set(frigate_config_file.active_cameras).intersection(frigate_config_file.detection_enabled_cameras) + for camera in active_and_detection_enabled_cameras: + await set_camera_detection(camera, True) + + if healthchecks_url: + requests.post(healthchecks_url, data=", ".join(active_and_detection_enabled_cameras)) + except Exception as e: + if healthchecks_url: + requests.post(os.path.join(healthchecks_url, "fail"), data=str(e)) + raise e +