Check who scanned Home Assistant NFC tag and run action or fire a custom event if that person is on the list of allowed users.
Running an action:
Firing custom event:
check comments, because I’m a new user and I can’t embed more than 1 media
What’s inside?
Both automations have two variables in them:
- user_id — ID of the user, who scanned the tag
- user_name — Human readable name of that user
Which can be used like so in the action:
action: notify.notify
data:
message: "{{ user_name }} scanned NFC tag {{ trigger.event.data.name }}"
In the case of custom event, its fields would looks something like this:
event_type: custom_tag_scanned
data:
tag_id: test
tag_name: Test
device_id: xxxx
user_id: xxxx
user_name: admin
origin: LOCAL
time_fired: "1970-01-01T00:00:00.000000+00:00"
context:
id: XXXX
parent_id: XXXX
user_id: null