I am working on a project to provide a sensory room for my autistic grandson. The basic idea is for him to be able to put an NFC tag (disguised as a coin) on an NFC tag reader and have it kickoff a combination of music, LED lights, laser lights, etc.
I’ve got the general flow and integration working but I’m looking for a more elegant way of kicking off the “show”. Currently I have a script for the lights, music , etc associated with each NFC tag. These scripts are orchestrated by an automation and the automation is kicked off by an NFC tag read. Right now I’ve got one automation associated with each NFC tag.
TO reduce the amount of effort coordinating tags, automations and scripts I would like to consolidate all the automations into a single tag read triggered automation. The automation would then determine which tag was read and kick off the appropriate script.
Does anyone have any suggestions or pointers on how to do something like I’ve described?
The following example will run a script associated with a specific tag. For example, if tag_id “A7-6B-90-5F” is scanned, the automation will execute script.play_music
alias: example
trigger:
- id: play_music
platform: tag
tag_id: A7-6B-90-5F
- id: flash_lights
platform: tag
tag_id: C5-2E-40-9F
- id: something_else
platform: tag
tag_id: D3-5A-E3-78
condition: []
action:
- service: script.turn_on
target:
entity_id: "script.{{ trigger.id }}"
mode: queued
Do I have to use the numeric value for the tag id as the script name ? I’m using the tag friendly name as the script name (eg Tag Named Test1 kicks of script Test1).
I have a similar problem. Currently, I want to merge 20 automations into one. It’s an automation that, after scanning an NFC tag that is located on the spice jar’s cap, plays the name of the spice that is in the jar through the speakers in the kitchen. The automations work in versions where one tag equals one spice. The automation combining them into one is problematic. I kindly ask for help. What could possibly be wrong?
alias: Kuchnia P2 - Tag NFC - TTS - Przyprawy
description: >-
Po zeskanowaniu tagu NFC (znajduje się on na nakrętce słoiczka) w głośnikach w
Kuchni P2 odtwarzana jest nazwa przyprawy znajdującej się w danym słoiczku.
trigger:
- platform: tag
tag_id: tag_nfc_kuchnia_tts_bazylia
- platform: tag
tag_id: tag_nfc_kuchnia_tts_cukier_wanilinowy
- platform: tag
tag_id: tag_nfc_kuchnia_tts_curry
- platform: tag
tag_id: tag_nfc_kuchnia_tts_cynamon
- platform: tag
tag_id: tag_nfc_kuchnia_tts_czosnek_granulowany
- platform: tag
tag_id: tag_nfc_kuchnia_tts_galka_muszkatolowa
- platform: tag
tag_id: tag_nfc_kuchnia_tts_imbir
- platform: tag
tag_id: tag_nfc_kuchnia_tts_lubczyk
- platform: tag
tag_id: tag_nfc_kuchnia_tts_majeranek
- platform: tag
tag_id: tag_nfc_kuchnia_tts_oregano
- platform: tag
tag_id: tag_nfc_kuchnia_tts_papryka_ostra
- platform: tag
tag_id: tag_nfc_kuchnia_tts_papryka_slodka
- platform: tag
tag_id: tag_nfc_kuchnia_tts_pieprz_cayenne
- platform: tag
tag_id: tag_nfc_kuchnia_tts_pieprz_czarny_mielony
- platform: tag
tag_id: tag_nfc_kuchnia_tts_pieprz_czarny_ziarnisty
- platform: tag
tag_id: tag_nfc_kuchnia_tts_pieprz_ziolowy
- platform: tag
tag_id: tag_nfc_kuchnia_tts_przyprawa_do_piernika
- platform: tag
tag_id: tag_nfc_kuchnia_tts_tymianek
- platform: tag
tag_id: tag_nfc_kuchnia_tts_ziele_angielskie
- platform: tag
tag_id: tag_nfc_kuchnia_tts_ziola_prowansalskie
condition: []
action:
- service: tts.cloud_say
data:
entity_id: media_player.glosniki_w_kuchni_p2
message: |
{% if tag_id == 'tag_nfc_kuchnia_tts_bazylia' %}
Bazylia
{% elif tag_id == 'tag_nfc_kuchnia_tts_cukier_wanilinowy' %}
Cukier Wanilinowy
{% elif tag_id == 'tag_nfc_kuchnia_tts_curry' %}
Curry
{% elif tag_id == 'tag_nfc_kuchnia_tts_cynamon' %}
Cynamon
{% elif tag_id == 'tag_nfc_kuchnia_tts_czosnek_granulowany' %}
Czosnek Granulowany
{% elif tag_id == 'tag_nfc_kuchnia_tts_galka_muszkatolowa' %}
Gałka Muszkatołowa
{% elif tag_id == 'tag_nfc_kuchnia_tts_imbir' %}
Imbir
{% elif tag_id == 'tag_nfc_kuchnia_tts_lubczyk' %}
Lubczyk
{% elif tag_id == 'tag_nfc_kuchnia_tts_majeranek' %}
Majeranek
{% elif tag_id == 'tag_nfc_kuchnia_tts_oregano' %}
Oregano
{% elif tag_id == 'tag_nfc_kuchnia_tts_papryka_ostra' %}
Papryka Ostra
{% elif tag_id == 'tag_nfc_kuchnia_tts_papryka_slodka' %}
Papryka Słodka
{% elif tag_id == 'tag_nfc_kuchnia_tts_pieprz_cayenne' %}
Pieprz Cayenne
{% elif tag_id == 'tag_nfc_kuchnia_tts_pieprz_czarny_mielony' %}
Pieprz Czarny Mielony
{% elif tag_id == 'tag_nfc_kuchnia_tts_pieprz_czarny_ziarnisty' %}
Pieprz Czarny Ziarnisty
{% elif tag_id == 'tag_nfc_kuchnia_tts_pieprz_ziolowy' %}
Pieprz Ziołowy
{% elif tag_id == 'tag_nfc_kuchnia_tts_przyprawa_do_piernika' %}
Przyprawa Do Piernika
{% elif tag_id == 'tag_nfc_kuchnia_tts_tymianek' %}
Tymianek
{% elif tag_id == 'tag_nfc_kuchnia_tts_ziele_angielskie' %}
Ziele Angielskie
{% elif tag_id == 'tag_nfc_kuchnia_tts_ziola_prowansalskie' %}
Zioła Prowansalskie
{% endif %}
mode: single
is this only usable if you are directly scanning the NFC tag via the native mobile HA app?
I’m on iOS and want to get into using more NFC tags once I upgrade my ancient phone. But my wifes supports background scanning but seems laborious to have to script everything in ios/share per phone…etc.
If the tag id is possible to pass to HA and then u can just switch case the auotmations based on Tag that would be huge.