Skip to content

Instantly share code, notes, and snippets.

@R00S
Last active December 27, 2025 16:50
Show Gist options
  • Select an option

  • Save R00S/d1c4b466e4900d29a3235f26a7368c70 to your computer and use it in GitHub Desktop.

Select an option

Save R00S/d1c4b466e4900d29a3235f26a7368c70 to your computer and use it in GitHub Desktop.
play ma view assist with album
blueprint:
name: View Assist - Play Music with Music Assistant
description:
Use various methods to play individual songs, albums, add to queue, play artist
and playlists from your Music Assistant server (View Assist Play Music with Music
Assistant v 1.3.0)
domain: automation
input:
ma_instance:
name: Music Assistant Instance
description: Select the Music Assistant instance
selector:
config_entry:
integration: music_assistant
view_path:
name: Dashboard Info view
description:
The View Assist dashboard view to use for displaying music information
(example /view-assist/music)
default: /view-assist/music
language:
name: Language
description: The desired spoken language
default: en
selector:
language:
languages: [de, en, pt]
play_artist_command:
name: Play Artist Command
description: The command to trigger the play artist action
default: (play the artist {artist} | play some {artist} [music] |play [some] [music | songs] by {artist})
play_album_command:
name: Play Album Command
description: The command to trigger the play album action
default: play [the] album {album} [by {artist}]
play_playlist_command:
name: Play Playlist Command
description: The command to trigger the play playlist action
default: start [the] {playlist} playlist
play_song_command:
name: Play Song Command
description: The command to trigger the play song action
default: play {song} by {artist}
queue_song_command:
name: Queue Song Command
description: The command to trigger the queue song action
default: (queue | cue | Q) {song} by {artist}
alias: View Assist - Play Music with Music Assistant
description: Play music using music assistant
trigger:
- trigger: conversation
command: !input play_artist_command
id: playartist
- trigger: conversation
command: !input play_album_command
id: playalbum
- trigger: conversation
command: !input play_playlist_command
id: playlist
- trigger: conversation
command: !input play_song_command
id: playsong
- trigger: conversation
command: !input queue_song_command
id: cuesong
conditions: []
actions:
- variables:
target_satellite_device: "{{ view_assist_entity(trigger.device_id) }}"
target_mediaplayer_device: "{{ state_attr(target_satellite_device, 'mediaplayer_device')}}"
target_satellite_device_type: "{{ state_attr(target_satellite_device, 'type')}}"
target_musicplayer_device: "{{ state_attr(target_satellite_device, 'musicplayer_device') }}"
target_use_announce: "{{ state_attr(target_satellite_device, 'use_announce') }}"
view_path: !input view_path
ma_instance: !input ma_instance
language: !input language
translations:
en:
responses:
playartist_found: Playing {artist} music
playartist_not_found: I was unable to find any music for {search_artist}
playalbum_found: "Playing the album {album}"
playalbum_not_found: "Sorry, the album {search_album} was not found"
playlist_found: "Playing the {playlist} playlist"
playlist_not_found: "Sorry, no playlist named {search_playlist} could be found"
playsong_found: "Playing {song} by {artist}"
playsong_not_found: "Sorry {song} by {artist} was not found"
playsong_queue: "Queuing {song} by {artist}"
de:
responses:
playartist_found: "Spiele Musik von {artist}"
playartist_not_found: "Entschuldigung, ich konnte keine Musik von {search_artist} finden"
playalbum_found: "Spiele das Album {album}"
playalbum_not_found: "Entschuldigung, das Album {search_album} wurde nicht gefunden"
playlist_found: "Spiele die Playlist {playlist}"
playlist_not_found: "Entschuldigung, ich konnte keine Playlist mit dem Namen {search_playlist} finden"
playsong_found: "Spiele {song} von {artist}"
playsong_not_found: "Entschuldigung, ich konnte den Song {song} von {artist} nicht finden"
playsong_queue: "Füge {song} von {artist} zur Warteschlange hinzu"
pt:
responses:
playartist_found: "Tocando música de {artist}"
playartist_not_found: "Não foi possível encontrar nenhuma música de {search_artist}"
playalbum_found: "Tocando o álbum {album}"
playalbum_not_found: "Desculpe, o álbum {search_album} não foi encontrado"
playlist_found: "Tocando a Playlist {playlist}"
playlist_not_found: "Desculpe, nenhuma Playlist com o nome {search_playlist} pode ser encontrada"
playsong_found: "Tocando {song} por {artist}"
playsong_not_found: "Desculpe, a música {song} por {artist} não foi encontrada"
playsong_queue: "Incluindo a música {song} por {artist} na lista"
- choose:
- conditions:
- condition: trigger
id:
- playartist
sequence:
- action: music_assistant.search
data:
limit: 1
config_entry_id: "{{ ma_instance }}"
media_type:
- artist
name: "{{ trigger.slots.artist }}"
response_variable: found_artist
- alias: Did we find an artist?
if:
- condition: template
value_template: "{{found_artist['artists'] | count>0}}"
alias: We found an artist!
then:
- action: view_assist.set_state
target:
entity_id: "{{ target_satellite_device }}"
data:
mode: music
title: ""
message_font_size: "5vw"
- action: view_assist.navigate
data:
device: "{{ target_satellite_device }}"
path: "{{ view_path }}"
- action: music_assistant.play_media
target:
entity_id: "{{ target_musicplayer_device }}"
data:
media_type: artist
enqueue: replace
media_id: "{{ found_artist.artists.0.name }}"
- if:
- condition: template
value_template: "{{ target_use_announce is not false }}"
then:
- variables:
conversation_response: >-
{{ translations[language]['responses']['playartist_found'].replace("{artist}", found_artist.artists.0.name)}}
- set_conversation_response: "{{ conversation_reponse }}"
- action: view_assist.set_state
target:
entity_id: "{{ target_satellite_device }}"
data:
last_said: "{{ conversation_response }}"
else:
- set_conversation_response: ""
else:
- if:
- condition: template
value_template: "{{ target_use_announce is not false }}"
then:
- variables:
conversation_response: >-
{{ translations[language]['responses']['playartist_not_found'].replace("{search_artist}", trigger.slots.artist)}}
- set_conversation_response: "{{ conversation_reponse }}"
- action: view_assist.set_state
target:
entity_id: "{{ target_satellite_device }}"
data:
last_said: "{{ conversation_response }}"
else:
- set_conversation_response: ""
- conditions:
- condition: trigger
id:
- playalbum
sequence:
- action: music_assistant.search
data:
limit: 1
config_entry_id: "{{ ma_instance }}"
media_type:
- album
name: "{{ trigger.slots.album }}"
artist: "{{ trigger.slots.artist if trigger.slots.artist is defined else '' }}"
response_variable: found_album
- alias: Did we find an album?
if:
- condition: template
value_template: "{{found_album['albums'] | count>0}}"
alias: We found an album!
then:
- action: view_assist.set_state
target:
entity_id: "{{ target_satellite_device }}"
data:
mode: music
title: ""
message_font_size: "5vw"
- action: view_assist.navigate
data:
device: "{{ target_satellite_device }}"
path: "{{ view_path }}"
- action: music_assistant.play_media
target:
entity_id: "{{ target_musicplayer_device }}"
data:
media_type: album
enqueue: replace
media_id: "{{ found_album.albums.0.name }}"
artist: "{{ found_album.albums.0.artist.name if found_album.albums.0.artist is defined else '' }}"
- if:
- condition: template
value_template: "{{ target_use_announce is not false }}"
then:
- variables:
conversation_response: >-
{{ translations[language]['responses']['playalbum_found'].replace("{album}", found_album.albums.0.name)}}
- set_conversation_response: "{{ conversation_reponse }}"
- action: view_assist.set_state
target:
entity_id: "{{ target_satellite_device }}"
data:
last_said: "{{ conversation_response }}"
else:
- set_conversation_response: ""
else:
- if:
- condition: template
value_template: "{{ target_use_announce is not false }}"
then:
- variables:
conversation_response: >-
{{ translations[language]['responses']['playalbum_not_found'].replace("{search_album}", trigger.slots.album)}}
- set_conversation_response: "{{ conversation_reponse }}"
- action: view_assist.set_state
target:
entity_id: "{{ target_satellite_device }}"
data:
last_said: "{{ conversation_response }}"
else:
- set_conversation_response: ""
- conditions:
- condition: trigger
id:
- playlist
sequence:
- action: music_assistant.search
data:
limit: 1
config_entry_id: "{{ ma_instance }}"
media_type:
- playlist
name: "{{ trigger.slots.playlist }}"
response_variable: found_playlist
- alias: Did we find a playlist?
if:
- condition: template
value_template: "{{found_playlist['playlists'] | count>0}}"
alias: We found a playlist!
then:
- action: view_assist.set_state
target:
entity_id: "{{ target_satellite_device }}"
data:
mode: music
title: ""
message_font_size: "5vw"
- action: view_assist.navigate
data:
device: "{{ target_satellite_device }}"
path: "{{ view_path }}"
- action: music_assistant.play_media
target:
entity_id: "{{ target_musicplayer_device }}"
data:
media_type: playlist
enqueue: replace
media_id: "{{ trigger.slots.playlist }}"
- if:
- condition: template
value_template: "{{ target_use_announce is not false }}"
then:
- variables:
conversation_response: >-
{{ translations[language]['responses']['playlist_found'].replace("{playlist}", found_playlist.playlists.0.name )}}
- set_conversation_response: "{{ conversation_reponse }}"
- action: view_assist.set_state
target:
entity_id: "{{ target_satellite_device }}"
data:
last_said: "{{ conversation_response }}"
else:
- set_conversation_response: ""
else:
- if:
- condition: template
value_template: "{{ target_use_announce is not false }}"
then:
- variables:
conversation_response: >-
{{ translations[language]['responses']['playlist_found'].replace("{search_playlist}", trigger.slots.artist )}}
- set_conversation_response: "{{ conversation_reponse }}"
- action: view_assist.set_state
target:
entity_id: "{{ target_satellite_device }}"
data:
last_said: "{{ conversation_response }}"
else:
- set_conversation_response: ""
- conditions:
- condition: trigger
id:
- playsong
- cuesong
sequence:
- action: music_assistant.search
data:
limit: 1
config_entry_id: "{{ ma_instance }}"
media_type:
- track
name: "{{ trigger.slots.song }}"
artist: "{{ trigger.slots.artist }}"
response_variable: found_track
- alias: Did we find a track?
if:
- condition: template
value_template: "{{found_track['tracks'] | count>0}}"
alias: We found a track!
then:
- action: view_assist.set_state
target:
entity_id: "{{ target_satellite_device }}"
data:
mode: music
title: ""
message_font_size: "5vw"
- action: view_assist.navigate
data:
device: "{{ target_satellite_device }}"
path: "{{ view_path }}"
- alias:
Set enqueue_type, media_type and response_first_word depending on cuesong
or playsong trigger
choose:
- conditions:
- condition: trigger
id:
- cuesong
sequence:
- action: music_assistant.play_media
target:
entity_id: "{{ target_musicplayer_device }}"
data:
media_type: track
enqueue: next
media_id: "{{ found_track.tracks.0.name }}"
artist: "{{ trigger.slots.artist }}"
- if:
- condition: template
value_template: "{{ target_use_announce is not false }}"
then:
- variables:
conversation_response: >-
{{ translations[language]['responses']['playsong_queue'].replace("{artist}", trigger.slots.artist ).replace("{song}", found_track.tracks.0.name ) }}
- set_conversation_response: "{{ conversation_reponse }}"
- action: view_assist.set_state
target:
entity_id: "{{ target_satellite_device }}"
data:
last_said: "{{ conversation_response }}"
else:
- set_conversation_response: ""
- conditions:
- condition: trigger
id:
- playsong
sequence:
- action: music_assistant.play_media
target:
entity_id: "{{ target_musicplayer_device }}"
data:
media_type: track
enqueue: play
media_id: "{{ found_track.tracks.0.name }}"
artist: "{{ trigger.slots.artist }}"
- if:
- condition: template
value_template: "{{ target_use_announce is not false }}"
then:
- variables:
conversation_response: >-
{{ translations[language]['responses']['playsong_found'].replace("{artist}", trigger.slots.artist ).replace("{song}", found_track.tracks.0.name ) }}
- set_conversation_response: "{{ conversation_reponse }}"
- action: view_assist.set_state
target:
entity_id: "{{ target_satellite_device }}"
data:
last_said: "{{ conversation_response }}"
else:
- set_conversation_response: ""
else:
- if:
- condition: template
value_template: "{{ target_use_announce is not false }}"
then:
- variables:
conversation_response: >-
{{ translations[language]['responses']['playsong_not_found'].replace("{artist}", trigger.slots.artist ).replace("{song}", trigger.slots.song ) }}
- set_conversation_response: "{{ conversation_reponse }}"
- action: view_assist.set_state
target:
entity_id: "{{ target_satellite_device }}"
data:
last_said: "{{ conversation_response }}"
else:
- set_conversation_response: ""
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment