Setup Healthchecks integration for sunset detection reset #22
This commit is contained in:
1 parent
4620d5b9dc
commit
7b24dad5b9
4 files changed
+31
-4
No files matched your search
@@ -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
|
||||
@@ -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
|
||||
|
||||
Reference in new issue
Block a user