Skip to content

dispatch event when an unknown face is detected#1362

Open
snaquaye wants to merge 4 commits into
roflcoopter:devfrom
snaquaye:feature/unknown_face_detected_event
Open

dispatch event when an unknown face is detected#1362
snaquaye wants to merge 4 commits into
roflcoopter:devfrom
snaquaye:feature/unknown_face_detected_event

Conversation

@snaquaye

Copy link
Copy Markdown

No description provided.

Copilot AI review requested due to automatic review settings May 21, 2026 22:28
@netlify

netlify Bot commented May 21, 2026

Copy link
Copy Markdown

Deploy Preview for viseron canceled.

Name Link
🔨 Latest commit 33fe30d
🔍 Latest deploy log https://app.netlify.com/projects/viseron/deploys/6a10e175373f950008d66b8b

@snaquaye snaquaye changed the title dispatch event when an unknown face is found dispatch event when an unknown face is detected May 21, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds event dispatching for unknown face detections in the face recognition domain so consumers can react to “unknown” faces similarly to recognized faces.

Changes:

  • Dispatch EVENT_FACE_DETECTED when an unknown face is found.
  • Include EventFaceDetected payload for unknown face events.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +229 to +237
self._vis.dispatch_event(
EVENT_FACE_DETECTED.format(
camera_identifier=self._camera.identifier, face=UNKNOWN_FACE
),
EventFaceDetected(
camera_identifier=self._camera.identifier,
face=face_dict,
),
)
@roflcoopter

Copy link
Copy Markdown
Owner

Thank you!
As the Copilot review pointed out, this will make the binary sensor always show on after an unknown face has been detected.

Any specific reason you didnt make it expire like known faces?

@snaquaye

Copy link
Copy Markdown
Author

I'm new to Viseron and python and wasn't aware of that timer. I will implement that now and update my PR

snaquaye added 2 commits May 23, 2026 00:05
Mirror known_face_found behavior: cancel any existing timer for
UNKNOWN_FACE, start the new expiry timer, save the snapshot only once
until expired, and store the face dict in self._faces so that
expire_face(UNKNOWN_FACE) can properly emit EVENT_FACE_EXPIRED without
raising a KeyError.

if self._config[CONFIG_SAVE_UNKNOWN_FACES]:
# Only store face once until it is expired
if (

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it is best to revert this if statement since this would be a change in behaviour.

Before the change, every unknown face would be stored.
After the change, only one unknown face would be saved until the expiry timer hits.

Otherwise i think it looks good! If you can fix that i can merge this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants