USB NFC Reader?

What is the easiest way to use a USB NFC card reader (for example ACR122U) with Home Assistant?

I’m using Home Assistant Container. Ideally I would just plug one in, mount the device into the container and let a Home Assistant integration create tag events. Is that possible?

Not USB based. But this works great for tag reading. I followed the plans and built my own.

Yeah, I saw that. If the USB one isn’t possible, I’ll build an ESP8266-based one. Will probably go for Tasmota instead of ESPHome as I already use that on other equipment and I can still use USB for power. It’s just that the USB reader comes complete with a case and cable and everything and it doesn’t need Wifi… all around it seems a better choice if it will be set up right next to the Home Assistant server (Pi).

I just realized… instead of going PN532 → ESP8266 → Wifi → Home Assistant I could just hook up the PN532 to the Raspberry Pi’s GPIOs directly.

However I cannot find any information on how to get the tags into Home Assistant. All I can find is either using the Tasmota integration or the ESPHome integration. Is there a generic API (REST? MQTT?) for that?

1 Like

Any progress on this @AndreKR?

Nope, I gave up for now. It would have been just a gimmick anyway and it turned out to be a bit annoying. I hooked up a generic PN532-based reader to a Raspberry Pi and I tried all three connection types (serial, I2C and SPI) with the software that is available in Debian/Pi OS (I think it’s called nfc-tools.) Some of the connection types are just slow, some are flaky and require frequent restarts of the tool, all of them require polling. The last point might be a limitation of the hardware, but the protocol is complicated and the implementation in nfc-tools is documented rather poorly.

This was my plan too. I was even fine buying a $200 reader, but if it’s gonna be such a pain to hook up to Home Assistant, who cares :person_shrugging:.

I saw some ideas online about using Web Hooks and MQTT to hook it up, but you’d have to first read it, and then send the command somehow requiring a 3rd party app or something you write yourself.

I was recently in the same boat and so I built a thing for it:

Just in case it ends up being of some use to someon

So there is an MQTT API? Did you reverse engineer it from ESPHome or did you find it documented somewhere?

Hm, the tags should automatically appear under Settings > Tags, right? I don’t have to add them manually, or do I?

The MQTT API is quite well documented under the MQTT Integration docs actually.

EspHome however does not use the MQTT api. They use an internal API that’s… less documented.

Hm, the tags should automatically appear under Settings > Tags, right?

It won’t, because that requires triggering the tag_scanned event, which I couldn’t figure out how to do using MQTT.

You have to write data to the tags using the Home Assistant companion app. Whatever you chose as the Tag ID when creating/writing the tag is what will show up as the state of the sensor.

If you haven’t written anything to the tag it should still show up as a generic_SOMEHEXCODE, but I haven’t tested it.

What I did was I wrote the track ID I wanted to play as the Tag ID (e.g. library://track/172) and made an automation that calls the music_assistant.play_media action with the state of the sensor as media ID (using a template).

That way, I don’t need to maintain a mapping of TagID → TrackID anywhere.

Well, I see the sensor but it doesn’t seem to trigger the “when a tag is scanned” (trigger: tag) automations.

Yep. You have to make the automation trigger on state change

How do I link it up to Home Assistant’s tags functionality? A text sensor is quite useless, I could do that with Node-RED or a shell script even. My question is about how to hook into the tags feature, so that it works, well, like tags do.