Use {{payload}} to play URL by media_player

I'm trying to send a payload that consists of an URL to call a service and start this radio stream.
This is what I've entered in the 'Data' property field:

{
    "media_content_id": "{{payload}}",
    "media_content_type": "audio/mp3"
}

I don't see any error, but the actual URL is not played/streamed to the media device. However, when I use the exact same flow, but enter the URL directly in the 'Data' property (see below), the URL is played and the flow works perfectly.

{
    "media_content_id": "https://icecast.omroep.nl/3fm-bb-mp3",
    "media_content_type": "audio/mp3"
}

Does anyone know how to use payload data to start playing a stream?

Try {{msg.payload}}

Or if the type input field has JSONata (J:) then you can do

{
    "media_content_id": $$.payload,
    "media_content_type": "audio/mp3"
}

[edit] I am guessing this is a homeassitant node, from their docs-

By default, Mustache will replace certain characters with their HTML escape codes. To stop this happening, you can use triple braces: {{{payload}}}

1 Like

Thanks for your support, but this doesn't work unfortunately. The following error is than showed in debug: Call-service error. string index out of range.

It's indeed a Home Assistant node I'm using. The triple braces solved the issue.
Thank you for your help!

@alborg; I've seen your post about the same issue. The solution to the issue is described in this topic.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.