blakeblackshear / frigate

NVR with realtime local object detection for IP cameras
https://frigate.video
MIT License
19.02k stars 1.74k forks source link

Expose Review:Alert/Detection settings to MQTT so they can be enabled/disabled via home assistant #13038

Open Jurykov opened 2 months ago

Jurykov commented 2 months ago

Describe what you are trying to accomplish and why in non technical terms My cameras are setup to detect and record 24/7, but I'm really only interested in reviewing events that happen when no-one is home. It would be nice to be able to not have to acknowledge hundreds of Alerts and Detections in the review section, when I'm only interested in Alerts that happen during certain time periods. I'd still like to record any events for potential review later if something unusual happens, so I'm not interested in disabling detection completely, but it would be nice to flag items as Alerts, only if certain conditions are met.

Describe the solution you'd like My Home assistant instance tracks when people leave, and arrive. It could enable/disable alerts appropriately if these settings were exposed to MQTT like RECORDINGS, DETECT, MOTION, etc. are.

Describe alternatives you've considered Again, I could disable detections completely when no one is home, but then I would lose the flagging of person, dog, and so on in the review tab. It sounds like per user reviews are coming in a later version. Perhaps there could be some more granularity in the settings as to what is an Alert or Detection per user?

mavacpjm commented 2 months ago

I second this request, would be awesome to have this additional functionality with conditions to alert...

phoenixtechnam commented 2 months ago

I also support this. But instead of defining time frames I would couple it with Home Assistant's Alarm Control Panel, e.g. only create Alerts when the Alarm Control Panel is in a specific state, e.g. "Armed Home", independent of the alarm actually being triggered by that alert.

Jurykov commented 2 months ago

I also support this. But instead of defining time frames I would couple it with Home Assistant's Alarm Control Panel

Exactly. Not based on time frames, but based on when no one is home, e.g. when the alarm in home assistant is turned on. If this was exposed either via mqtt, or an API it could be toggled appropriately from a home assistant automation.

I'm just getting too many 'alerts' from Frigate in the review panel to be useful. I'm trying to work out some way to better filter them so I don't see hundreds of alerts of me walking around my house in the evening. Maybe the solution is to just disable detections completely when I'm home, but then I'd lose some data that is potentially useful to me.

MintyTrebor commented 2 months ago

A quick thought: Is it possible to set up 2 different configurations for the same camera feed, one with alerts enabled the other without, then swap between disabling record/detect/motion on the "alerting" camera config, and enabling record/detect/motion on "non alerting" camera according to the trigger/scenario you need?

d-steve commented 2 months ago

I definitely want this for similar reasons: using Home Assistant to only enable certain alerts/detections at night or when away.

Best workaround I’ve found is to run an automation in Home Assistant to mark as read (or delete) for new review items that fall outside the desired criteria.

Create a rest_command in HA configuration.yaml (or use a curl command) to mark an ID as reviewed:

rest_command:
  frigate_mark_reviewed:
    url: 'http://<frigate>:5000/api/reviews/viewed'
    method: POST
    payload: '{ "ids": ["{{ id }}" ] }'
    content_type: 'application/json; charset=utf-8'

Then an automation:

alias: Frigate mark as reviewed
description: ""
trigger:
  - platform: mqtt
    topic: frigate/reviews
  - condition: template
    value_template: >-
      {{ trigger.payload_json['after']['severity'] == 'detection' and
      trigger.payload_json['type'] == 'end' }}
action:
  - service: rest_command.frigate_mark_reviewed
    metadata: {}
    data:
      id: "{{ trigger.payload_json['after']['id'] }}"
mode: single

Where you can modify the conditions as needed based on sensor status, time of day, review item attributes, etc.