Frigate per object motion detection

Hi all, wondering if anyone can help point in the right direction -
Frigate comes with a general motion binary sensor, and object presence sensors, but I would like to have per-object motion detection. Use case being to trigger a light in the yard for humans and cars but not general motion or animals etc. I can’t use the presence sensors as a parked car will keep the light on.
I’ve searched a lot on the topic but much of the info is outdated(and difficult to google given they only recently changed the sensors to be called “presence”).

It’s been hinted that this would be possible using frigate mqtt events but I’m not sure how?
Would appreciate any pointers if anyone has something similar working already.

You could have the on trigger be the person count and car count sensor increasing or the person/car occupancy changing to active. Then you could use the person count going back to 0 as an off trigger and also have a 10 minute timer or something if only the car count is still above 0. It would be pretty flexible but i’d probably do it with two automations. one for off and one for on. The off automation would be triggered by the on automation or by the state of the light turning on, then have built in wait trigger or timer before turning the light off.

Thanks for the suggestions, will certainly look into that road if it’s not possible with the mqtt sensors.

Edit: the reason being if I use the existing count sensors, a car parked in the drive overnight could be lost by frigate and detected again multiple times, causing false triggers. If its possible to have an mqtt sensor trigger only on non-stationary objects, that seems like the better route?

I have found a solution, or at least a start:

    - name: "Front Yard Person Motion"
      device_class: motion
      off_delay: 2
      state_topic: "frigate/events"
      value_template: >
        {% if (value_json['after']['camera'] == 'camera1') and (value_json['after']['label'] == 'person') and (value_json['after']['stationary'] == false) %}
        {% else %}
        {% endif %}

If anyone had any suggestions to improve this, particularly how to handle the “off” state, it’d be much appreciated.

Having the same issue, I wrote a small program that monitors the frigate events in mqtt and publishes sensors for motion and stationary status and object counts for every label and every camera. This solves the issue of off detection because it tracks the event id from frigate and sees when tracked events end.

1 Like

Great, thanks for sharing, will take a look into this.
I’ve been living with lots of false triggers and often hung lights since but been too busy to follow up. This could be ideal!

If you run into any issues, feel free to submit a github issue.

I just did a bit of refactoring to make it easier get zone info and write templates to avoid some false positives myself. Check the release notes for v0.0.2 for an example template.