Expose face recognition from Unifi Protect integration

The Unifi Protect integration is amazing. The person and object detection exposed through sensors effectively makes PIR motioni sensors obsolete and are also a great solution for presence. This is huge!

Unifi’s latest AI cameras do on-camera face detection and have a great UI for face recognition, training, and matching. If this capability could be exposed through the integration, in the same style as the double-take integration for Frigate, we would be able to do things like:

  • Supress outdoor motion alerts for known people
  • Auto unlock or welcome
  • Person-specific presence routines

and so much more. Please give us access to the Unifi Protect face recognition features in HA.

Would be a great addition. In the meantime you could use the new alarm manager and webhooks in the latest EA version of protect. It does have triggers on known faces

1 Like

Just a note, I’ve been screwing around with this and it is promising but not of any practical usefulness is of limited usefulness because the parameters for the webhook API have not been documented. AFAICT there is not a way to know that a particular face has been detected, for example. Let me know if you come up with any other information. Thanks!

hey mrechs,

the webhook call from unifi protect set to a post, actually sends the info which known face was recognised. Can be used with a value template un an automation.

if your interested let me know I can post the details.

Boris

Certainly interested! Is this documented anywhere?

alias: Boris Eingang Detection
description: ""
triggers:
  - allowed_methods:
      - POST
      - PUT
      - HEAD
    local_only: true
    webhook_id: "xxxxxxxxxxxxxxxxxxxxx"
    trigger: webhook
conditions:
  - condition: template
    value_template: "{{ trigger.json.alarm.triggers[0].value == 'Boris' }}"
actions:
1 Like
  1. Create an automation with trigger webhook in HA. copy out the webhook ID generated or create your own.

  2. Unifi protect create an Alarm, new alarm. Choose devices and recognition type that trigger the alarm. obviously it will have to be face recognition. Section action choose webhook and enter.
    http://192.168.1.102:8123/api/webhook/xxxxxxxxxxxxxxxxxx. Instead of xxxxxx you webhook ID

  3. Protect sends several variables including the name of the person detected. You can filter that with the following:

value_template: “{{ trigger.json.alarm.triggers[0].value == ‘Boris’ }}” this value temple will filter for the name Boris or who ever is Known in the Protect DB.

2 Likes

btw this Automation a webhook debugger helped me to see what protect actually sends in the webhook. you can filter for several other variables.

Oh there is one more issue. For some reason unifi protect only acts on a recognised face at the end of smart detection, think same goes for licenses plates. So standing infront of the cam and waiting for the webhook finally to trigger won’t work. The detection event/process has to stop.

Not happy with it, but I did a messy workaround by defining Smart detection zones. Stepping out of the zone ends the event and sends the webhook.

3 Likes

Boris, you’re my hero. I’m going to get to work on my own Boris detection here. Thank you.

Hey Boris /Mrechs
did you have joy with his - Im a relative newbie bur have all the gear to activate it but im unsure of the webhook basics ( cant seem to make it work )

any tips for a newbie appreciated

thanks

Hi all,

Thank you kindly @borisA for all the pointers!

I just wanted to mention for anyone else trying to do this, you may have to slightly modify the Jinja to:

{{ trigger.json.alarm.triggers[0].value }}

Unifi is passing back an array in the “triggers” key’s value, where the first element (it’s usually of size 1) is the device that spotted the person.

The above syntax is working for me.

Cheers
Matt

Hey Mckrick, yes it’s working nicely for me. Dont use my keys anymore :slight_smile: to enter the flat. If you can explain your problem to me, I might be able to help you. You have to configure in the protect alarm manger a webhook action first and then an automation in HA that gets trigger by the webhook. The actual url and webhook ID is defined by HA though. how far did you get ?