Using NFC tag last scanned in templates

That’s what I was trying to replicate from dev states…perfect thx

1 Like

You’re welcome!

If you believe my suggestion fulfills your Feature Request, please consider marking my post above with the Solution tag. It will automatically place a check-mark next to the topic’s title which signals to other users that this topic has been resolved. This helps users find answers to similar questions (or Feature Requests).

For more information about the Solution tag, refer to guideline 21 in the FAQ.

1 Like

Yeah, I don’t remember the exacts, but the simple forward way didn’t work (reliably) for some reason back then.
I use a mix of external NFC readers (ESP-Home) and the build in the phone one, i always had so scan twice or three times before the template switch would update if i scanned from a different device then the last one.
anyway, good to hear the straight forward way now works.

You can name/rename tags under the config → tag tab

then the cogwheel at the end:

other than being more recognizable than the codes this doesn’t make it a usable entity…

For the last_scanned part see excellent suggestions in this thread.
You would have to create some template sensors

Yeah definitely will mark post :+1:
Have one little issue I can’t resolve is getting time format
(month, day, year hour : min) only.
Nothing seems to work, I hate to keep bugging you over this. But sometimes that little stuff gets me. :rofl:
Hey thanks for all your help… I guess walking away helped!!! got to work
Again, thanks for all your hard work.
For some reason I don’t see the solved check box

1 Like

No worries. I thought you were the author of this topic. Only the topic’s author can mark a post with the Solution tag.

OH yeah that’s right .lol
You’re awesome appreciate the hell out of it

If anyone wants to see… this is end results
Apothecary Card


This should get you where you need to go

input-boolean
  vitamins_taken:
    name: Vitamins
    icon: mdi:pill-multiple
    # icon: mdi:pill

# Automations
## Meds ##
  - alias: med1_Med
    description: 'Daily'
    trigger:
    - platform: tag
      tag_id: 88b98f79-c6d8-4bd7-bd1d-d74d4368ca75
    action:
    - service: input_boolean.turn_on
      data:
        entity_id: input_boolean.med1_taken
## Resets ##
  - alias: Reset med1
    trigger:
    - platform: time
      at: "00:00:01"
    action: 
    - service: input_boolean.turn_off
      data:
        entity_id: input_boolean.med1_taken
        
# Template
## NFC_Scraping ##
  - trigger:
      - platform: event
        event_type: tag_scanned
    sensor:
      - name: NFC_LastTag_Scanned
        state: '{{ trigger.event.data.tag_id }}'
      - name: NFC_LastTime_Scanned
        state: '{{ trigger.event.time_fired }}'
## Date ##
  - trigger:
      - platform: tag
        tag_id: 88b98f79-c6d8-4bd7-bd1d-d74d4368ca75
    sensor:
      - name: NFC_med1_Date 
        state: "{{ as_timestamp(states('sensor.date_time_iso')) | timestamp_custom('%a %B %-d, %I:%M %p') }}"
        icon: "mdi:calendar-clock"

Thank you much @123 Taras so apreci!!

1 Like

If you’re interested, you can replace this:

{{ as_timestamp(states('sensor.date_time_iso')) | timestamp_custom('%a %B %-d, %I:%M %p') }}

with this:

{{ now().strftime('%a %B %-d, %I:%M %p') }}
1 Like

Retried that string and works this time… I guess it was my formatting before
thanks makes it simpler!