@gekagal I assume you mean recognition confidence? If I understood you correctly, then I implemented it like this. If the confidence is higher than I indicated, then the name is displayed in the sensor
I created an auxiliary element input_number.deepstack_confidence_face for confidence and can change the confidence level directly in the GUI without making edits in the code
A sensor that displays the name based on the set value for confidence and has more attributes. If the identified name is below the specified confidence, it will be unknown, if higher, it will show the name. This sensor can be used in automation
sensor:
- platform: template
sensors:
persons_names_hall:
friendly_name: 'Names of identified persons'
icon_template: mdi:face-recognition
value_template: >
{% set detect_face = state_attr('image_processing.detect_face_eufy_camera','faces') | selectattr('faces','!=','name')| map(attribute='name') | join(', ') %} #specify your sensor
{% set confidence_face = state_attr('image_processing.detect_face_eufy_camera','faces') | selectattr('faces','!=','confidence')| map(attribute='confidence') | join(', ') %} #specify your sensor
{% set set_confidence = states('input_number.deepstack_confidence_face')%} #specifying our auxiliary element input_number
{% if detect_face and confidence_face >= set_confidence %}
{{ state_attr('image_processing.detect_face_eufy_camera','faces') | selectattr('faces','!=','name')| map(attribute='name') | join(', ') }} #specify your sensor
{% elif detect_face and confidence_face <= set_confidence %} unknown
{% endif %}
attribute_templates:
faces: "{{ state_attr('image_processing.detect_face_eufy_camera','faces') }}" #specify your sensor
total_faces: "{{ state_attr('image_processing.detect_face_eufy_camera','total_faces') }}" #specify your sensor
total_matched_faces: "{{ state_attr('image_processing.detect_face_eufy_camera','total_matched_faces') }}" #specify your sensor
matched_faces: "{{ state_attr('image_processing.detect_face_eufy_camera','matched_faces') }}" #specify your sensor
last_detection: "{{ state_attr('image_processing.detect_face_eufy_camera','last_detection') }}" #specify your sensor
friendly_name: "{{ state_attr('image_processing.detect_face_eufy_camera','friendly_name') }}" #specify your sensor
device_class: "{{ state_attr('image_processing.detect_face_eufy_camera','device_class') }}" #specify your sensor
And also made a sensor that shows your own or someone else’s. In the whitelist list, we specify the names of our household members and if there are only our own names in the list when determining, it will be determined as our own, and if there is unknown among the identified names in the list, then there will be someone else’s. For example, there are 3 people in front of the camera, if the sensor showed the names: Angela, Peter, Boris, then these are their own, and if there is Angela, Peter, unknown, then it will show that there is someone else
- platform: template
sensors:
identified_person_owner_of_the_house_hall:
friendly_name: 'Is the identified person the owner of the house?'
icon_template: mdi:face-recognition
value_template: >
{% set persons = "sensor.persons_names_hall" %} #specify your sensor
{% set detect_face = states("image_processing.detect_face_eufy_camera") %} #specify your sensor
{% set whitelist = ["Angela", "Peter", "Boris"]|join('|') %} #we indicate the names of our household
{% set blacklist = ['unknown']|join('|') %} #leave it as it is
{% set authorized_persons = states("sensor.persons_names_hall")|string is search(find=whitelist, ignorecase=True) %} #specify your sensor
{% set unauthorized_persons = states("sensor.persons_names_hall")|string is search(find=blacklist, ignorecase=True) %} #specify your sensor
{% if detect_face != "unknown" and authorized_persons == True and unauthorized_persons == False %} All your own
{% elif detect_face != "unknown" and authorized_persons == True and unauthorized_persons == True %} There is someone else's face
{% elif detect_face == "unknown" %} off
{% endif %}
Текст на русском (Text in Russian)
Предполагаю, что вы имеете ввиду уверенность распознавания? Если я верно вас понял, то я реализовал вот так. Если уверенность выше, чем я указал, то в сенсоре отображается имя
Я создал вспомогательный элемент input_number.deepstack_confidence_face для уверенности и могу изменить уровень уверенности прямо в GUI не внося правки в коде
Сенсор, который отображает имя исходя выставленному значению для уверенности и имеет еще атрибуты. Если опознанное имя будет ниже указанной уверенности, то будет неизвестно, если выше, то покажет имя. Этот сенсор можно использовать в автоматизации
sensor:
- platform: template
sensors:
persons_names_hall:
friendly_name: 'Коридор: Имена идентифицированных лиц'
icon_template: mdi:face-recognition
value_template: >
{% set detect_face = state_attr('image_processing.detect_face_eufy_camera','faces') | selectattr('faces','!=','name')| map(attribute='name') | join(', ') %} #указываем свой сенсор
{% set confidence_face = state_attr('image_processing.detect_face_eufy_camera','faces') | selectattr('faces','!=','confidence')| map(attribute='confidence') | join(', ') %} #указываем свой сенсор
{% set set_confidence = states('input_number.deepstack_confidence_face')%} #указываем свой вспомогательный элемент input_number
{% if detect_face and confidence_face >= set_confidence %}
{{ state_attr('image_processing.detect_face_eufy_camera','faces') | selectattr('faces','!=','name')| map(attribute='name') | join(', ') }}#указываем свой сенсор
{% elif detect_face and confidence_face <= set_confidence %} unknown
{% endif %}
attribute_templates:
faces: "{{ state_attr('image_processing.detect_face_eufy_camera','faces') }}" #указываем свой сенсор
total_faces: "{{ state_attr('image_processing.detect_face_eufy_camera','total_faces') }}"#указываем свой сенсор
total_matched_faces: "{{ state_attr('image_processing.detect_face_eufy_camera','total_matched_faces') }}" #указываем свой сенсор
matched_faces: "{{ state_attr('image_processing.detect_face_eufy_camera','matched_faces') }}" #указываем свой сенсор
last_detection: "{{ state_attr('image_processing.detect_face_eufy_camera','last_detection') }}" #указываем свой сенсор
friendly_name: "{{ state_attr('image_processing.detect_face_eufy_camera','friendly_name') }}" #указываем свой сенсор
device_class: "{{ state_attr('image_processing.detect_face_eufy_camera','device_class') }}" #указываем свой сенсор
А также сделал сенсор, который показывает свой или чужой. В списке whitelist указываем имена своих домочадцев и если при определении в списке будут только свои имена, то будет определено как свои, а если в списке будет unknown среди опознанных имен, то будет отображать есть чужой. Например перед камерой находятся 3 человека, если сенсор показал имена: Ольга, Петр, Борис, значит это свои, а если будет Ольга, Борис, unknown, значит покажет, что есть чужой
- platform: template
sensors:
identified_person_owner_of_the_house_hall:
friendly_name: 'Коридор: Опознанное лицо является ли хозяином дома?'
icon_template: mdi:face-recognition
value_template: >
{% set persons = "sensor.persons_names_hall" %} #указываем свой сенсор
{% set detect_face = states("image_processing.detect_face_eufy_camera") %} #указываем свой сенсор
{% set whitelist = ["Ольга", "Петр", "Борис", "Маша"]|join('|') %} #указываем имена своих домочадцев
{% set blacklist = ['unknown']|join('|') %} #оставляем как есть
{% set authorized_persons = states("sensor.persons_names_hall")|string is search(find=whitelist, ignorecase=True) %} #указываем свой сенсор
{% set unauthorized_persons = states("sensor.persons_names_hall")|string is search(find=blacklist, ignorecase=True) %} #указываем свой сенсор
{% if detect_face != "unknown" and authorized_persons == True and unauthorized_persons == False %} Все свои
{% elif detect_face != "unknown" and authorized_persons == True and unauthorized_persons == True %} Есть чужое лицо
{% elif detect_face == "unknown" %} off
{% endif %}