Squashed commit of the following: commit 423931bcd23136ff4aea6b1cb9d9bf6dfc210f5a Author: Ashish D'Souza <sudouser512@gmail.com> Date: Sat Jan 27 16:03:57 2024 -0600 Added 30 minute sunset delay
This commit is contained in:
parent
f3dfaeea1b
commit
c58751e6dd
|
@ -14,7 +14,7 @@ import paho.mqtt.publish as mqtt_publish
|
||||||
blueprint = Blueprint('detection', __name__)
|
blueprint = Blueprint('detection', __name__)
|
||||||
|
|
||||||
|
|
||||||
def get_sunset() -> dt.datetime:
|
def get_sunset_time() -> dt.datetime:
|
||||||
sunset_date = dt.datetime.now().date()
|
sunset_date = dt.datetime.now().date()
|
||||||
try:
|
try:
|
||||||
IPGEOLOCATION_API_KEY = os.environ['IPGEOLOCATION_API_KEY']
|
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_api_response.raise_for_status()
|
||||||
frigate_camera_config = json.loads(frigate_api_response.content)['cameras']
|
frigate_camera_config = json.loads(frigate_api_response.content)['cameras']
|
||||||
|
|
||||||
sunset = get_sunset()
|
sunset_time = get_sunset_time() + dt.timedelta(minutes=30)
|
||||||
print(f'Waiting until {sunset} to reset detection for all cameras...', file=sys.stderr)
|
print(f'Waiting until {sunset_time} to reset detection for all cameras...', file=sys.stderr)
|
||||||
seconds_until_sunset = (sunset - dt.datetime.now()).total_seconds()
|
seconds_until_sunset = (sunset_time - dt.datetime.now()).total_seconds()
|
||||||
time.sleep(seconds_until_sunset)
|
time.sleep(seconds_until_sunset)
|
||||||
|
|
||||||
for camera_name in frigate_camera_config:
|
for camera_name in frigate_camera_config:
|
||||||
|
|
Loading…
Reference in New Issue