Home Assistant Tags

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

hm this seams to be an issue with handling over from HA to chromecast, due to the fact that i use sonos system i can not help you there.
Play music on chromecast work with HA and other automations?

Actually I have to admit, I never tried it. I can launch a song from Spotify on this speaker then control the media player from HA. But never succeeded in launching a song directly from HA…

Hi,

to start playing on a chromecast you need Spotcast - custom component to start playback on an idle chromecast device

That is because the “normal” integration needs the chromecast already as player in spotify…

1 Like

Indeed, that worked, thank you!
So here is my code for anyone who wants to get inspired.

- alias: 123
  mode: single
  # Hide warnings when triggered while in delay.
  max_exceeded: silent
  variables:
    # Map tag ID to content
    tags:
      D0-56-31-22:
        media_content_id: 'spotify:playlist:37i9dQZF1DWV0gynK7G6pD'
  trigger:
    platform: event
    event_type: tag_scanned
  condition:
    # Test that we support this device and tag
    - "{{ trigger.event.data.tag_id in tags }}"
  action:
    - variables:
        media_content_id: "{{ tags[trigger.event.data.tag_id].media_content_id }}"
    - service: spotcast.start
      data:
#        account: 
        device_name: "Device friendly name in Spotify"
        uri: "{{ media_content_id }}"
    - delay: 2 # timeout before we allow processing next scan

Little detail, what I am trying to achieve does NOT work YET:

  • Some tags will change the song/playlist/album
  • Some other tags will change the account or the speaker

Any clue how to tell the automation not to change this or that parameter without having to duplicate the automation?

- alias: 123
  mode: single
  # Hide warnings when triggered while in delay.
  max_exceeded: silent
  variables:
    # Map tag ID to content
    tags:
      D0-56-31-22:
        media_content_id: 'spotify:playlist:37i9dQZF1DWV0gynK7G6pD'
      67-12-D1-C2:
        media_player_entity_id: "Friendly name of the device in Spotify"
  trigger:
    platform: event
    event_type: tag_scanned
  condition:
    # Test that we support this device and tag
    - "{{ trigger.event.data.tag_id in tags }}"
  action:
    - variables:
        media_player_entity_id: "{{ tags[trigger.event.data.tag_id].media_player_entity_id }}"
        media_content_id: "{{ tags[trigger.event.data.tag_id].media_content_id }}"
    - service: spotcast.start
      data:
#        account: 
        device_name: "{{ media_player_entity_id }}"
        uri: "{{ media_content_id }}"
    - delay: 2 # timeout before we allow processing next scan

HI @adonno,
Thanks for the devices, I ordered a pair, it works great!
Is there a way to control the buzzer from HA? I would love to make it beep few times when I need.
Is is also possible to control the volume?

And if i change in future my smartphone, this automation will work the same or i am forced to use always the smartphone who created the tag_scanned?

1 Like

Just change the device_id later when you get a new phone. Or if you leave out the device_id it should just work with any registered device as far as I understand.

1 Like

Thanks, but in case, where to find the device_id?

When you scan a tag you can view that data in dev tools. See this post above with some screen shots:

May I ask what RANGE you guys get with these NFC Modules V3?
I built the circuit with a Wemos D1 and BEST i can get like 5mm. If I put it in a case that is 1.5mm thick it’s almost impossible to read tags. Any idea on that?

This tagreader is a great addition to my Home Assistant! Like most people I use it for playing music. My 2-year old son has his own nfc cards, and can easiliy use it to play his favourite songs on my Nest Audio speakers. He is addicted to it :slightly_smiling_face:
I added a Xiaomi wireless switch in order to control the songs in the playlist: one press is next song, double press is previous song, long press is stop. I bought a Canon TS8350 printer and a pvc card tray to print images on the cards. I’m very happy with this project, and so are my family members. Thanks @adonno for the great work!

QR-Codes generated from Tags works great when I scan them with my Galaxy S7 Edge using any third party App, except for when I use the Microsoft Launcher for Android. The integrated QR-Code scanner in the MS Launcher persistently forwards the URL to the default browser no matter what I do.
How can I make it forward this URL to the HA Companion App - like any other well behaved scanner will do?

Now is it possible to start playing tracks/podcasts/streams/favorites stored on Logitecht Media Server and play it on my squeezebox classic? Do I need to customize scripts or anything. I’m not really a programmer/scripter. :slight_smile:

Is it possible to retrieve the device_id of the device who scanned the tag? I just want to know which phone scan the tag that enable or disable my alarm.

The event data has the attribute “device_id” that is the id of the device that scanned the tag.

I know this event data but i am not able to use it. There is my yaml for the notification in my automation.

service: notify.mobile_app_mi_8_bbo
data:
message: ‘Alarm desactivated by {{ state_attr(’‘trigger.device_id’‘, ‘‘friendly_name’’) }}.’
title: ALARME HA

PS: Sorry for my english, i’m French :sweat_smile:

It would be trigger.event.data.device_id and it doesn’t have a friendly name. You could translate the id to a string with variables. Take a look at the examples

1 Like