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.
|
||||
# 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",
|
||||
)
|
||||
|
|
|
@ -104,18 +104,23 @@ def thing_detected(
|
|||
):
|
||||
respective_type[thing_name]["last_notification_time"] = time.time()
|
||||
print(f"Detected {thing_name} for {detection_duration} seconds")
|
||||
headers = construct_ntfy_headers(
|
||||
title=f"{thing_name} detected",
|
||||
tag="rotating_light",
|
||||
priority="default",
|
||||
)
|
||||
send_notification(
|
||||
data=f"{thing_name} detected for {detection_duration} seconds",
|
||||
headers=headers,
|
||||
url=ntfy_url,
|
||||
)
|
||||
# Reset the detection duration
|
||||
print("Just sent a notification - resetting detection duration")
|
||||
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",
|
||||
priority="default",
|
||||
)
|
||||
send_notification(
|
||||
data=f"{thing_name} detected for {detection_duration} seconds",
|
||||
headers=headers,
|
||||
url=ntfy_url,
|
||||
)
|
||||
# Reset the detection duration
|
||||
print("Just sent a notification - resetting detection duration")
|
||||
respective_type[thing_name]["detection_duration"] = 0
|
||||
|
||||
# Take the aliased objects_and_peoples and update the respective dictionary
|
||||
|
|
Loading…
Reference in New Issue