Home Assistant Tags

Thx, @adonno - NFC reader has been delivered!

1 Like

@adonno I’m a happy user of your tag reader solution and thanks a lot for your work and effort.
I have a problem that I could not resolve or, maybe, I didn’t understand how it works.

Prerequisites
a. Wemos D1 mini
b. PN RFID 532
c. Card & tag, 13.56 MHz
d. master branch pn532_i2c

Use case
I want to use my Huawei Mate 20 Pro as an NFC Tag

What I did

  1. Open Home Assistant Companion which is logged in at HA instance
  2. NFC Tag option from Settings
  3. Write Tag on White Card
  4. Returning results
- platform: event
  event_type: tag_scanned
  event_data:
    device_id: 93d872ca49dfe4d7
    tag_id: ce1685b2-0bdf-4786-bea4-39caa49c4035
  1. Fire event button
  2. Check if ce1685b2-0bdf-4786-bea4-39caa49c4035 is displayed in Tags from configuration
  3. Make the following automation in automation.yaml
- alias: "Huawei NFC Access"
  initial_state: True
  mode: single
  trigger:
  - platform: event
    event_type: tag_scanned
    event_data:
      device_id: 93d872ca49dfe4d7
      tag_id: ce1685b2-0bdf-4786-bea4-39caa49c4035
  action:
    - service: switch.toggle
      entity_id: switch.shelly_1pm
  1. Reload automation
  2. Swipe Huawei Phone

Expected results

  1. The bulb must be switched on

Actual results

  1. The bulb is not light on and a new entry is created in Tags
  2. Huawei and White Card still have different identificators

More actions

  1. Go To events and listen tag_scanned
  2. Scan Huawei and White Card
    –> “device_id”: bf45cac435a56ede5256ea83fed4f9c0 is the same for both.
    –> tag id is different than the id created with HA Companion
    –> device_id is different than the id created with HA Companion


3. Go to automation and at device_id paste bf45cac435a56ede5256ea83fed4f9c0 value

New automation code excluded tag_id

- alias: "Huawei NFC Access Device ID"
  initial_state: True
  mode: single
  trigger:
  - platform: event
    event_type: tag_scanned
    event_data:
      device_id: bf45cac435a56ede5256ea83fed4f9c0
    #   tag_id: ce1685b2-0bdf-4786-bea4-39caa49c4035
  action:
    - service: switch.toggle
      entity_id: switch.shelly_1pm
  1. Reload automation
  2. Swipe White Card --> the bulb is switching ON
  3. Swipe Huawei --> the bulb is switching ON
  4. Check Tags from HA
    New Tag is created for Huawei
  5. Swipe Huawei again
    New Tag is created for Huawei

Expected results
Huawei and White card should be considered one entity
When I write a new card

      device_id: 93d872ca49dfe4d7
      tag_id: ce1685b2-0bdf-4786-bea4-39caa49c4035

must be used in automation in order to make two entities to act as one


More Testing

  1. Go To HA companion and read White Card
    –> results
- platform: event
  event_type: tag_scanned
  event_data:
    device_id: 93d872ca49dfe4d7
    tag_id: ce1685b2-0bdf-4786-bea4-39caa49c4035
  1. Make the following automation
- alias: "Huawei NFC Access"
  initial_state: True
  mode: single
  trigger:
  - platform: event
    event_type: tag_scanned
    event_data:
      device_id: 93d872ca49dfe4d7
      tag_id: ce1685b2-0bdf-4786-bea4-39caa49c4035
  action:
    - service: switch.toggle
      entity_id: switch.shelly_1pm
  1. Fire the event directly from the HA companion / Button Fire Event
    –> The bulb is switching ON and OFF
    –> Verify-in Tags if ce1685b2-0bdf-4786-bea4-39caa49c4035 was used == yes
  2. Swipe Huawei in order to obtain the same result
    –> a new tag is created
    –> the bulb remains switched off

In conclusion
if I used Fire Event button directly from HA companion the phone trigger the action and in TAGS is used the device id which was created, but if I put the same values in the automation I am not able to obtain the same behavior

2 Likes

Hi, is that working ?

Has anyone tried to read an NFC tag with the HA iOS Companion App on an iPhone 12 Pro? I can’t seem to get it to read or write any card or tag. My HA Tag Reader picks up all my cards and tags fine however.

What NFC tags are you trying to scan? Not all will work on a mobile especially the lower frequency cards and the keyring tags. NTAG are 13.56 MHz tags and pretty much all NFC enabled phones can read/write to them. If you stick to the NTAG type tags you should be ok.

1 Like

It was the card and keyring tag that came with my HA Tag Reader…so I figured there wouldnt be an issue. I ended up ordering another set of cards off Amazon and they worked…strange!

actually, on the order page, it is stated that these cards are read-only. Apparently only under iOS read-only

Don’t ask me why unfortunately I get them like that

Still working on it, it requires changes to the esphome source code in c, and my free time is… minimal

Hi
Already some time ago, but I have the same problem

iPhone Shortcuts setup reads NFC perfectly.
Shortcuts automation itself afterwards also recognizes tag an triggers events.

The tag reader for Home Assistant also recognizes the tag

But HomeAssistant App can not read the tag.
iPhone SE 2020, ios 14.2, HomeAssistant App 2020.7

Any ideas ? Is this a bug ? Or an oversight from my part ?

Greets
Arnout

Have you written to the TAG first with HA? It needs to format it from within the app first before it can read it.

Hi, sorry for the noob question. I am brand new to this.
I have setup my home assistant on my Raspberry PI.
I have added the jukebox YAML.
I have my tagreader (thanks adonno), connected to Home Assistant and it reads the tags I scan.
But now I am lost. How do I actually make the jukebox work? I guess I need to associate events to the tags I scan, but how does it actually make the jukebox start playing the spotify song or album on the device I want?

My question is has someone made a step by step guide for making this work?
Thanks for any help you can provide.

You will need to create a script which selects a playlists depending on which tag was scanned.

Something similar to this would work:

script:
  internet_radio:
    alias: Play Internet Radio
    sequence:
    - service: media_player.volume_set
      data_template:
        entity_id: >
          {% if is_state("input_select.chromecast_radio", "Lounge") %} media_player.lounge_speakers
          {% elif is_state("input_select.chromecast_radio", "Bedroom") %} media_player.bedroom
          {% elif is_state("input_select.chromecast_radio", "Everywhere") %} media_player.everywhere
          {% elif is_state("input_select.chromecast_radio", "Back yard") %} media_player.back_yard
          {% endif %}
        volume_level: '{{  states.input_number.volume_radio.state  }}' 
    - service: media_player.play_media
      data_template:
        entity_id: >
          {% if is_state("input_select.chromecast_radio", "Lounge") %} media_player.lounge_speakers
          {% elif is_state("input_select.chromecast_radio", "Bedroom") %} media_player.bedroom
          {% elif is_state("input_select.chromecast_radio", "Everywhere except office") %} media_player.all_except_office
          {% elif is_state("input_select.chromecast_radio", "Back yard") %} media_player.back_yard
          {% endif %}
        media_content_id: >
          {% if is_state("input_select.radio_station", "Hit 92-9") %} http://ic6ti.scahw.com.au/6ppm_128
          {% elif is_state("input_select.radio_station", "Nova 93-7") %} http://streaming.novaentertainment.com.au/nova937
          {% elif is_state("input_select.radio_station", "Mix 94-5") %} http://sc01.scahw.com.au/6mix_32
          {% elif is_state("input_select.radio_station", "96FM") %} https://icy.ihrcast.arn.com.au/au_012_icy

          {% endif %}
        media_content_type: 'audio/mp4'

Swapping out the radio station URL’s for Spotify playlists and the input_select info for your tag read data.

I know it’s not a nice simple guide but hopefully it helps.

2 Likes

Hey guys,
I have sucessfully installed the adonno Tag reader and this is working with the lastest version of HA with tags and services like shutter und switches.
But i could not get it working with spotfiy links on my sonos s2 system.
Can anyone give me a sample configuration of the automation action:
This is my current setting which does not work.

service: media_player.media_play
data:
  entity_id: media_player.kuche
  media_content_id: 'https://open.spotify.com/track/5T490vvoFNU6psep0NPmxs?si=OD-_qchVSiGIf3wT3FUllw'
  media_content_type: music

Do i need to install the spotify HA integration? (This was also installed in the mean time, but down not work)

Thank you in advance, hope i will get fixed my christmas present for my daughter.

Here is my automation:

alias: Tag Scanner
description: ''
trigger:
  - platform: event
    event_type: tag_scanned
condition:
  - condition: template
    value_template: '{{ trigger.event.data.tag_id in tags }}'
  - condition: template
    value_template: '{{ trigger.event.data.device_id in media_players }}'
action:
  - variables:
      media_player_entity_id: '{{ media_players[trigger.event.data.device_id] }}'
      media_content_id: '{{ tags[trigger.event.data.tag_id].media_content_id }}'
      media_content_type: '{{ tags[trigger.event.data.tag_id].media_content_type }}'
  - service: media_player.play_media
    data:
      entity_id: '{{ media_player_entity_id }}'
      media_content_id: '{{ media_content_id }}'
      media_content_type: '{{ media_content_type }}'
  - delay: '2'
mode: single
max_exceeded: silent
variables:
  media_players:
    428c1e0658d3c81d1dd08c4340ae0152: media_player.buro
  tags:
    C0-59-6B-32:
      media_content_id: 'spotify:playlist:37i9dQZF1DWV0gynK7G6pD'
      media_content_type: music
    A0-C1-64-32:
      media_content_id: 'spotify:playlist:37i9dQZF1DWV0gynK7G6pD'
      media_content_type: music

Now i got it working

I’m sure this is possible, but I don’t have the experience to figure it out.
How can I identify which device (phone) scanned the tag.
Thanks

It’s listed as device_id in the data that comes in for the event. See the example above.

1 Like

Hi @ds1707

How did you get it working? I am trying to make it work on a media_player which is an audio ChromeCast.

Hi,
im new to HA. I just created a NFC-Tag and used the tag for a automation to put off all my lights. But when i scan the NFC-Tag with my iPhone, i need to open the HA App on my iPhone first so the automation will do its job. Does someone know if i can make it happen that the automation goes on directly when i scan it without going to the app first? Thanks in advance!

You can Copy my Template above into a new automation yaml Mode. Does your Tag reader already Work?

Hi! It works well, I can scan a tag and it can trigger things. I tried adding the spotify integration. It works and starts a song in my Spotify account (the spotify media_player). But how to make it start on a specific Chromecast media_player? When I change the media_player in the yaml, and trigger the automation, I can hear the starting sound of the chromecast but the music never starts