Tag
The tag integration in Home Assistant knows the NFC tags and QR codes you scan with your phone. Every tag has an ID, written on the tag itself, and a name, and scanning one can start an automation. You find them under Settings > Tags.
Home Assistant lets you add, rename and delete tags on the Tags page, by hand. Spook adds actions for it, so an automation or a script can do the same: add the tag for a new sticker, give it a name and a description, and delete it again. An assistant with Spook's tools can do all three too.
Actions
Spook adds three actions for tags. You find them wherever you add an action, marked with a 👻. All three are for administrators only, the same as the Tags page.
Every tag has an entity, which Home Assistant names after the tag, and which shows when it was last scanned. The actions leave that the way the Tags page does: a new tag gets one, a new name renames it, and deleting a tag deletes it too.
Create a tag
Creates a new tag, the same as adding one on the Tags page.
You stuck a new NFC sticker next to the front door. Writing it with your phone gives it an ID, and Home Assistant adds the tag the first time it is scanned, without a name. With this action, the tag is there before that, with the name and description you want.
How to use it
- Open the automation or script that should create the tag, and select Add action.
- Search for create a tag, and select Tag: Create a tag 👻.
- Fill in Name, like
Front door. - Fill in the Tag ID that is on the tag, and a Description if you like.
- Select Save.
Just want to see it work? Try this action opens it in your Home Assistant, ready to run once. Mind you: running it creates the tag for real.
| Action properties | |
|---|---|
| Action | Tag: Create a tag 👻 |
| Action name | tag.create |
| Action targets | No targets |
| Action response | Optional, the entity_id and tag_id of the new tag |
| Spook's influence | Newly added action |
| Tools | Try this action |
| Action data parameters | |||
|---|---|---|---|
| Attribute | Type | Required | Default / Example |
name | string | Yes | Front door |
tag_id | string | No | 04-91-5c-22-7f-61-80 |
description | string | No | The NFC sticker next to the front door |
Without a tag_id, Home Assistant makes one up, the same as the Tags page does when you leave it out. The response gives you the ID it made, to write on a tag. A tag_id another tag already has is refused.
The entity ID follows the name, as it does in the UI, and gets a number at the end if that name is already taken. A tag needs a name: the Tags page does not save one without either.
The NFC sticker next to the front door:
action: tag.create
data:
name: "Front door"
tag_id: "04-91-5c-22-7f-61-80"
description: "The NFC sticker next to the front door"
response_variable: created
The new tag's entity ID is then in {{ created.entity_id }}, and its ID in {{ created.tag_id }}.
- This makes the tag Home Assistant knows, it does not write a tag. Write the ID on the tag with the companion app.
- The ID of a tag cannot change afterwards: it is what the tag says when it is scanned.
- This takes an admin when a user calls it. Automations and scripts are not affected.
Delete a tag
Deletes one or more tags, with their entities, disabled ones included.
The other half of Create a tag: the sticker came off the door, or the QR code went out with the old fridge. Everything in the list is checked first: if one of them cannot be deleted, none of them are.
How to use it
- Open the automation or script that should delete the tag, and select Add action.
- Search for delete a tag, and select Tag: Delete a tag 👻.
- Under Entity ID, choose the tags to delete.
- Select Save.
Just want to see it work? Try this action opens it in your Home Assistant, ready to run once. Mind you: running it deletes the tag for real.
| Action properties | |
|---|---|
| Action | Tag: Delete a tag 👻 |
| Action name | tag.delete |
| Action targets | No targets |
| Action response | No response |
| Spook's influence | Newly added action |
| Tools | Try this action |
| Action data parameters | |||
|---|---|---|---|
| Attribute | Type | Required | Default / Example |
entity_id | string | list of strings | Yes | tag.front_door |
A tag goes by its entity, which every tag has. The tag ID is in the attributes of that entity, when you only know the ID.
Delete the front door tag:
action: tag.delete
data:
entity_id: tag.front_door
- Scanning a deleted tag adds it again, without a name, the same as for a tag Home Assistant never knew.
- An automation started by scanning the tag goes by its ID, not by the tag Home Assistant knows. Deleting the tag does not stop it running when the tag is scanned.
- This takes an admin when a user calls it. Automations and scripts are not affected.
Update a tag
Changes the name or description of tags, the same as editing them on the Tags page. The change stays, through a reload and a restart.
A tag added by scanning it has no name, only its ID. Or the sticker moved from the front door to the back door. Without this action, that is a trip to the Tags page. With it, the script that sorts out your tags does it too.
How to use it
- Open the automation or script that should change the tag, and select Add action.
- Search for update a tag, and select Tag: Update a tag 👻.
- Under Targets, choose the tag.
- Fill in what should change: Name or Description. What you leave out stays as it is.
- Select Save.
Just want to see it work? Try this action opens it in your Home Assistant, ready to run once. Mind you: running it changes the tag for real.
| Action properties | |
|---|---|
| Action | Tag: Update a tag 👻 |
| Action name | tag.update |
| Action targets | Yes, tag entities |
| Action response | No response |
| Spook's influence | Newly added action |
| Tools | Try this action |
| Action data parameters | |||
|---|---|---|---|
| Attribute | Type | Required | Default / Example |
name | string | No | Back door |
description | string | No | The NFC sticker next to the back door |
Give at least one field. What is given goes on top of what the tag has, and what is left out keeps what it has. A tag keeps its name on its entity, the same name you see in the settings of that entity: a new name renames the entity, not its entity ID. With more than one tag, each gets the change, and a tag that already has it is left alone.
A description of null empties the description. Home Assistant has no way to take one away completely.
The sticker moved to the back door:
action: tag.update
target:
entity_id: tag.front_door
data:
name: "Back door"
description: "The NFC sticker next to the back door"
- The ID of a tag stays what it is: it is what the tag says when it is scanned.
- The entity ID stays what it is. To change it too, use Entity: Update ID.
- This takes an admin when a user calls it. Automations and scripts are not affected.
Use cases
What people use this for:
- Add the tag for a new NFC sticker before its first scan, with a name and a description that says where it is.
- Give the tags that were added by scanning them a proper name in one go.
- Clean up the tags of stickers that are gone.
Missing something here?
An action, an entity or a repair this integration should have? Say so. Stuck, or found a bug? There is help.
Labs
Spook adds actions to Home Assistant Labs that switch a preview feature on or off from an automation, like winter mode when it snows.
MQTT
Spook adds an action to MQTT that finds the retained messages a removed device or integration left on your broker, and clears them, so MQTT discovery stops bringing old devices back.
