0x2142 / frigate-notify

Event notifications for a standalone Frigate NVR instance
https://frigate-notify.0x2142.com/
MIT License
78 stars 6 forks source link

Add more filter criteria for alerting #107

Closed digcre closed 2 weeks ago

digcre commented 1 month ago

First things first, thanks for this amazing hassle free implementation and that I can avoid a enormous Home Assistant / HACS / Plugins / Notification setup with 30 moving parts !

Is your feature request related to a problem? Please describe. What I would like to have is more grained filter options when to alert. As you can see in my screenshot I'm filtering by label=person, as this is a crowded place I dont want to get any notifications on day time. I'm using frigate with a Coral TPU and want to benefit from the detector information.

Describe the solution you'd like

Additional context image

freefd commented 1 month ago

Hi @digcre,

add more parameters to labels like probability >80%

Trying to identify suitable keys from the example event:

{
    "after": {
        "id": "1715933215.305115-umg80m",
        "camera": "CameraNameGoesHere",
        "frame_time": 1715933220.702879,
        "snapshot": {
            "frame_time": 1715933215.906813,
            "box": [1227, 328, 2209, 1924],
            "area": 1567272,
            "region": [0, 0, 3072, 3072],
            "score": 0.84375,
            "attributes": []
        },
        "label": "person",
        "sub_label": null,
        "top_score": 0.837890625,
        "false_positive": false,
        "start_time": 1715933215.305115,
        "end_time": null,
        "score": 0.76953125,
        "box": [1048, 196, 1722, 943],
        "area": 503478,
        "ratio": 0.9022757697456493,
        "region": [971, 113, 1863, 1005],
        "stationary": false,
        "motionless_count": 4,
        "position_changes": 1,
        "current_zones": [],
        "entered_zones": [],
        "has_clip": true,
        "has_snapshot": true,
        "attributes": {},
        "current_attributes": []
    }
}

current_zones, entered_zones, label and has_snapshot are already supported.

Let's say, it would be useful to add filtering by:

  1. top_score mentioned by you;
  2. sub_label mentioned in https://github.com/0x2142/frigate-notify/issues/102;
  3. attributes and/or current_attributes - https://github.com/blakeblackshear/frigate/blob/dev/docs/docs/integrations/mqtt.md?plain=1#L80-L91
  4. stationary - https://docs.frigate.video/configuration/stationary_objects/, not sure whether the motionless_count and position_changes should also be involved here;
  5. false_positive - https://github.com/blakeblackshear/frigate/issues/8294#issuecomment-1776495323, https://docs.frigate.video/plus/improving_model/;

add a time range to filter detection time and only notify after 10pm until 6am for example

I also thought about this feature called "quiet hours" or "silent hours", but eventually considered this as client OS feature with scheduled DND, where the client application (Ntfy, Telegram, etc.) respects that DND flag. In this way the Frigate will keep recording, frigate-notify will send detected events, but your client will be silent.

The 2nd option is to allow frigate-notify control the camera recording over MQTT (or WebSocket API) to disable it for a certain amount of time. Disable recording:

{
    "topic": "<camera_name>/recordings/set",
    "payload": "OFF",
    "retain": true
}

Enable recording:

{
    "topic": "<camera_name>/recordings/set",
    "payload": "ON",
    "retain": true
}
0x2142 commented 1 month ago

Sounds good. I'm happy to look into adding some of these options.

I'm still on a short break (#104) from this project & my dev setup is offline. Hoping to start working on this again closer to the end of the month.

0x2142 commented 2 weeks ago

Hi there - Just letting you know this was added in v0.3.3. Here's the docs for quiet hours and minimum label score