How to play a mp3 stored at HA at mediaplayer with Node-RED?

Sorry about confusing
I tried both: and audio/mp3 and music
It has to do something with media_content_id.
Because it says: Call-servive API error media_content_id

So I think something is wrong in my url
But this is how I log in into Home Assistant desk (without the config/tts/doorbell.mp3 part)

my mp3 is in /config/tts directory

Oh that’s probably why.
It needs to be in the www directory.
I made a folder called media in there.
and when you access it via url replace www with local
which is how I got:
/local/media/12hrwhitenoise.mp3

But I do not have a www directory?
Where to make?
In the root? like /www?
I did make the directory but not able to approuch it by samba

I did make a www directory in /config
I will restart HA to check again

It’s in my config folder.
It’s been a while, I was trying to get this to work a while ago and I might have manually made it then.
Might need to restart HA after adding it.
I can’t remember if I had to chmod that folder. Hopefully if I did it’s not a security risk I’ve forgotten about…

1 Like

I’m getting closer.
I did make a www directory in /config
restarted HA
Then I did copy the link with local in it and put it in straight in the browser it is playing the mp3.
So it is recognize local as directory
Put the string in NR it stil gives an error

Yesssssss It is working!!!
Thanks 1000 times.
I did make also a directory media into www
Now it is working.

I’m sooooo happy
What did you help me :+1: :+1: :+1:

Glad to hear!
And thank you for reminding me to tackle this problem I wanted to solve.
I tried this months ago and my Google Home Mini’s started distorting the audio and failing after about 20 minutes.
I think they fixed the issue because it was happening with the built-in “play white noise” command.
We’ll see if plays through the night for my kids and hopefully doesn’t start sounding like Satan is trying to teach my children the ways of evil.

I was trying the same thing, playing a local mp3 file from HA to one of my SONOS speakers in node-red. This is my flow:

image

As you can see the Data has no single quotes ’ around the link!

[{"id":"517e9999.ae4418","type":"api-call-service","z":"81901ec9.ddcee8","name":"test local mp3 play","server":"efdc12b5.8e0cb","version":1,"debugenabled":false,"service_domain":"media_player","service":"play_media","entityId":"media_player.werkkamer","data":"{\"entity_id\":\"media_player.werkkamer\",\"media_content_id\":\"https://XXXX.duckdns.org:8123/local/audio/test.mp3\",\"media_content_type\":\"music\"}","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":530,"y":780,"wires":[["fa805ab9.d984f8"]]},{"id":"efdc12b5.8e0cb","type":"server","z":"","name":"Home Assistant","legacy":false,"addon":true,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":true,"cacheJson":true}]

Why to define twice your entity_id?
In data and at the Node?
I think you don’t need to define this in the data part
Why do you mention no single quotes?

using the entity twice? I did not know you only would need it once.
removing it from the data part in next update :slight_smile:
double quotes works fine for me.

Does this not work with echos?

I tried it and it says sent, but dont hear anything. But if I open the URL in web browser, music plays so I know URL is good.
image

If I change content type to “music” alexa tells me that i can only do TTS through the notify service, blah blah blah. If I choose audio/mp3 it says sent as above, but doesnt play anything


image

1 Like

I remember back when I was slightly interested in using echo’s I found it much more difficult to accomplish things with HA.
I remember downloading something called Alexa Media Player or something like that so it could be treated as a media player.
It was kinda hit or miss.

I think I was told several months ago that Amazon prevents the use of local music files. Apparently they want you to subscribe to a service like Amazon Music, Spotify, etc. I installed the Amazon Media integration, but it doesn’t do anything as far as I can tell. It would be nice to play music from my library - I have tons and it’s enough for me

Well since this is resurrected now. I found a way to play your own music using a skill.

But its not very useful if you intend on playing your whole library as it involved a few steps and caveats. I would only use it now if I wanted a certain sound/song to play for a certain occsaion. One that, once set, I wouldent change it.

It pretty much involves uploading the song in a very speific format (only can be so long in length, certain size in kb, etc), then using an amazon skill to play it. The node would look like this…

image


Heres full breakdown in another thread…

Hi all,
I’ve find the way that is working for me, no need for new folder…just used this path for radio playlist:

{
    "media_content_id": "///media/radio/Radio.xspf",
    "media_content_type": "music"
}

and this path for song:

{
    "media_content_id": "///media/my_folder/song.mp3",
    "media_content_type": "music"
}

Hope this helps!

Thankyou - This post really helped me :smiley:

1 Like

Just for future reference. I think, that original problem is, you used service “media_play”, which equals to pressing the play button. But when you want to specify what to play, you have to use service “play_media” (used later in thread). It took me long time to spot this difference when i was trying to play some media myself

1 Like

@Canedje @keithcroshaw Thanks for your help and example, I Make the same mistake, The key point is the service should be play_media.

1 Like

This is the way!

Hello,
I have made some flows with the normal flow builder to play mp3 files out a google home speaker.
That works fine.
But now i want to use Node-Red to do the same.
I can not get this to work.
Can somebody help me with this??

Thank you

Henk