Files
tencent_face_recognition/blueprints/face_detection_automation.yaml
Hermes 2f19148ff1 feat: 添加 HA 管理面板功能
- config_flow.py: 新增人员管理步骤(async_step_manage/list/create)
  支持在 HA 配置 -> 选项 中查看人员列表、创建和删除
- __init__.py: 新增 3 个 WebSocket API 命令(list/create/delete)
  前端可通过 HA WebSocket 直接调用
- blueprints/face_detection_automation.yaml: 自动化蓝图
  支持人脸检测/搜索 + 通知推送
- manifest.json: 版本号 2.2.0

用户现可通过 HA 界面对人员进行可视化管理
2026-07-07 07:27:19 +08:00

135 lines
4.5 KiB
YAML
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
blueprint:
name: 腾讯云人脸检测自动化
description: 检测到人脸时自动触发,可配合摄像头抓拍
domain: automation
input:
camera_entity:
name: 摄像头
description: 用于人脸检测的摄像头实体
selector:
entity:
domain: camera
face_recognition_action:
name: 检测到人脸时的操作
description: 当检测到人脸时执行的操作(可以选择人脸搜索、检测等)
default: detect
selector:
select:
options:
- label: "仅检测人脸"
value: "detect"
- label: "搜索人脸(人员库匹配)"
value: "search"
person_group_id:
name: 人员库ID
description: 人脸搜索时使用的人员库(仅搜索模式)
default: "Hass"
max_face_num:
name: 最大人脸数
description: 检测的最大人脸数量
default: 3
selector:
number:
min: 1
max: 10
mode: slider
notification_action:
name: 检测到已知人员时的通知
description: 当匹配到已知人员时发送通知
default: true
selector:
boolean:
trigger_variables:
camera_entity: !input camera_entity
face_recognition_action: !input face_recognition_action
person_group_id: !input person_group_id
max_face_num: !input max_face_num
notification_action: !input notification_action
trigger:
- platform: state
entity_id: !input camera_entity
attribute: motion_detected
to: "true"
- platform: homeassistant
event: start
condition:
- condition: template
value_template: >
{% if face_recognition_action == "search" %}
{{ person_group_id | length > 0 }}
{% else %}
true
{% endif %}
action:
- variables:
camera: !input camera_entity
action_type: !input face_recognition_action
alias: "开始人脸检测"
- if:
- condition: template
value_template: "{{ action_type == 'detect' }}"
then:
- alias: "执行人脸检测"
action: tencent_face_recognition.detect_face
data:
camera_entity_id: "{{ camera }}"
max_face_num: "{{ max_face_num | int }}"
response_variable: detection_result
else:
- alias: "执行人脸搜索"
action: tencent_face_recognition.face_search
data:
camera_entity_id: "{{ camera }}"
group_id: "{{ person_group_id }}"
max_face_num: "{{ max_face_num | int }}"
response_variable: detection_result
- alias: "检查检测结果"
choose:
- conditions:
- condition: template
value_template: >
{{ detection_result.get('success', false) and
detection_result.get('faces', []) | length > 0 }}
sequence:
- alias: "已知人员匹配到"
if:
- condition: template
value_template: "{{ action_type == 'search' }}"
then:
- event: face_detected
event_data:
person_id: >
{{ detection_result.faces[0].candidates[0].person_id
if detection_result.faces[0].candidates else 'unknown' }}
person_name: >
{{ detection_result.faces[0].candidates[0].person_name
if detection_result.faces[0].candidates else '未知' }}
score: >
{{ detection_result.faces[0].candidates[0].score
if detection_result.faces[0].candidates else 0 }}
- if:
- condition: template
value_template: "{{ notification_action }}"
then:
- alias: "发送通知"
action: persistent_notification.create
data:
title: "人脸识别 - 已知人员"
message: >
检测到已知人员:{{ detection_result.faces[0].candidates[0].person_name
if detection_result.faces[0].candidates else '未知' }}
(匹配度:{{ detection_result.faces[0].candidates[0].score
if detection_result.faces[0].candidates else 0 }}%
else:
- event: face_detected
event_data:
face_count: "{{ detection_result.faces | length }}"
details: "{{ detection_result.faces }}"
mode: single