Nfc tags not working 2024

Hi;
I am trying to create an NFC tag to toggle on and off the lights in the UI. The automation does not save, it goes blank, and it does not run.
In vscode I create a folder called Automation and put the toggle light script in there there is a sample of the code
I have automation: !include_dir_merge_list automations/ add to the configuration.yaml file

alias: "Tag is scanned"
description: " main light bedroom"
trigger:
  - platform: event
    event_type: tag_scanned
    event_data:
      tag_id: "001"
condition: []
action:
  - service: light.toggle
    target:
      entity_id: light.bedroom4_main
mode: single
```

Not an expert, but my NFCs work well.

Your note states that NFC tags do not work.
What do you use to scan the tag? I use mobile phone
Do you have the HA Companion app loaded? I do, running on the phone
Have you registered the NFC tag? Settings --> Tags

Here is an example I have. I made no directories/folders or files. Your tag_id and device_id will have to be matching. All of this was done through the UI.
This automation os on the light that has the overhanging reading light with a tiny table attached. The NFC tag is on the table. When I sit down, and rest my phone on the table the overhanging reading comes on. If I lift it, and tap it again, the light goes off.

alias: "Main: Tag: TOGGLE reading light"
description: ""
mode: single
triggers:
  - tag_id: 00000000-0000-0000-0000-000000000000
    trigger: tag
conditions: []
actions:
  - if:
      - condition: state
        entity_id: light.ewelight_zb_cl01_forceonlight_4
        state: "on"
    then:
      - data: {}
        target:
          entity_id: light.ewelight_zb_cl01_forceonlight_4
        action: light.turn_off
    else:
      - data:
          brightness: 255
        target:
          entity_id: light.ewelight_zb_cl01_forceonlight_4
        action: light.turn_on
      - data: {}
        action: script.color_loop
    enabled: false
  - type: toggle
    device_id: abcdef0123456790abcdef0123456790
    entity_id: light.ewelight_zb_cl01_forceonlight_4
    domain: light

1 Like

HI,
thank you for the replay I have the HA Companion app installed
when I create the NFC tag in the HA Companion app it does not save it goes to rename and then it exits when I reopen the NFC editor the then do section is blank

If I remember correctly, once you scan the tag with the companion app, it will create an entity in HA and will not show it in the companion app. Check your entities in HA for the tag. Is that what you are asking for?

1 Like

This is how I create my tags. Let me know if this is the same for you.

mise on place

  • get your blank tag ready but do not be too close to your cell phone
  • get your cell phone ready by starting HA, preferably while on local network

Creating tag

  • On you cell HA app, from the side menu hamburger go to Settings

  • In the list of Settings options select Tags

  • On the lower right corner tap + ADD TAG

  • DO NOT fill the Tag ID

  • Fill in the Name* field [Image 1]

  • Tap CREATE AND WRITE

    • at this point you should see in the center of the screen Hold your device near an NFC tag to write the following ID to it: <long hexadecimal unique ID> [Image 2]
  • now hover your cell phone over the NFC tag

  • you should hear a beep (if audio is turned on), and a message Successfully wrote NFC tag, while the screen returns to the list of NFC tags. [Image 3]

  • The tag name you gave it should show up, with Never scanned as last scan below it. [Image 4]

  • You can test it is functioning just by scanning and the time should show 1 seconds and so on. [Image 5]

  • At this point the tag can be reference in the GUI automation and in YAML.

[1]


[2]

[3]

[4]

[5]

1 Like

Hi,

Thank you for the help. The problem was with the automation since I split the automation file using:

automation: !include_dir_merge_list automations/

By doing that, the UI does not save the automation. I forgot that each automation block should start with a hyphen before the id.