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: