Use one NFC tag with multiple phones and users

Home assistant is not detecting the event fired from an NFC tag from a second phone.

Use case:

  1. I have an NFC tag named front_door_tag.
  2. I used the shortcuts app on an iPhone XR to set up a personal automation so that every time I scan the tag, it fires an event to home assistant.
  3. I then set up an automation in HA to listen for this event and trigger the end result.

Issue:

This works perfectly on the first phone I set up.
But, I cannot get this to work on the second phone, (also an iPhone XR).
The second phone has the exact same personal shortcut setup. The only difference is that the second phone is logged in to HA app with a different user.

Things I tried:

  1. In HA, I listened to the event front_door_tag and while it does show an event when scanning the tag with the first phone, it doesn’t show anything when I’m scanning the tag with the second phone.
  2. Second phone shows that the shortcut is running but nothing happens. I verified that I’m logged in the HA app.
  3. Both users are administrators and the automation settings “Select User” in the “Limit to events triggered by” is empty to allow both users to trigger it.

Here’s the automation in the shortcuts app:

Here’s the automation in HA:

How do I troubleshoot shoot this? There are no errors in the home assistant logs and afaik, the shortcuts app doesn’t have logs either.

2 Likes

Could you use a Boolean that you can trigger from either phone to run the automation you are trying to run?

They also survive their state on a restart.

This should work out of the box. You can check, if the event is triggered in the dev-tools.

Just make sure, that you don’t have the device-id of the scanner as a condition in your automation, as this is different on every phone.

I do the same with two android phones and it works. However what strickes me as odd is that you say:

I don’t think this is the way you should do it. HA has a build in method you can use. In the configuration panel of the App you find Tags. From there click on Add Tag. Give it a name and click on Create and Write. This should add the Tag to HA. The tag ID can then be used to trigger an automation.

If this is not clear, check out Home Assistant Tags - Home Assistant and Automation Trigger - Home Assistant

I tried using your method originally but there are 3 downsides for my scenario:

  1. By registering and writing to the tag in home assistant every time the tag is scanned both applications show the notification. (home assistant shows that it detected the tag and siri shortcuts. No way to turn it off).

  2. I couldn’t get it to run in the background. Meaning, just by taping the tag with the phone, the home assistant would sometimes not run or require an additional click. I just want it to work without prompting me for confirmation.

  3. This is for a door lock. So I highly prefer not writing anything to the tag but rather just use the tag’s ID and register it in the siri shortcuts.
    Siri shortcuts then takes care of firing the event and notifying home assistant.

This article describes the limitation of scanning NFC tags in iOS and running the action without confirmation.
scroll down to “Shortcuts Automations” section:

or here:

Well that’s what I thought too. No, there’s no device_id in the automation.
It just listens for the event front_door_tag to have {} in the event data. No additional identifiers.

This is the shortcut automation on the iPhone:

This is the automation in Home Assistant:

I’m not familiar with the iPhone and the shortcuts app, but it sounds like you setup the automation locally on one phone not on HA like @deisi said. How would another phone know about that?

@deisi is talking about the method which requires to write to the tag and register it with home assistant first which I carefully explained why it wouldn’t work in my case.

The method I am using is well documented and works perfectly every single time from the first phone I set up. I followed the exact same steps on the second phone, yet home assistant doesn’t receive the event for some reason. I’ll try to delete the app and reinstall it.

Update. That didn’t do anything.

Okay, then you have to find out where exactly the issue is. Do you have a way to validate weather your second phone is sending its command to HA? Is there any kind of logging you can follow. My guess is your second phone is not sending the same or any thing to HA and thus nothing happens.

Check out HA logs:

For the app I don’t know how you can get a log there if you see nothing in HA.

Welp, that’s exactly what I wrote in OP.

There’s no way to debug a shortcut automation in iOS. It’s Apple. The options are very limited. It just works…or it don’t.

The flow goes like this:
iOS detects the NFC TAG > iOS shortcut automation triggers the home assistant companion app to fire an event to home assistant > home assistant detects the event and runs the automation.

I’m listening to this event in HA via Developer Tools > Listen to events.
I can see the event being fired when running with the first phone.
There aren’t any logs if the event is not fired.

My assumption is that something is not right with the companion app on the second phone.

I think its more likely some sort of permission issue/ config issue with your second phone. Check if you find any difference between the two phones there.

same exact settings.
Both in iPhone>Settings>Home Assistant
and
Home Assistant App > App Configuration.

did you solve? Have exactly same issue