Open milkplus27 opened 5 months ago
Hi I also got this error...I've narrowed it down to the script in home assistant...what I can see it only plays "Playlists" and not individual tracks???...please correct me if I'm wrong??
I'm trying to modify the script to also accept the name of the track queries..
I also have the error "something went wrong: template rendered invalid entity ids" and don't know how to get further from here.
My additional quest is to get this Assistant to speak German. Where do I have to change the code / script in order to achieve that?
I am encountering exactly this error, has anyone fixed it yet?
this is what i use to play music on my ceiling speakers. you can edit the default media player entity in the spec below. You can also send a media player name when saying the command.
- spec:
name: search_music
description: >
Searches for music.
parameters:
type: object
properties:
query:
type: string
description: search query
media_type:
type: array
optional: true
items:
type: string
enum: ["artist", "album", "playlist", "track", "radio"]
description: Types of media to search
artist:
type: string
optional: true
description: Specify this when you search from a specific artist
album:
type: string
optional: true
description: Specify this when you search from a specific album
required:
- query
function:
type: script
sequence:
- service: mass.search
data: >
{
"name": "{{ query }}",
{% if media_type is defined and media_type %}
"media_type": {{ media_type | tojson }},
{% else %}
"media_type": ["artist", "album", "playlist", "track", "radio"],
{% endif %}
{% if artist is defined and artist %}
"artist": "{{ artist }}",
{% endif %}
{% if album is defined and album %}
"album": "{{ album }}",
{% endif %}
"limit": 1
}
response_variable: _function_result
- spec:
name: music_assistant_play
description: >
Plays a spotify URI after searching for it
using search_music. If a device is not defined,
use media_player.ceiling_speakers
parameters:
type: object
properties:
media_player_id:
type: array
items:
type: string
description: List of media player Entity IDs to play.
media_id:
type: string
description: Media identifier (URI)
enqueue:
type: string
enum: ["play", "replace", "next", "replace_next", "add"]
description: >
How to enqueue the media.
If the user says to play a song next, then use next.
If the user says to play a song at the end of the playlist, then use add.
If the user says to start a new playlist, then use replace.
If you are unsure, just use play.
required:
- media_player_id
- media_id
- enqueue
function:
type: script
sequence:
- service: mass.play_media
target:
entity_id: "{{ media_player_id }}"
data:
media_id: "{{ media_id }}"
enqueue: "{{ enqueue }}"
this is what i use to play music on my ceiling speakers. you can edit the default media player entity in the spec below. You can also send a media player name when saying the command. '''
spec: name: search_music description: > Searches for music. parameters: type: object properties: query: type: string description: search query media_type: type: array optional: true items: type: string enum: ["artist", "album", "playlist", "track", "radio"] description: Types of media to search artist: type: string optional: true description: Specify this when you search from a specific artist album: type: string optional: true description: Specify this when you search from a specific album required:
query function: type: script sequence:
service: mass.search data: > { "name": "{{ query }}", {% if media_type is defined and media_type %} "media_type": {{ media_type | tojson }}, {% else %} "media_type": ["artist", "album", "playlist", "track", "radio"], {% endif %} {% if artist is defined and artist %} "artist": "{{ artist }}", {% endif %} {% if album is defined and album %} "album": "{{ album }}", {% endif %} "limit": 1 } response_variable: _function_result
- spec: name: music_assistant_play description: > Plays a spotify URI after searching for it using search_music. If a device is not defined, use media_player.ceiling_speakers parameters: type: object properties: media_player_id: type: array items: type: string description: List of media player Entity IDs to play. media_id: type: string description: Media identifier (URI) enqueue: type: string enum: ["play", "replace", "next", "replace_next", "add"] description: > How to enqueue the media. If the user says to play a song next, then use next. If the user says to play a song at the end of the playlist, then use add. If the user says to start a new playlist, then use replace. If you are unsure, just use play. required:
- media_player_id
- media_id
- enqueue function: type: script sequence:
- service: mass.play_media target: entity_id: "{{ media_player_id }}" data: media_id: "{{ media_id }}" enqueue: "{{ enqueue }}"
Cheers for this function....is there any chance you could upload a correctly formatted version?...cheers again
- spec:
name: search_music
description: >
Searches for music.
parameters:
type: object
properties:
query:
type: string
description: search query
media_type:
type: array
optional: true
items:
type: string
enum: ["artist", "album", "playlist", "track", "radio"]
description: Types of media to search
artist:
type: string
optional: true
description: Specify this when you search from a specific artist
album:
type: string
optional: true
description: Specify this when you search from a specific album
required:
- query
function:
type: script
sequence:
- service: mass.search
data: >
{
"name": "{{ query }}",
{% if media_type is defined and media_type %}
"media_type": {{ media_type | tojson }},
{% else %}
"media_type": ["artist", "album", "playlist", "track", "radio"],
{% endif %}
{% if artist is defined and artist %}
"artist": "{{ artist }}",
{% endif %}
{% if album is defined and album %}
"album": "{{ album }}",
{% endif %}
"limit": 1
}
response_variable: _function_result
- spec:
name: music_assistant_play
description: >
Plays a spotify URI after searching for it
using search_music. If a device is not defined,
use media_player.ceiling_speakers
parameters:
type: object
properties:
media_player_id:
type: array
items:
type: string
description: List of media player Entity IDs to play.
media_id:
type: string
description: Media identifier (URI)
enqueue:
type: string
enum: ["play", "replace", "next", "replace_next", "add"]
description: >
How to enqueue the media.
If the user says to play a song next, then use next.
If the user says to play a song at the end of the playlist, then use add.
If the user says to start a new playlist, then use replace.
If you are unsure, just use play.
required:
- media_player_id
- media_id
- enqueue
function:
type: script
sequence:
- service: mass.play_media
target:
entity_id: "{{ media_player_id }}"
data:
media_id: "{{ media_id }}"
enqueue: "{{ enqueue }}"
- spec: name: search_music description: > Searches for music. parameters: type: object properties: query: type: string description: search query media_type: type: array optional: true items: type: string enum: ["artist", "album", "playlist", "track", "radio"] description: Types of media to search artist: type: string optional: true description: Specify this when you search from a specific artist album: type: string optional: true description: Specify this when you search from a specific album required: - query function: type: script sequence: - service: mass.search data: > { "name": "{{ query }}", {% if media_type is defined and media_type %} "media_type": {{ media_type | tojson }}, {% else %} "media_type": ["artist", "album", "playlist", "track", "radio"], {% endif %} {% if artist is defined and artist %} "artist": "{{ artist }}", {% endif %} {% if album is defined and album %} "album": "{{ album }}", {% endif %} "limit": 1 } response_variable: _function_result - spec: name: music_assistant_play description: > Plays a spotify URI after searching for it using search_music. If a device is not defined, use media_player.ceiling_speakers parameters: type: object properties: media_player_id: type: array items: type: string description: List of media player Entity IDs to play. media_id: type: string description: Media identifier (URI) enqueue: type: string enum: ["play", "replace", "next", "replace_next", "add"] description: > How to enqueue the media. If the user says to play a song next, then use next. If the user says to play a song at the end of the playlist, then use add. If the user says to start a new playlist, then use replace. If you are unsure, just use play. required: - media_player_id - media_id - enqueue function: type: script sequence: - service: mass.play_media target: entity_id: "{{ media_player_id }}" data: media_id: "{{ media_id }}" enqueue: "{{ enqueue }}"
Thanks for this function. About script, can you share your script to play media?
There’s no script. These two specs play the media
Hi there! Firstly, just wanted to say that you're doing awesome work here. Both video and written tutorials are easy to follow and a real asset to the HA community.
However, I seem to be having an issue which I'm certain is likely my own error but am a little stuck on how to debug it.
I have followed all your instructions to get to the point of having the Wyoming Satellite (with 2Mic PiHat) play music via either the wake word or just by typing into Assist in HA but i'm getting an errors back. If i ask it to play a specific artist on the specific device I get the following when i check the debug:
and then, if I ask it just to play a specific artist or genre (without specifying the device) i get this:
At this point I'm not sure where I'm going wrong. What's interesting is that I had a different speaker (my Sonos soundbar) enabled in Music Assistant and had to disable it because when I said "Hey, Jarvis. Play Queen in the Living Room" it was playing on that speaker instead of the Wyoming Satellite. Which I didn't even think was possible.
I should add that everything else seems to be working well enough, like turning on/off lights and asking "Who is Bruce Wayne", for example.
Any advice would be super appreciated - I'm sure it's just me misunderstanding things haha