Skip to content

Commit 5a6f45e

Browse files
authored
Merge pull request #220 from 0x2142/release-v0.4.3
Release v0.4.3
2 parents 52dbb54 + eed8cf2 commit 5a6f45e

20 files changed

+315
-11
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ Frigate-Notify is a simple app designed to send notifications from [Frigate](htt
2828
- SMTP
2929
- Telegram
3030
- Webhook
31+
- And many others via the [Apprise API](https://github.com/caronc/apprise-api)
3132

3233
### Other
3334

config/internal.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ var Internal models.InternalConfig
66

77
func init() {
88
Internal.Status.Notifications.Enabled = true
9-
Internal.AppVersion = "v0.4.2"
9+
Internal.AppVersion = "v0.4.3"
1010
Internal.Status.Health = "n/a"
1111
Internal.Status.API = "n/a"
1212
Internal.Status.Frigate.API = "n/a"

config/validate.go

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,17 @@ func (c *Config) Validate() []string {
7070
validationErrors = append(validationErrors, results...)
7171
}
7272

73+
// Validate Apprise API
74+
Internal.Status.Notifications.AppriseAPI = make([]models.NotifierStatus, len(c.Alerts.AppriseAPI))
75+
for id, profile := range c.Alerts.AppriseAPI {
76+
Internal.Status.Notifications.AppriseAPI[id].InitNotifStatus(id, profile.Enabled)
77+
if profile.Enabled {
78+
if results := c.validateAppriseAPI(id); len(results) > 0 {
79+
validationErrors = append(validationErrors, results...)
80+
}
81+
}
82+
}
83+
7384
// Validate Discord
7485
Internal.Status.Notifications.Discord = make([]models.NotifierStatus, len(c.Alerts.Discord))
7586
for id, profile := range c.Alerts.Discord {
@@ -394,6 +405,12 @@ func (c *Config) validateAlertGeneral() []string {
394405
alertErrors = append(alertErrors, msg)
395406
}
396407

408+
// Set default for max snap retry
409+
if c.Alerts.General.MaxSnapRetry == 0 {
410+
c.Alerts.General.MaxSnapRetry = 10
411+
}
412+
log.Debug().Msgf("Max retry attempts for snapshots: %v", c.Alerts.General.MaxSnapRetry)
413+
397414
return alertErrors
398415
}
399416

@@ -468,6 +485,34 @@ func (c *Config) validateLabelFiltering() []string {
468485
return labelErrors
469486
}
470487

488+
func (c *Config) validateAppriseAPI(id int) []string {
489+
var appriseapiErrors []string
490+
log.Debug().Msgf("Alerting enabled for Apprise API profile ID %v", id)
491+
if c.Alerts.AppriseAPI[id].Server == "" {
492+
appriseapiErrors = append(appriseapiErrors, fmt.Sprintf("No Apprise API server specified! Profile ID %v", id))
493+
}
494+
if c.Alerts.AppriseAPI[id].Token == "" && len(c.Alerts.AppriseAPI[id].URLs) == 0 {
495+
appriseapiErrors = append(appriseapiErrors, fmt.Sprintf("No Apprise API token or notification URLs specified! Profile ID %v", id))
496+
}
497+
if c.Alerts.AppriseAPI[id].Token != "" && len(c.Alerts.AppriseAPI[id].URLs) != 0 {
498+
appriseapiErrors = append(appriseapiErrors, fmt.Sprintf("Only Apprise API token or notification URLs may be configured, not both! Profile ID %v", id))
499+
}
500+
if c.Alerts.AppriseAPI[id].Token != "" && len(c.Alerts.AppriseAPI[id].Tags) == 0 {
501+
appriseapiErrors = append(appriseapiErrors, fmt.Sprintf("If using Apprise API token, tags must also be configured! Profile ID %v", id))
502+
}
503+
504+
// Check if Apprise API server URL contains protocol, assume HTTP if not specified
505+
if !strings.Contains(c.Alerts.AppriseAPI[id].Server, "http://") && !strings.Contains(c.Alerts.AppriseAPI[id].Server, "https://") {
506+
log.Debug().Msgf("No protocol specified on Apprise API Server. Assuming http://. If this is incorrect, please adjust the config file. Profile ID %v", id)
507+
c.Alerts.AppriseAPI[id].Server = fmt.Sprintf("http://%s", c.Alerts.AppriseAPI[id].Server)
508+
}
509+
// Check template syntax
510+
if msg := validateTemplate("Apprise API", c.Alerts.AppriseAPI[id].Template); msg != "" {
511+
appriseapiErrors = append(appriseapiErrors, msg+fmt.Sprintf(" Profile ID %v", id))
512+
}
513+
return appriseapiErrors
514+
}
515+
471516
func (c *Config) validateDiscord(id int) []string {
472517
var discordErrors []string
473518
log.Debug().Msgf("Alerting enabled for Discord profile ID %v", id)
@@ -662,6 +707,11 @@ func (c *Config) validateWebhook(id int) []string {
662707

663708
func (c *Config) validateAlertingEnabled() string {
664709
// Check to ensure at least one alert provider is configured
710+
for _, profile := range c.Alerts.AppriseAPI {
711+
if profile.Enabled {
712+
return ""
713+
}
714+
}
665715
for _, profile := range c.Alerts.Discord {
666716
if profile.Enabled {
667717
return ""

docker-compose.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
version: "3.0"
21
services:
32
frigate-notify:
43
image: ghcr.io/0x2142/frigate-notify:latest

docs/changelog.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# Changelog
22

3+
## [v0.4.3](https://github.com/0x2142/frigate-notify/releases/tag/v0.4.3) - Feb 21 2025
4+
- Add support for notifications via [Apprise API](https://frigate-notify.0x2142.com/latest/config/file/#apprise-api)
5+
- Add retry interval for collecting snapshots from Frigate
6+
- Updated notification templates to include sublabel information, if available
7+
- Fix app crash when no items in a review were eligible for notification
8+
39
## [v0.4.2](https://github.com/0x2142/frigate-notify/releases/tag/v0.4.2) - Feb 10 2025
410
- Fix issue with Signal notifications when no snapshot image is available
511
- Fix issue with sending Signal notifications to groups or usernames

docs/config/file.md

Lines changed: 51 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,12 @@ All alert providers (Discord, Gotify, etc) also support optional filters & the a
165165
- **snap_crop** (Optional - Default: `false`)
166166
- Crops snapshot when retrieved from Frigate
167167
- Note: Per [Frigate docs](https://docs.frigate.video/integrations/api/#get-apieventsidsnapshotjpg), only applied when event is in progress
168+
- **max_snap_retry** (Optional - Default: `10`)
169+
- Max number of retry attempts when waiting for snapshot to become available
170+
- Enabling additional Frigate features, like facial recognition, may delay availability of snapshot image
171+
- Retries are every 2 seconds
172+
- Default is 10, which means waiting up to 20 seconds for snapshot
173+
- Note: Does not apply if event received from Frigate contains `has_snapshot: false`
168174
- **notify_once** (Optional - Default: `false`)
169175
- By default, each Frigate event may generate several notifications as the object changes zones, etc
170176
- Set this to `true` to only notify once per event
@@ -191,6 +197,7 @@ alerts:
191197
snap_bbox:
192198
snap_timestamp:
193199
snap_crop:
200+
max_snap_retry:
194201
notify_once:
195202
notify_detections:
196203
audio_only:
@@ -300,6 +307,49 @@ alerts:
300307
- XYZ
301308
```
302309

310+
### Apprise-API
311+
312+
!!!important
313+
Notifications via Apprise require an external service: [https://github.com/caronc/apprise-api](https://github.com/caronc/apprise-api)
314+
315+
Please follow the instructions on the [apprise-api](https://github.com/caronc/apprise-api) repo for set up & configuration. This service exposes a REST API that Frigate-Notify uses to forward notifications to various notification providers.
316+
317+
⚠️ Not all Apprise notification providers support sending attachments. See the full list [here](https://github.com/caronc/apprise/wiki).
318+
319+
- **enabled** (Optional - Default: `false`)
320+
- Set to `true` to enable alerting via Apprise-API
321+
- **server** (Required)
322+
- Full URL of the desired [apprise-api](https://github.com/caronc/apprise-api) container
323+
- Required if this alerting method is enabled
324+
- **token** (Required - Unless `urls` is used)
325+
- Config token in apprise-api
326+
- Required if this alerting method is enabled
327+
- **urls** (Required - Unless `token` is used)
328+
- Destination Apprise URLs to forward notifications to
329+
- See supported providers & example URL formats [here](https://github.com/caronc/apprise?tab=readme-ov-file#supported-notifications)
330+
- **tags** (Optional - Required if `token` is used)
331+
- If using a config token, specify target tags to notify
332+
- **ignoressl** (Optional - Default: `false`)
333+
- Set to `true` to allow self-signed certificates
334+
- **template** (Optional)
335+
- Optionally specify a custom notification template
336+
- For more information on template syntax, see [Alert Templates](./templates.md#alert-templates)
337+
338+
```yaml title="Config File Snippet"
339+
alerts:
340+
apprise-api:
341+
enabled: false
342+
server:
343+
token:
344+
urls:
345+
- ntfy://xxxxxxxx/frigate
346+
- discord://xxxxxxxxxxx
347+
tags:
348+
- ntfy
349+
ignoressl: true
350+
template:
351+
```
352+
303353
### Discord
304354

305355
- **enabled** (Optional - Default: `false`)
@@ -467,7 +517,7 @@ alerts:
467517
### Signal
468518

469519
!!!important
470-
Signal notifications rely on an external service to handle communication to Signal: https://github.com/bbernhard/signal-cli-rest-api
520+
Signal notifications rely on an external service to handle communication to Signal: [https://github.com/bbernhard/signal-cli-rest-api](https://github.com/bbernhard/signal-cli-rest-api)
471521

472522
Please follow the instructions on the [signal-cli-rest-api](https://github.com/bbernhard/signal-cli-rest-api) repo for set up & configuration. This service exposes a REST API that Frigate-Notify uses to forward notifications to Signal.
473523

docs/config/sample.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ alerts:
4343
snap_bbox:
4444
snap_timestamp:
4545
snap_crop:
46+
max_snap_retry:
4647
notify_once:
4748
notify_detections:
4849
recheck_delay:

docs/index.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ Frigate-Notify is a simple app designed to send notifications from [Frigate](htt
2626
- SMTP
2727
- Telegram
2828
- Webhook
29+
- And many others via the [Apprise API](https://github.com/caronc/apprise-api)
2930

3031
**Other**
3132

events/reviews.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,15 @@ func processReview(review models.Review) {
101101

102102
detections = append(detections, detection)
103103
}
104+
105+
// Check to make sure at least 1 detection passed filters
106+
if len(detections) == 0 {
107+
log.Info().
108+
Str("review_id", review.ID).
109+
Msgf("Review dropped - No events eligable for notification")
110+
return
111+
}
112+
104113
// If any detection would be filtered, skip notifying on this review
105114
if reviewFiltered {
106115
log.Info().

example-config.yml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,10 @@ alerts:
8686
snap_timestamp:
8787
# Set to `true` to crop snapshot
8888
snap_crop:
89+
# Maximum number of retry attempts when pulling snapshot from Frigate at 2 second intervals
90+
# Enabling additional Frigate features, like facial recognition, may delay availability of snapshot image
91+
# By default, max_snap_retry is 10 - which means waiting up to 20 seconds for a snapshot image
92+
max_snap_retry:
8993
# By default, each Frigate event may generate several notifications as the object changes zones, etc
9094
# Set this to `true` to only notify once per event
9195
notify_once:
@@ -133,6 +137,25 @@ alerts:
133137
# List of sublabels to never generate notifications
134138
block:
135139

140+
apprise-api:
141+
# Set to true to enable alerting via Discord messages
142+
enabled: false
143+
# Server URL (ex. https://apprise.yourdomain.tld)
144+
server:
145+
# Apprise config token (or specify individual URLs below)
146+
token:
147+
# Target Apprise URL(s) (or specify a config token above)
148+
urls:
149+
- ntfy://xxxxxxxx/frigate
150+
- discord://xxxxxxxxxxx
151+
# Apprise Tags to notify (if using config token)
152+
tags:
153+
- ntfy
154+
# Set to true to allow self-signed certificates
155+
ignoressl: true
156+
# Custom notification template, if desired
157+
template:
158+
136159
discord:
137160
# Set to true to enable alerting via Discord messages
138161
enabled: false

0 commit comments

Comments
 (0)