Automation to add to playlist #3147
Replies: 6 comments 10 replies
-
I think you are thinking too narrowly for what MA does. It combined streaming providers as well as local files. So there are no "relative paths", there are uri to the items. Probably the closest thing being looked at currently is being able to add an item to your favourites. You would then be able to use the built-in ALL FAVOURITES playlist |
Beta Was this translation helpful? Give feedback.
-
@OzGav Thank for the response. I believe that I understand the concept of MA, at least at a basic level. I think it's an awesome piece of technology and have a great appreciation for all the people involve in this project.
I get this response: (shortened to the relevant parts)
if you look at the results of the search, there is one from provider : library and another from provider: ytmusic. In the album section of each one there is an "image" property. In the case of the "provider: library" is has the value of the relative path to the album image and in the case of the provider: ytmusic that very same value is "null". So my question is, Could it be possible to have a property in the track section that tell us where the uri is pointing to? Or the path of the track if the provider is library, similar to the image of the album, and null if it is other provider? |
Beta Was this translation helpful? Give feedback.
-
please do. |
Beta Was this translation helpful? Give feedback.
-
With MA 2.4 comes an API that can be used for this. Get the value for The In your automation you will call as an action the rest_command. You can use a template in the uri field for example
|
Beta Was this translation helpful? Give feedback.
-
working example 😊 Action ma_add_to_playlist:
url: "http://homeassistant.local:8095/api"
method: POST
headers:
accept: "application/json, text/html"
payload: >
{
"message_id": "1",
"command": "music/playlists/add_playlist_tracks",
"args": {
"db_playlist_id": "{{ playlist_id }}",
"uris": [ "{{ track_url }}" ]
}
}
content_type: 'application/json; charset=utf-8' Automationalias: Add To Playlist
description: ""
triggers:
- trigger: conversation
command:
- Mark {playlist_id}
conditions:
- condition: device
device_id: 382288c47f6746fe7e37ee3b6409f162
domain: media_player
entity_id: 404911e56fc7c1b74cd4c0ca1883a3b2
type: is_playing
- condition: not
conditions:
- condition: state
entity_id: media_player.studio_music_player
attribute: media_content_id
state: ""
actions:
- variables:
search_term: "{{ trigger.details.playlist_id.value }}"
- action: music_assistant.get_library
metadata: {}
data:
limit: 10
offset: 0
config_entry_id: 01JQSC52KYFGHD4B6A6H3AF971
media_type: playlist
search: Track {{ search_term }}
response_variable: response
- action: rest_command.ma_add_to_playlist
response_variable: rest_response
data:
playlist_id: "{{ response['items'][0].uri.split('/')[-1] }}"
track_url: "{{ state_attr('media_player.studio_music_player', 'media_content_id') }}"
mode: single |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
I have been trying to find a way to easily add current playing song to a playlist and can't find an easy way. My intention is to work with my local music library (Filesystem provider) and add the current playing song to a predefined playlist.
Using the mass.search actions I can get a lot of information, but the uri points to something like this: library://track/29643 which did not work when I tried it on the playlist. What I am looking for is the relative path to the current playing song with respect to the root folder of the library.
My idea is to use the File Integration to create an automation to add current playing song to a predefined playlist, which is also a m3u file in the local file system.
Beta Was this translation helpful? Give feedback.
All reactions