From 2db48814a819aa7de7460df90d0189cb88f7f0c5 Mon Sep 17 00:00:00 2001 From: thomas Date: Sat, 30 Aug 2025 12:11:15 +0000 Subject: [PATCH] =?UTF-8?q?blueprints/automation/set-person-from-nfc.yaml?= =?UTF-8?q?=20hinzugef=C3=BCgt?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../automation/set-person-from-nfc.yaml | 44 +++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 blueprints/automation/set-person-from-nfc.yaml diff --git a/blueprints/automation/set-person-from-nfc.yaml b/blueprints/automation/set-person-from-nfc.yaml new file mode 100644 index 0000000..fcdf12a --- /dev/null +++ b/blueprints/automation/set-person-from-nfc.yaml @@ -0,0 +1,44 @@ +blueprint: + name: Set Person from NFC Tag + description: > + Sets a person selector helper to the name of the person whose tag was scanned. + This replaces the need for an individual automation for each person. + + domain: automation + + input: + person_selector: + name: Person Selection Helper + description: The input_select helper to set for the current person. + selector: + entity: + domain: input_select + person_tag_map: + name: Person Tag Mapping + description: 'A list of person NFC tag IDs and their names, e.g., ''- tag_id: "tag_123" name: "John"''' + selector: + object + +trigger: + - platform: event + event_type: tag_scanned + +condition: + # Check if the scanned tag ID exists in the provided map + - condition: template + value_template: "{{ trigger.event.data.tag_id in person_tag_map | map(attribute='tag_id') | list }}" + +action: + # Find the name that corresponds to the scanned tag ID + - variables: + person_name: > + {% set tag_id = trigger.event.data.tag_id %} + {% set matched_entry = person_tag_map | selectattr('tag_id', 'equalto', tag_id) | first %} + {{ matched_entry.name }} + + # Set the input_select helper to the found name + - service: input_select.select_option + target: + entity_id: !input person_selector + data: + option: "{{ person_name }}" \ No newline at end of file