I’ve got some NFC cards that I want to use to start specific timers.
The cards have the attribute timer like so:
type: timer
time: 1200
for: finn
last_used:
timer: timer.finn_gaming_timer
device_class: None
icon: mdi:nintendo-switch
friendly_name: Finn Timer NFC Card
However I keep getting the error in the logs:
Automation with alias 'Handle Tag Scan' could not be validated and has been disabled: not a valid value for dictionary value @ data['action'][1]['choose'][1]['sequence'][2]['entity_id']. Got '{{ timer }}'
The automation is:
action:
- variables:
tag: "{{ trigger.event.data.tag_id }}"
scannedCard: "binary_sensor.nfc_card_{{ tag | regex_replace(find='-', replace='_') | lower }}"
for: "{{ state_attr(scannedCard, 'for')|string }}"
timer: "{{ state_attr(scannedCard, 'timer') }}"
media_player_entity_id: "{{ media_players[trigger.event.data.device_id] }}"
media_account: "{% if media_players[trigger.event.data.device_id] == 'media_player.kits_bedroom_speaker' -%} kit {%- else -%} finn {%- endif %}"
- choose:
- conditions:
- condition: template
value_template: "{{ state_attr(scannedCard, 'type')|string == 'music' }}"
sequence:
- choose:
- conditions:
- condition: and
conditions:
- condition: template
value_template: "{{ states(media_player_entity_id)|string != 'off' }}"
- condition: template
value_template: "{{ states(media_player_entity_id)|string != 'idle' }}"
sequence:
- service: media_player.media_stop
data:
entity_id: "{{ media_player_entity_id }}"
- service: spotcast.start
data:
account: "{{ media_account }}"
entity_id: "{{ media_player_entity_id }}"
uri: "{{ state_attr(scannedCard, 'media_content_id')|string }}"
random_song: true
shuffle: true
force_playback: true
- conditions:
- condition: template
value_template: "{{ state_attr(scannedCard, 'type')|string == 'timer' }}"
sequence:
- service: notify.mobile_app_sm_n985f
data:
message: "{{ media_player_entity_id }} {{ timer }} {{ state_attr(scannedCard, 'time') }}"
title: TEST
- service: script.turn_on
target:
entity_id: script.tts_announcement
data:
media_player: "{{ media_player_entity_id }}"
message: "Timer for Finn gaming starts now."
volume: 0.4
continue_on_error: true
- service: timer.start
entity_id: "{{ timer }}"
data:
duration: "{{ state_attr(scannedCard, 'time') }}"
default:
- service: script.turn_on
target:
entity_id: script.tts_announcement
data:
media_player: "{{ media_player_entity_id }}"
message: "Sorry, that card is invalid. Please try again."
volume: 0.4
- delay: 2 # timeout before we allow processing next scan
I really can’t figure out what it is complaining about.
It is saying it got {{timer }}
and that is correct, as that is a variable set at the top like the others.
Pulling my hair on this, so help would be greatly appreciated.