Make ntfy url optional

This commit is contained in:
slashtechno 2023-10-27 11:08:17 -05:00
parent f669a39056
commit eedc2783c9
Signed by: slashtechno
GPG Key ID: 8EC1D9D9286C2B17
2 changed files with 18 additions and 15 deletions

View File

@ -98,14 +98,12 @@ def set_argparse():
# Defaults for the stuff here and down are already set in notify.py.
# Setting them here just means that argparse will display the default values as defualt
# TODO: Perhaps just remove the default parameter and just add to the help message that the default is set is x
# TODO: Make ntfy optional in ntfy.py. Currently, unless there is a local or LAN instance of ntfy, this can't run offline
notifcation_services = argparser.add_argument_group("Notification Services")
notifcation_services.add_argument(
"--ntfy-url",
default=os.environ["NTFY_URL"]
if "NTFY_URL" in os.environ and os.environ["NTFY_URL"] != ""
else "https://ntfy.sh/wyzely-detect",
else None,
type=str,
help="The URL to send notifications to",
)

View File

@ -104,6 +104,11 @@ def thing_detected(
):
respective_type[thing_name]["last_notification_time"] = time.time()
print(f"Detected {thing_name} for {detection_duration} seconds")
if ntfy_url is None:
print(
"ntfy_url is None. Not sending notification. Set ntfy_url to send notifications"
)
else:
headers = construct_ntfy_headers(
title=f"{thing_name} detected",
tag="rotating_light",