From c58751e6dd46af5e47195f899dff4c1280b5c744 Mon Sep 17 00:00:00 2001 From: Ashish D'Souza Date: Sat, 27 Jan 2024 16:04:39 -0600 Subject: [PATCH] Added sunset delay to allow full darkness #7 #8 Squashed commit of the following: commit 423931bcd23136ff4aea6b1cb9d9bf6dfc210f5a Author: Ashish D'Souza Date: Sat Jan 27 16:03:57 2024 -0600 Added 30 minute sunset delay --- webcontrol/src/detection.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/webcontrol/src/detection.py b/webcontrol/src/detection.py index 0e5a2ae..997a23c 100644 --- a/webcontrol/src/detection.py +++ b/webcontrol/src/detection.py @@ -14,7 +14,7 @@ import paho.mqtt.publish as mqtt_publish blueprint = Blueprint('detection', __name__) -def get_sunset() -> dt.datetime: +def get_sunset_time() -> dt.datetime: sunset_date = dt.datetime.now().date() try: IPGEOLOCATION_API_KEY = os.environ['IPGEOLOCATION_API_KEY'] @@ -41,9 +41,9 @@ def reset_all_camera_detection_at_sunset() -> None: frigate_api_response.raise_for_status() frigate_camera_config = json.loads(frigate_api_response.content)['cameras'] - sunset = get_sunset() - print(f'Waiting until {sunset} to reset detection for all cameras...', file=sys.stderr) - seconds_until_sunset = (sunset - dt.datetime.now()).total_seconds() + sunset_time = get_sunset_time() + dt.timedelta(minutes=30) + print(f'Waiting until {sunset_time} to reset detection for all cameras...', file=sys.stderr) + seconds_until_sunset = (sunset_time - dt.datetime.now()).total_seconds() time.sleep(seconds_until_sunset) for camera_name in frigate_camera_config: