Home assistant is not detecting the event fired from an NFC tag from a second phone.
Use case:
I have an NFC tag named front_door_tag.
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.
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:
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.
Second phone shows that the shortcut is running but nothing happens. I verified that I’m logged in the HA app.
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.
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.
I tried using your method originally but there are 3 downsides for my scenario:
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).
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.
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:
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.
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.
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.
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.