Home Assistant Tags

Ok, so a question. If I mounted an NFC tag or card inside a plastic housing mounted by my front door, I take it I would be able to scan it with my phone and unlock the door.

From a security perspective, is the device id only supplied by the phone and it’s not stored on the NFC card? I wouldn’t want someone with some kind of hacker tool to be able to read the card and get all the necessary info to clone a device and be able to unlock my door. It sounds like they might only be able to read the tag that I wrote to it.

May I ask what kind of script you had running on the raspberry pi solution?
I have some raspberry pies and an nfc reader lying around and would like to try this out :slight_smile:

NFC tag reading/writing in iOS 14.
I’ll try my best to describe the issue I’m experiencing.

I have a newish iPhone (capable of background NFC reading) and an NFC tag.
When I’m trying to read the tag via iOS’s Shortcuts App > Personal automations > NFC - I can read the tag without problems.
However, when I try to use HA Companion App (current official version, not a beta) to read (or write) the very same tag, nothing happens.

I am not sure if the tag is writable, but from what I understand, even if it already has something written on it, the HA Companion should be able to read it.

Am I getting this all wrong, or am I experiencing a bug of some kind?

Thanks a lot to everybody who worked on this, this is brilliant.

I have it working with my Android phone and with a NodeMCU using esptool and this configuration.

Two questions:

  1. Even if I “write” the tag with the companion app, the ID returned by the NodeMCU is different from the one returned by the phone. Is this intentional? Is there a way to have a single card return the same ID on every device?
  2. Is it always necessary to unlock the screen on Android? For me there is no effect if the screen is locked.

Adonno’s creation is an NFC reader that triggers the new scan_tag home assistant event. It basically works equivlent to a cell phone for reading. (Except currently it only reads the card id, rather than the data, while the phone apps use the data rather than the id).

You should be able to make something similar for 125kHz RFID badges using the RDM6300 reader, slightly different wireing between the two components, and a slightly different esphome yaml file, although Adonno’s 3d printed cases might not be compatible with such a creation.

Once again, that would also be limited to reading the card id, not the data. (This is just a limitation of the ESPHome components. It would be entirely possible to read and send the data with a custom component if one wants to put in the effort to write a custom component.)

  1. Adonno’s ESPHome configuration currently does not yet support reading the content of the card, only the read-only id number from the header. This is a limitation of the card reader component in ESPHome. Android/IOS use an tag number encoded in the data.

    In the mean time, one possible work around is to first scan the card with the ESPHome device. Then use the Android or IOS to write that same card ID back to the body of the card. In theory that should make both recognize it as the same card.

  2. NFC is deliberately restricted by android when locked or screen off, such that apps cannot receive NCF intents while locked. It might be possible to bypass this while rooting the phone, but not in unmodified Android.

1 Like

Does anyone know if it’s possible to make a custom tag reader that does not rely on the ESPHome API? Taking a look at the code it does not seem possible to execute the scan_tag event oustide the esphome / companion api

In order for scanning a tag with a phone to work you need all of the following to be true:

  1. The phone has the home-assistant companion app installed.
  2. The companion app is connected to your home assistant installation (which requires signing in to your home assistant instance.)
  3. You need some sort of automation set up. The automation gets to know both the card ID, and the device_id. The device_id is determined by the integration that triggers the scan event. For the mobile_app integration, this is a unique value stored on the phone itself.

All that is stored on the card is a url that identifies that it is a home assistant tag, and includes the tag id.

Those are indeed the only two integrations that currently support tag scanning. For anything else, you would need to create a custom integration as of right now. I suppose you can always trigger the event manually from an automation, but that would not cause the last scanned time to be updated in the tag list.

Tags are super.
Does someone have a simple automation to toggle a light
I don’t know what the trigger is of a tag

There’s an example in the first post.

You can algo go in Configuration > Tags and click the Automation button, it’ll fill up all you need for the trigger.

Here you go, this is my test automation

alias: "Tag1 Scanned"
initial_state: True
mode: single
trigger:
  platform: event
  event_type: tag_scanned
  event_data:
    device_id: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
    tag_id: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
action:
 - service: homeassistant.toggle
   entity_id: switch.bedroom_fan_switch
2 Likes

I just built mine! I had the D1 Mini, Buzzer, and WS2812 laying around, but picked up the NFC reader from Amazon (the HiLetGo PN532 kit) for $10. Totally blown away by the coolness of this project. And it was so easy! Except for one thing - getting the project to fit in the case. :smile:

I’m probably going to have to disassemble and re-solder with shorter pieces of wire, as I couldn’t get the case lid on with the first try.

But having everything work on the first try, with the LED, the buzzer, and the automation - so thrilled at how well this was implemented!

Thanks!!!

The tag implementation seems to rely exclusively on ESPHome based on the examples. To make this truly useful, there needs to be a way to feed tag data into it from any source. For example, MQTT. I have RFID readers at several entry points which publish to MQTT when a tag is scanned ( room/rfid/ = tagID ). Unfortunately not usable with the Tags integration.

3 Likes

I plan on doing the same but having a hard understanding how this project would be useful. Care to share how you plan on using it? I am now using NFC tags to trigger automations (one by the door to enable alarm etc.)

I have 3 kids, with the youngest being 2 years old. Since they don’t have phones, and have trouble communicating with Alexa or Siri, I plan on building lots of cards with pictures on them to play particular videos on the Chromecast (from Youtube or Plex) or their favorite music on the Sonos, or set their nightlight scenes with deCONZ lights and such. Also, we have a Roborock vacuum, so different cards that send it a particular room for sweeping (once they have their floors picked up). It’s really mainly going to be a computerless interface for anything and everything I have hooked up that gives kids easy access.

1 Like

You can also use your phone as a tag reader. That is what I am currently playing with. I just need some ideas for what to control by sticking tags around the place…

Does this need constant power in order to work? Or does it just need to be programmed. I would like to omit the led and buzzer.

edit: I get it now. The tags are low/no power. This device can scan multiple tags and phones.

edit2: can this work with an apple watch too?

Seems to me an automation to fire a tag scanned event on receipt of an mqtt message should be doable https://www.home-assistant.io/integrations/tag/#tag-scanned-events