Make ntfy url optional
This commit is contained in:
parent
f669a39056
commit
eedc2783c9
|
@ -98,14 +98,12 @@ def set_argparse():
|
||||||
|
|
||||||
# Defaults for the stuff here and down are already set in notify.py.
|
# 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
|
# 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 = argparser.add_argument_group("Notification Services")
|
||||||
notifcation_services.add_argument(
|
notifcation_services.add_argument(
|
||||||
"--ntfy-url",
|
"--ntfy-url",
|
||||||
default=os.environ["NTFY_URL"]
|
default=os.environ["NTFY_URL"]
|
||||||
if "NTFY_URL" in os.environ and 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,
|
type=str,
|
||||||
help="The URL to send notifications to",
|
help="The URL to send notifications to",
|
||||||
)
|
)
|
||||||
|
|
|
@ -104,6 +104,11 @@ def thing_detected(
|
||||||
):
|
):
|
||||||
respective_type[thing_name]["last_notification_time"] = time.time()
|
respective_type[thing_name]["last_notification_time"] = time.time()
|
||||||
print(f"Detected {thing_name} for {detection_duration} seconds")
|
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(
|
headers = construct_ntfy_headers(
|
||||||
title=f"{thing_name} detected",
|
title=f"{thing_name} detected",
|
||||||
tag="rotating_light",
|
tag="rotating_light",
|
||||||
|
|
Loading…
Reference in New Issue