blueprint:
name: Start music on Alexa when tag is scanned
description: When a tag is scanned, start the associated music on the selected Alexa media player
domain: automation
input:
tag_id:
name: Tag ID
description: The tag ID for the selected song
song_name:
name: Song name
description: The name of the song to play
alexa_entity_id:
name: Alexa player
description: The entity ID of the alexa player to use
selector:
entity:
domain: media_player
trigger:
- platform: tag
tag_id: !input tag_id
action:
- service: media_player.play_media
data_template:
entity_id: !input alexa_entity_id
media_content_id: !input song_name
media_content_type: "AMAZON_MUSIC"
artist_name:
name: Artist name
description: The name of the artist
album_name:
name: Album name
description: The name of the album of this artist the song belongs to
I haven’t tried it yet but should work. If not, maybe remove the double quotes around !input tags.
Have got this far but not getting the movie playing, sorry i have probably butchered your Blueprint.
blueprint:
name: Start Movie on Plex when tag is scanned
description: When a tag is scanned, start the associated music on the selected Alexa
media player
domain: automation
input:
tag_id:
name: Tag ID
description: The tag ID for the selected song
Movie_name:
name: Movie Name
description: The name of the movie to play
alexa_entity_id:
name: Alexa player
description: The entity ID of the alexa player to use
selector:
entity:
domain: media_player
source_url: https://community.home-assistant.io/t/start-music-on-alexa-media-player-when-a-tag-is-scanned/256630
trigger:
- platform: tag
tag_id: !input 'tag_id'
action:
- service: media_player.play_media
data_template:
entity_id: !input 'alexa_entity_id'
media_content_id: '{ "library_name": "movies", "title": "!input movie_name" }'
media_content_type: MOVIE
Indeed it was not as simple as planned.
After a few dozens unsuccessful attempts, here one that works
blueprint:
name: Start movie on Plex when tag is scanned
description: When a tag is scanned, start the associated movie on the selected Plex media player
domain: automation
input:
tag_id:
name: Tag ID
description: The tag ID for the selected movie
movie_name:
name: Movie name
description: The name of the movie to play
movie_library:
name: Movie library
description: The name of the movie library in plex, usually "Movies"
plex_player_id:
name: Plex player
description: The entity ID of the Plex player to use
selector:
entity:
domain: media_player
variables:
name: !input movie_name
library: !input movie_library
trigger:
- platform: tag
tag_id: !input tag_id
action:
- service: media_player.play_media
data_template:
entity_id: !input plex_player_id
media_content_type: movie
media_content_id: '{ "library_name": "{{ library }}", "title": "{{ name }}" }'
Thanks for creating this Blueprint. Couple questions if you dont mind…
Im totally lacking the knowledge needed in yaml as of now, but Im learning. I have a playlist in spotify I would like to play through my echo device. What part of the code and with what would I change it to.
I gave it a try. I added the url from the share spotify playlist link into the song id and set the media content type to playlist. Nothing played. Unfortunately…
Thank you
I changed your blueprint so its more universal and modified some descriptions. It needs some work on the descriptions and though cause I only tested Universal, amazon and spotify (i dont have the rest), but it seems to work fine. Its a good working prototype
Maybe you can check this out and look if you wanna adept this to your blueprint. Its solves the issues with spotify for the most users and as a last chance you can use the Universal source, where you can type in what you would say to your alexa device and it will work.
blueprint:
name: Start music on Alexa when a tag is scanned
description:
When a tag is scanned, start the associated music on the selected Alexa media player.
You can also run commands with the "universal function"
domain: automation
input:
tag_id:
name: Tag ID
description:
The tag ID of your NFC trigger. Can be found under Settings --> NFC Tags
and then click on the NFC Tag you want to choose.
alexa_entity_id:
name: Alexa player
description: The entity ID of the alexa player to use
selector:
entity:
domain: media_player
song_name:
name: Song name.
description: The name of the song to play. The source is specified below.
Make sure to select only one source. If its known that a source must be formatted right
then its specified in the source you can select.
source_amazon:
name: Amazon Music
description: Music is from Amazon Music. The Song name can be the songname
default: false
selector:
boolean:
source_spotify:
name: Spotify
description:
Music is from Spotify. Song name must be songname (e.g. Still Alive),
songname and interpret (e.g. Still alive from Red ),
"playlist" and playlist name (e.g. Playlist Oldies)
or the name of a featured playlist from Spotify (e.g. Missed Hits).
selector:
boolean:
source_apple:
name: Apple Music
description: Music is from Apple Music.
default: false
selector:
boolean:
source_deezer:
name: Deezer
description: Music is from Deezer.
default: false
selector:
boolean:
source_tunein:
name: TuneIn
description: Music is from TuneIn.
default: false
selector:
boolean:
source_custom:
name: Universal
description:
You can put a command in the songname which you would say to your Alexa device e.g.
"Play my playlist Oldies on Spotify" (leave out your trigger word from your device).
Requires Alexa Media Player version 3.4.0 or newer.
default: false
selector:
boolean:
variables:
is_spotify: !input "source_spotify"
is_amazon: !input "source_amazon"
is_apple: !input "source_apple"
is_deezer: !input "source_deezer"
is_tunein: !input "source_tunein"
is_costum: !input "source_custom"
trigger:
- platform: tag
tag_id: !input tag_id
action:
- service: media_player.play_media
data_template:
entity_id: !input alexa_entity_id
media_content_id: !input song_name
media_content_type: >
{% if is_amazon %}
AMAZON_MUSIC
{% elif is_spotify %}
SPOTIFY
{% elif is_apple %}
APPLE_MUSIC
{% elif is_deezer %}
DEEZER
{% elif is_tunein %}
TUNEIN
{% elif is_costum%}
custom
{% endif%}
any idea how (if it’s possible) to extend this to allow the Alexa device be selected via an Input Select dropdown similar to how you’ve done it in your TTS Blueprint. Ideally using the Friendly Name of the media_player entity rather than it’s entity_id
Also, as an aside “borrowing” the Input Text structure from your TTS Blueprint (same link as above) allows you to input a song/playlist as text and have this play when the automation executes (I’m using a button in the UI to call the automation)