frigate-notify

repository·main·Indexed 18 days ago

https://github.com/0x2142/frigate-notify

A notification bridge for Frigate NVR that converts events into alerts for platforms including Telegram, Discord, Gotify, Matrix, Mattermost, Ntfy, Pushover, Signal, SMTP, and Webhooks, as well as services via the Apprise API. It supports event polling via MQTT or the Frigate API and includes a REST API for configuration management, notification state control, and health monitoring.

Tokens
11.9K
Snippets
40
Records
57
Agent score
63%

What's inside frigate-notify

  1. Overview of Frigate-Notify features and capabilities

    main

    Frigate-Notify is a notification bridge designed to send alerts from Frigate NVR to various platforms. It is intended for standalone Frigate installations and does not require Home Assistant. While MQTT is optional, it is recommended for event polling.

    Event Polling Methods

    • MQTT: Polls events via an MQTT broker.
    • Direct via Frigate API: Polls events directly from the Frigate API.

    Supported Notification Methods

    • Native Support: Discord, Gotify, Matrix, Mattermost, Ntfy, Pushover, Signal, SMTP, Telegram, Webhook.
    • Extensible Support: Any service supported by the Apprise API can be used.

    Monitoring

    • Aliveness Monitor: Provides an HTTP GET endpoint to monitor the application's status, compatible with tools like HealthChecks or Uptime Kuma.
  2. Overview of Frigate-Notify

    main
    Frigate-Notify is a lightweight application designed to bridge Frigate NVR events to various notification platforms. It is built to work with standalone Frigate installations and does not require Home Assistant. While MQTT is optional, it is the recommended method for event polling.
  3. Supported Event Polling Methods

    main

    Frigate-Notify can ingest events from Frigate using two primary methods:

    1. MQTT: The recommended approach for receiving event data.
    2. Direct via Frigate API: Polling the Frigate API directly if MQTT is not configured.
  4. Customize alert messages with templates

    main

    Frigate-Notify uses Golang text templates to allow customization of alert messages. You can define a template within any notification provider's configuration.

    Variables are inserted using the {{ .VariableName }} syntax. If the template key is missing or blank, the default template (HTML, Plaintext, Markdown, or JSON depending on the provider) is used.

    Important Syntax Rules:

    • Single-line templates: If your template starts with a variable, you must wrap the entire string in quotes to avoid configuration loading errors. Use template: "{{ .Camera }} alert!" instead of template: {{ .Camera }} alert!.
    • Multi-line templates: Use the YAML pipe operator (|) for cleaner multi-line messages.

    To debug template rendering issues, enable debug logging to see the final rendered output in the logs.

    alerts:
      discord:
        enabled: true
        webhook: # Webhook URL
        template: "Looks like {{ .Camera }} spotted a {{ .Label }}!!"
  5. Install and run frigate-notify locally

    main

    Binary executables are available in the project releases. After downloading the binary, you can run it directly. By default, the application searches for a file named config.yml in the same directory as the executable.

    ./frigate-notify
  6. Customize alert titles with templates

    main

    You can use template variables to dynamically set the subject line or title of an alert by configuring the title key under a notification provider.

    Example: Setting a title that includes the camera name and the detected label.

    alerts:
      general:
        title: Frigate - {{ .Camera }} detected {{ .Label }}
  7. Customize HTTP headers with templates

    main

    For notification methods that support custom HTTP headers, you can use templates to dynamically generate header values. This is useful for:

    • Dynamic Priority/Tags: Changing notification behavior (like Ntfy priority) based on event data (e.g., whether an object is in a zone).
    • Authentication: Injecting sensitive tokens from environment variables.

    Example: Using logic to change Ntfy priority and tags based on whether the object is in a zone, and pulling an auth token from an environment variable.

        headers:
          - Authorization: Basic {{ env.Getenv "FN_NTFY_AUTH_BASIC" }}
          - X-Priority: "{{ if ge (len .Zones ) 1 }} 4{{ else }} 3{{ end }}"
          - X-Tags: "{{ if ge (len .Zones ) 1 }} rotating_light, {{ end }}walking"
  8. Configure Frigate-Notify via config file or environment variables

    main

    Frigate-Notify can be configured using three primary methods:

    1. Config File: The preferred method for complex setups. Detailed schema and structure can be found in the Config File documentation.
    2. Environment Variables: Useful for containerized deployments or overriding specific settings.
    3. Command Line Flags: A limited set of extra options are available via CLI flags to supplement the configuration.
  9. Install frigate-notify using Docker Compose

    main

    The recommended way to run frigate-notify is via Docker. You can use the official images from the GitHub Container Registry. Use the latest tag for the most recent version or specific version tags (e.g., v0.3.0) for stability.

    To run with Docker Compose, map your local config.yml to the container's expected path. By default, the app looks for the configuration at /app/config.yml or within the /app/config directory.

    services:
      frigate-notify:
        image: ghcr.io/0x2142/frigate-notify:latest
        # Uncomment below if REST API server is enabled
        # ports:
        #   - "8000:8000"
        environment:
          - TZ=Etc/UTC
        volumes:
          - /path/to/config.yml:/app/config.yml
        restart: unless-stopped
  10. Configure Frigate-Notify using the sample configuration template

    main

    Frigate-Notify is configured via a YAML file. The configuration is divided into several main sections: app (application settings), frigate (connection settings for the Frigate server and MQTT), alerts (notification logic and provider settings), and monitor (health monitoring).

    Use the following template to structure your configuration file. Note that many fields are optional and depend on which notification methods and Frigate features you intend to use.

    app:
      mode:
      api:
        enabled:
        port:
    
    frigate:
      server: 
      ignoressl: true
      public_url: 
      headers: 
      startup_check:
        attempts: 
        interval: 
    
      webapi:
        enabled: 
        interval: 
        
      mqtt: 
        enabled: 
        server: 
        port:
        clientid:
        username: 
        password: 
        topic_prefix: 
      
      cameras:
        exclude:
          - test_cam_01
    
    alerts:  
      general:
        title:
        timeformat:
        nosnap: 
        snap_bbox: 
        snap_timestamp: 
        snap_crop: 
        snap_hires: 
        max_snap_retry: 
        notify_once: 
        notify_detections: 
        recheck_delay: 
        audio_only: 
    
      quiet:
        start:
        end:
    
      zones:
        unzoned: allow
        allow:
         - test_zone_01
        block:
         - test_zone_02
    
      labels:
        min_score: 
        allow:
         - person
         - dog
        block:
         - bird
    
      sublabels:
        allow:
         - ABCD
        block:
         - EFGH
    
      license_plate:
        enabled: false
        allow:
        block:
    
      # Notification Providers (examples)
      apprise_api:
        enabled: false
        server:
        token:
        urls:
        tags:
        ignoressl: 
        template: 
    
      discord:
        enabled: false
        webhook:
        disable_embed: 
        template: 
      
      gotify:
        enabled: false
        server:
        token:
        priority: 
        ignoressl: 
        template: 
    
      matrix:
        enabled: false
        server:
        username:
        password:
        roomid:
        ignoressl: 
        template: 
    
      mattermost:
        enabled: false
        webhook:
        channel:
        username:
        priority: 
        ignoressl: 
        headers: 
        template: 
    
      ntfy:
        enabled: false
        server:
        topic:
        ignoressl: 
        headers: 
        template: 
    
      pushover:
        enabled: false
        token:
        userkey:
        devices:
        sound: 
        priority: 
        retry: 
        expire: 
        ttl: 
        template: 
    
      signal:
        enabled: false
        server:
        account:
        recipients:
        ignoressl: 
        template: 
    
      smtp:
        enabled: false
        server:
        port:
        tls: 
        authtype: 
        user:
        password:
        recipient:
        msguuid: 
        thread: 
        template: 
    
      telegram:
        enabled: false
        chatid:
        send_clip: 
        message_thread_id: 
        token:
        template: 
    
      webhook:
        enabled: false
        server: 
        ignoressl: 
        method: 
        params: 
        headers: 
        template: 
    
    monitor:
      enabled: false
      url: 
      interval: 
      ignoressl: