blueprints/automation/set-person-from-nfc.yaml hinzugefügt
This commit is contained in:
44
blueprints/automation/set-person-from-nfc.yaml
Normal file
44
blueprints/automation/set-person-from-nfc.yaml
Normal file
@@ -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 }}"
|
||||||
Reference in New Issue
Block a user