Skip to content

Instantly share code, notes, and snippets.

@Vincenius
Last active April 9, 2026 12:57
Show Gist options
  • Select an option

  • Save Vincenius/4e1dcee28df71534d39b5aec2f8413d9 to your computer and use it in GitHub Desktop.

Select an option

Save Vincenius/4e1dcee28df71534d39b5aec2f8413d9 to your computer and use it in GitHub Desktop.
nfc audio blueprint
blueprint:
name: NFC Spotify Media Player
description: Play a Spotify album, playlist, or song when an NFC tag is scanned
domain: automation
input:
nfc_tag:
name: NFC Tag ID
selector:
text: {}
trigger_sensor:
name: NFC Sensor
default: sensor.amp_nfc_tag
selector:
entity:
domain: sensor
media_type:
name: Media Type
description: Choose whether this NFC tag should play an album, playlist, or song
default: album
selector:
select:
options:
- album
- playlist
- song
spotify_id:
name: Spotify ID
description: Only the Spotify album, playlist, or song ID
selector:
text: {}
shuffle:
name: Shuffle playback
description: Start playback in shuffle mode (not applicable for songs)
default: false
selector:
boolean: {}
variables:
wanted_tag: !input nfc_tag
media_type: !input media_type
spotify_id: !input spotify_id
shuffle: !input shuffle
media_content_id: >-
{% if media_type == 'song' %}
spotify:track:{{ spotify_id }}
{% else %}
spotify:{{ media_type }}:{{ spotify_id }}
{% endif %}
media_content_type: >-
{% if media_type == 'song' %}
music
{% else %}
spotify:{{ media_type }}
{% endif %}
trigger:
- platform: state
entity_id: !input trigger_sensor
condition:
- condition: template
value_template: "{{ trigger.to_state.state == wanted_tag }}"
action:
- choose:
- conditions:
- condition: template
value_template: "{{ media_type != 'song' }}"
sequence:
- service: media_player.shuffle_set
target:
device_id: 162e4ccf764510e81aba414870d1dfb7
data:
shuffle: "{{ shuffle }}"
- service: media_player.play_media
target:
device_id: 162e4ccf764510e81aba414870d1dfb7
data:
media:
media_content_id: "{{ media_content_id }}"
media_content_type: "{{ media_content_type }}"
mode: single
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment