NFC Tags in HA


NFC Tags

We have new items in our store. NFC tags, more about those tags you can read at our shop webiste …

Here is guide how to use this tags in Home Assistant automation and why we think it’s pretty cool.

Link to Home Assistant docs: https://www.home-assistant.io/integrations/tag/

Prerequisites

  • Home Assistant App on users phone
  • active connection with HA
  • NFC tag

Prepare tag for automation

Go to Home Assistant Settings in mobile app. You have to give NFC permissions to mobile app.

NFC Tags

Go to:

  1. Settings
  2. Tags
  3. Create tag
  4. Name your tag eg. LightGarden
  5. Click ‘Create and Write tag’
  6. Put tag to back of your phone, so it’d be written.

It’s ready. Tag is ready to be used in automation

Automation

This can be done either in any version of Home Assistant, on your PC as well.

Go to Automations and Create new automation.

  1. Add triger, start typing Tag

  2. Choose tag you named NFC Tags

  3. Create action you’d like to do, eg light toggle and toggle light.

    NFC Tags

It’s ready!

Light full automation

Safety precautions

Those NFC tags are great to open your front gate, doors etc. If you stick it in your car you might use them accidentaly. So let’s check if phone which is triggering this automation is in home zone to be sure. This tutorial assumes that you have your zones configured correctly.

Add condition to automation: template.

Template condition

put this code

'{{ (states.person|selectattr(''attributes.user_id'', ''eq'',trigger.event.context.user_id)|first).state == "home" }}'

In yaml mode it would look like this:

condition: template
value_template: >-
  {{ (states.person|selectattr(''attributes.user_id'',
  ''eq'',trigger.event.context.user_id)|first).state == "home" }}
Template condition

That’s make sure that person who triggered automation is in house.