Files
frigate/frigate/config/camera/notification.py
T
Josh HawkinsandGitHub 9b0aa75312
CI / AMD64 Build (push) Canceled after 0s
CI / AMD64 Smoke Test (push) Canceled after 0s
CI / ARM Build (push) Canceled after 0s
CI / Jetson Jetpack 6 (push) Canceled after 0s
CI / AMD64 Extra Build (push) Canceled after 0s
CI / ARM Extra Build (push) Canceled after 0s
CI / Synaptics Build (push) Canceled after 0s
CI / Assemble and push default build (push) Canceled after 0s
Add configurable notification TTL (#24829)
* 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.

* make notification ttl a global advanced setting

- Read `ttl` from the global notifications config and hide it on the camera form
- Show it under Advanced Settings on the Notifications page
- Remove extra padding that misaligned the Notifications cards with the rest of the form
- Shorten the ttl warning

* tweaks

* use enum instead of raw seconds value
2026-10-30 12:52:22 -06:00

50 lines
1.7 KiB
Python

from enum import Enum
from pydantic import Field
from frigate.util.env import EnvString
from ..base import FrigateBaseModel
__all__ = ["NotificationConfig", "NotificationTTLEnum", "NOTIFICATION_TTL_SECONDS"]
class NotificationTTLEnum(str, Enum):
immediate = "immediate"
reliable = "reliable"
NOTIFICATION_TTL_SECONDS = {
NotificationTTLEnum.immediate: 0,
NotificationTTLEnum.reliable: 30,
}
class NotificationConfig(FrigateBaseModel):
enabled: bool = Field(
default=False,
title="Enable notifications",
description="Enable or disable notifications for all cameras; can be overridden per-camera.",
)
email: EnvString | None = Field(
default=None,
title="Notification email",
description="Email address used for push notifications or required by certain notification providers.",
)
cooldown: int = Field(
default=0,
ge=0,
title="Cooldown period",
description="Cooldown (seconds) between notifications to avoid spamming recipients.",
)
ttl: NotificationTTLEnum = Field(
default=NotificationTTLEnum.immediate,
title="Notification TTL",
description="How the push service handles a notification sent while an alert is active if your device can't be reached. Immediate delivers it right away or drops it. Reliable keeps retrying for up to 30 seconds. 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",
description="Indicates whether notifications were enabled in the original static configuration.",
)