Is there any way to know what user scanned a NFC tag with home assistant?


I would like to know if there is any way to know what device scanned the NFC tag.
for example:
A user scans the tag with their phone, i want that to then trigger an event that says "welcom home ‘user’ " but then if another user scans it i would like it to say their name.

I should also add i am relitivly new to HASS

tag_scanned event provides output similar to following:

    "event_type": "tag_scanned",
    "data": {
        "tag_id": "93182830-f2c9-4557-9ffa-94ebce875b19",
        "device_id": "E6Axxxxxxxxxxxxxxxxxxx0D2"
    "origin": "LOCAL",
    "time_fired": "2021-11-07T08:05:51.119693+00:00",
    "context": {
        "id": "645a4fb060f5155b7ef658e0c3f8f97c",
        "parent_id": null,
        "user_id": "3df1eccaaa654858b72e6d942ecc39e0"

You test trigger for for either device_id to identify specific device that was used to scan NFC or user_id to identify user (though this would be user associated with the device, so result woul dbe the same…

Here is sample automation that can be triggered only by specific tag and specific device (so effectively associates this automation to specific user):

- alias: 'Toggle lights on NFC'
  initial_state: true
    platform: event
    event_type: tag_scanned
      tag_id: 93182830-f2c9-4557-9ffa-94ebce875b19
      device_id: E6Axxxxxxxxxxxxxxxxxxx0D2
    service: light.toggle
    entity_id: light.mirek_office

this template will print the friendly name for the user from the event

{% set person = states.person|selectattr('attributes.user_id', 'eq', trigger.event.context.user_id)|first %}{{ person.attributes.friendly_name }}