Android: Unable to read/write NFC tag

Created on 16 Sep 2020  路  24Comments  路  Source: home-assistant/android

Home Assistant Android version: beta-382-532ae9d-full

Android version: 10

Phone model: Oneplus7

Home Assistant version: 114.4

Last working Home Assistant release (if known): n/a

Description of problem: I cannot read or write an NFC tag which I can otherwise read or write fine using the "NFC tools" app.

Traceback (if applicable): n/a


Screenshot of problem:
image
image
image

Additional information: As you can see in the screenshot I have written a small text "by nfc tools" to the tag, so nothing should be wrong with the tag imo

bug

All 24 comments

I have the same problem with a different kind of tag and I think is related to the size of the tag - mine is 46byte.
If i try to write an uuid like: 554ee751-3adf-4f92-87f5-7517dcb60ec2 (which was created when i add a nfc tag manually in the homeassistant v0.115.0b11 web interface ) with the nfc tools app, it fails with an error stating not enough capacity.

That might indeed be the case,
I'm also unable to write any longer texts in the data field.
Perhaps they should give some minimum requirements for NFC tags before I order some that I can't use ..

NTAG215 is what i have personally used...the only requirements I know of are mentioned here: https://companion.home-assistant.io/docs/integrations/universal-links

I am unsure of what size to use but I think if you stick to a re-writable tag you should be ok

I think the minimum byte count is 70? This is actually an example of the tag we write.
https://www.home-assistant.io/tag/123e4567-e89b-12d3-a456-426614174000

same problem running HA 115.2

Same problem here with 0.115.4 reading a NTAG216. Working fine with NFC Tools:
photo_2020-09-28_21-26-33

But when I try to write an NFC tag via Homeassistant Android app:
photo_2020-09-28_21-26-37

I get this with my Poco F2 Pro:
photo_2020-09-28_21-39-59

Size should be pretty sufficient with 888Bytes.
It's writeable with NFC Tools without issues.

I will order some NTAG215s to test them out anyway.

On the latest IOS app everything works like a charm btw with the exact same NFC tag.

I had similar issues like Armadill0. Reading/writing via NFC tools was OK, but had no success with Home Assistant android application.

Phone: Xiaomi Mi 8 pro
Android: 10
Home Assistant: version 2.5.0-full
TAG: NTAG203

The solution was to allow NFC for Home Assistant application(it was disabled for me): Touch and hold the HA application icon > App info > Other permissions > NFC > Accept

Screenshot:
Screenshot_2020-10-22-18-33-39-925_com.miui.securitycenter.jpg

Then from HA application > Configuration > Tags > Add new tag with custom name(default Tag ID) and write it to the NFC tag.

The solution was to allow NFC for Home Assistant application(it was disabled for me): Touch and hold the HA application icon > App info > Other permissions > NFC > Accept

Can everyone else with this issue check this on their device? My device does not have this option so NFC is always available.

The solution was to allow NFC for Home Assistant application(it was disabled for me): Touch and hold the HA application icon > App info > Other permissions > NFC > Accept

@shmirgel Man that worked, thank you very much! :)

The solution was to allow NFC for Home Assistant application(it was disabled for me): Touch and hold the HA application icon > App info > Other permissions > NFC > Accept

Can everyone else with this issue check this on their device? My device does not have this option so NFC is always available.

@dshokouhi Checked, now works for me, sorry for bothering.

@Armadill0 not a bother at all, its helpful for us to know this because we don't all use the same devices and they are not all built the same or function the same :) I will leave this issue open for a few more days to let others respond.

@dshokouhi Great 馃槂
As a sidenote: I was able to scan the tags without those rights. But writing was not possible. Maybe this is helpful for future issues.

For future reference; I had a similar issue writing with my phone (OnePlus 5T) to a free promotional card. Reading went fine, but writing resulted in an error. However, after having written once with the NFC Tools, the HA app was able to write correctly -- multiple times and without failure.

Hi,
I have a Samsung Galaxy S9, and am running 0.117.2. I can write tags without a problem but am getting the read error. In my permissions, I can't modify the permissions for NFC access but see that the Home Assistant app appears to have access:
grafik

I can write a tag without a problem:
grafik
grafik

But then reading the same tag:
grafik
"Error while processing nfc tag"

What is strange is that the tag works fine on iOS... and I can see the URL in NFC tools:
grafik

At the suggestion of @dshokouhi on the discord server, I ran the android debug tool. I'm NOT a super advanced linux guy or debugger, so I had a hard time parsing through the logs. However I think I found the "moment" when the tag was scanned. Visibly it can read the card - as I see the full URL - but there is something preventing it from then properly opening it in home assistant. I'm happy to help debug by providing more logs, etc. See extract below (I removed the repeated '11-09 15:49:14.059 10321 10321 E TagReaderActivity:' from each line)

Unable to handle url (nfc): https://www.home-assistant.io/tag/bb7fd21a-97ab-4453-9e8f-057672f647cc io.homeassistant.companion.android.common.data.integration.IntegrationException at io.homeassistant.companion.android.common.data.integration.impl.IntegrationRepositoryImpl.scanTag(IntegrationRepositoryImpl.kt:233) at io.homeassistant.companion.android.common.data.integration.impl.IntegrationRepositoryImpl$scanTag$1.invokeSuspend(Unknown Source:12) at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33) at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:56) at android.os.Handler.handleCallback(Handler.java:883) at android.os.Handler.dispatchMessage(Handler.java:100) at android.os.Looper.loop(Looper.java:237) at android.app.ActivityThread.main(ActivityThread.java:8167) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:496) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1100)

@EagleAdam what version of the android app are you on? That error message occurs when we cant send that data back to HA. I see you are using the HA frontend to read the tag, can you try it from the App Configuration page to see if it works there?

@dshokouhi Version 3.0.1-full. And unfortunately no, same error message in App Configuration.

Are there any errors in the HA logs when this happens?

No, afraid not...

I think we may need to add some more debug logs around this to see where the issue is coming from.

Happy to volunteer my phone / system if needed 馃槃 Just let me know what I need to do

@EagleAdam can you try the full version debug APK from: https://github.com/home-assistant/android/actions/runs/354747509 it will install side by side the current app and you can change the device name to something else so you can remove it later on

This contains some additional ADB debug statements you can pull that should appear above the error you posted.

One will show the actual tag id nfcTagId: <id> and the other will start with Unable to send tag data for along with your HA URL (that you should remove from the log) and the data which should also contain the nfcTagId up above.

You should at least see the first log containing the tag ID but I am not certain you will see the last log. You may also see the last log more than once for each URL you have.

Comment back here with the log statements after you remove your URL please

@EagleAdam what version of the android app are you on? That error message occurs when we cant send that data back to HA. I see you are using the HA frontend to read the tag, can you try it from the App Configuration page to see if it works there?

Hi @dshokouhi and thanks for your help. So I don't see that specific text in the android debug logs. I see the following "NFC-related" entries (hard to parse them out from all the other stuff going on...)

NfcService: After 60 secs, send NfcConstants.SecMessage.MSG_TAG_CONNECTION
NfcService: [BIG DATA] TAG SUCCESS!!! PROTOCOL= 2
NfcService: tag value : NONE
NfcService: Handle launch intent with Knox Intent { act=android.nfc.action.NDEF_DISCOVERED dat=https://www.home-assistant.io/... pkg=io.homeassistant.companion.android (has extras) }

One note - in my earlier post I indicated that from the App Configuration I couldn't read the tag. In the normal version of the app I don't have a NFC Tags section in the App Configuration. However, in the debug version you shared, there is a NFC Tags section and I can successfully read the tag.

In the normal version of the app I don't have a NFC Tags section in the App Configuration. However, in the debug version you shared, there is a NFC Tags section and I can successfully read the tag.

sounds like you got something corrupted....in order to show the NFC section we check that the device reports it has the proper hardware and that HA version is at least 0.114. I think you may need to clear data especially if the debug version looks correct since that part of the code did not change. Follow these steps:

https://companion.home-assistant.io/docs/troubleshooting/faqs/#starting-fresh-with-the-android-app

I have same problem in my system. On Iphone XS it works perfectly, but problem is with all android devices (Asus Zenphone 5, Android 10) and tablet SONY (SGP771, Android 7.1). I can create NFC tag, but when you use it - shows message: "Error while processing nfc tag". I tried found NFC in app setting, but nothing like this it wasnt here. Thanks for all advice

// SOLVED // need to reinstall mobile app and allow NFC tags (apps looks like updated, but this setting was missing)

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Knoxie picture Knoxie  路  5Comments

N-Schaef picture N-Schaef  路  5Comments

Bruceforce picture Bruceforce  路  3Comments

Hypfer picture Hypfer  路  3Comments

jokerigno picture jokerigno  路  4Comments