From 23e0c41fc020f9a7ce9adc8bea6a6dec3020b118 Mon Sep 17 00:00:00 2001 From: Josh Hawkins <32435876+hawkeye217@users.noreply.github.com> Date: Thu, 29 Oct 2026 15:59:33 -0500 Subject: [PATCH] add configurable ttl for active alert notifications Notifications sent while an alert was active always used a TTL of 0, so the push service dropped them if the device wasn't reachable at that moment and users only received the notification sent when the alert ended. A new `ttl` notifications option, settable globally or per camera, lets the push service retry these notifications for that many seconds. It defaults to 0, and the settings UI warns that a non-zero value can deliver stale notifications. --- docs/docs/configuration/notifications.md | 23 +++++++++++++++++++ frigate/comms/webpush.py | 2 +- frigate/config/camera/notification.py | 6 +++++ web/public/locales/en/config/cameras.json | 4 ++++ web/public/locales/en/config/global.json | 4 ++++ web/public/locales/en/views/settings.json | 3 ++- .../section-configs/notifications.ts | 10 ++++++++ 7 files changed, 50 insertions(+), 2 deletions(-) diff --git a/docs/docs/configuration/notifications.md b/docs/docs/configuration/notifications.md index 67b4f2374d..a923c2a61c 100644 --- a/docs/docs/configuration/notifications.md +++ b/docs/docs/configuration/notifications.md @@ -108,6 +108,29 @@ Currently, only Chrome supports images in notifications. Safari and Firefox will Different platforms handle notifications differently, some settings changes may be required to get optimal notification delivery. +### Notification TTL + +By default, Frigate sends notifications for an active alert with a TTL of `0`, so the push service either delivers them immediately or drops them. If your device is briefly unreachable (asleep, switching from Wi-Fi to cellular, or on a weak signal), those notifications are lost and you only receive the notification sent when the alert ends, which is always kept for up to an hour. + +Setting `ttl` tells the push service to keep retrying notifications sent while an alert is active for that many seconds. This makes delivery more reliable, but a notification delivered late will still say an object is detected, even if the object has already left. Keep the value small. + + + + +1. Navigate to and select the desired camera. + - Set **Notification TTL** to the number of seconds to keep retrying (e.g. `10`) + + + + +```yaml +notifications: + ttl: 10 # retry an undelivered notification for up to 10 seconds +``` + + + + ### Android Most Android phones have battery optimization settings. To get reliable Notification delivery the browser (Chrome, Firefox) should have battery optimizations disabled. If Frigate is running as a PWA then the Frigate app should have battery optimizations disabled as well. diff --git a/frigate/comms/webpush.py b/frigate/comms/webpush.py index f7267896ed..465ea63306 100644 --- a/frigate/comms/webpush.py +++ b/frigate/comms/webpush.py @@ -623,7 +623,7 @@ class WebPushClient(Communicator): # if event is ongoing open to live view otherwise open to recordings view direct_url = f"/review?id={reviewId}" if ended else f"/#{camera}" - ttl = 3600 if ended else 0 + ttl = 3600 if ended else self.config.cameras[camera].notifications.ttl logger.debug(f"Sending push notification for {camera}, review ID {reviewId}") diff --git a/frigate/config/camera/notification.py b/frigate/config/camera/notification.py index 5fe6a57834..877a27cc04 100644 --- a/frigate/config/camera/notification.py +++ b/frigate/config/camera/notification.py @@ -24,6 +24,12 @@ class NotificationConfig(FrigateBaseModel): title="Cooldown period", description="Cooldown (seconds) between notifications to avoid spamming recipients.", ) + ttl: int = Field( + default=0, + ge=0, + title="Notification TTL", + description="Seconds the push service keeps retrying a notification sent while an alert is active if your device can't be reached. 0 delivers immediately or drops it. The notification sent when an alert ends is always kept for up to an hour.", + ) enabled_in_config: bool | None = Field( default=None, title="Original notifications state", diff --git a/web/public/locales/en/config/cameras.json b/web/public/locales/en/config/cameras.json index 68eccf03c6..62757efc4d 100644 --- a/web/public/locales/en/config/cameras.json +++ b/web/public/locales/en/config/cameras.json @@ -858,6 +858,10 @@ "label": "Cooldown period", "description": "Cooldown (seconds) between notifications to avoid spamming recipients." }, + "ttl": { + "label": "Notification TTL", + "description": "Seconds the push service keeps retrying a notification sent while an alert is active if your device can't be reached. 0 delivers immediately or drops it. The notification sent when an alert ends is always kept for up to an hour." + }, "enabled_in_config": { "label": "Original notifications state", "description": "Indicates whether notifications were enabled in the original static configuration." diff --git a/web/public/locales/en/config/global.json b/web/public/locales/en/config/global.json index 40d4542c16..0b21c2d8e2 100644 --- a/web/public/locales/en/config/global.json +++ b/web/public/locales/en/config/global.json @@ -154,6 +154,10 @@ "label": "Cooldown period", "description": "Cooldown (seconds) between notifications to avoid spamming recipients." }, + "ttl": { + "label": "Notification TTL", + "description": "Seconds the push service keeps retrying a notification sent while an alert is active if your device can't be reached. 0 delivers immediately or drops it. The notification sent when an alert ends is always kept for up to an hour." + }, "enabled_in_config": { "label": "Original notifications state", "description": "Indicates whether notifications were enabled in the original static configuration." diff --git a/web/public/locales/en/views/settings.json b/web/public/locales/en/views/settings.json index 267c88f49f..55259a5305 100644 --- a/web/public/locales/en/views/settings.json +++ b/web/public/locales/en/views/settings.json @@ -2051,7 +2051,8 @@ "profileBaseDisabled": "Recording is disabled in this camera's base config, so enabling it in a profile has no effect. Enable recording in the base config and use a profile to disable it instead." }, "notifications": { - "profileBaseDisabled": "No cameras have notifications enabled in their base config, so enabling them in a profile has no effect. Enable notifications in the base config of at least one camera." + "profileBaseDisabled": "No cameras have notifications enabled in their base config, so enabling them in a profile has no effect. Enable notifications in the base config of at least one camera.", + "ttlDelay": "If your device can't be reached when an alert is active, its notifications can arrive up to this many seconds late. It will still say an object is detected and open the live view, even if the object has already left." }, "birdseye": { "objectTrackingDetectDisabled": "Birdseye includes tracked objects, but object detection is disabled for this camera. The camera will not appear in Birdseye.", diff --git a/web/src/components/config-form/section-configs/notifications.ts b/web/src/components/config-form/section-configs/notifications.ts index 62adcab520..1fa3114127 100644 --- a/web/src/components/config-form/section-configs/notifications.ts +++ b/web/src/components/config-form/section-configs/notifications.ts @@ -24,6 +24,15 @@ const notifications: SectionConfigOverrides = { camera.notifications.enabled_in_config, ), }, + { + key: "notifications-ttl-delay", + field: "ttl", + messageKey: "configMessages.notifications.ttlDelay", + severity: "warning", + position: "after", + condition: (ctx) => + typeof ctx.formData?.ttl === "number" && ctx.formData.ttl > 0, + }, ], }, global: { @@ -32,6 +41,7 @@ const notifications: SectionConfigOverrides = { enabled: { "ui:widget": "hidden" }, email: { "ui:widget": "hidden" }, cooldown: { "ui:widget": "hidden" }, + ttl: { "ui:widget": "hidden" }, enabled_in_config: { "ui:widget": "hidden" }, }, },