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

I do have a media player named: media_player.zithoek
I did store a mp3 file on: config/tts/doorbell.mp3

How to play the mp3 on the media player, using node-RED?
I did try to use call service node, without succes?
Please help

1 Like

I tried without succes:

What is wrong?
How does it need to look like?

I’ve been trying to play white noise for my kids speakers lately without much luck.
I haven’t tried from Node-Red.
I know there’s the /www folder but I don’t know if Add-Ons can access that.

I will look into this this weekend because it’s something on my list of things to do.
I have a NAS drive and Plex at my disposal so it’ll be interesting to see if either of those can help.
I’m a little weak when it comes to Linux permissions, so if something can hang a file on the network where Node-Red doesn’t have to cut through red tape it might help, like DLNA, which I think both Plex and my NAS can do.

Thanks in advange

You should probably put the file under /config/www and ha will serve it via http[s].

1 Like

I do not have this directory.
But I like to know the right syntax and node-red tiles to use.
How does the tiles and syntax in node-RED look like for sending an mp3 to a mediaplayer?

Can somebody give an example how to play a MP3 to Home google mini?
I’m struggling now for more then a week without succes.
Or can somebody give me a direction to a url what explanes/ examples how to do?

1 Like

Follow what I suggested.

ok this worked for me:

entity_id: media_player.basement_speaker
media_content_id: "https://<HA-ADDRESS>/local/media/12hrwhitenoise.mp3"
media_content_type: music

Thanks
I will try tonight

1 Like

I tried again without succes I did:

Giving an API error
I think the JSON code isnt correct
I did try audio/ mp3 as music as well

Ya know I did it in NR but I did it first in HA services to let you see it generically.
I’ll copy what I have for NR.

{
    "media_content_id": "https://SecretAddress.ui.nabu.casa/local/media/12hrwhitenoise.mp3",
    "media_content_type": "music"
}

Here’s the actual node:

[{"id":"682d29bd.2348c8","type":"api-call-service","z":"43ff6cf5.198a24","name":"Play White Noise","server":"c8b3e58.9a76e18","version":1,"debugenabled":false,"service_domain":"media_player","service":"play_media","entityId":"media_player.kids_speaker_group","data":"{\"media_content_id\":\"https://SecretAddress.ui.nabu.casa/local/media/12hrwhitenoise.mp3\",\"media_content_type\":\"music\"}","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":1130,"y":640,"wires":[[]]},{"id":"c8b3e58.9a76e18","type":"server","z":"","name":"Home Assistant","legacy":false,"addon":true,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":true,"cacheJson":true}]
1 Like

Strange.
I do exactly the same (in my opinion), but for me it gives an API error.
You also uses Home Assistant and not hass.io?
The https adress until “/ocal” is your login to HA?
or means " .ui.nabu.casa" something?
or is maybe my “/config/tts/” blocked for reading or so?
I realy don’t understand what I’m doing wrong

The error is in the media_content_id ??
Do I miss a setup or so?
Or is it not accessable?

How to test this without NR?
)Until now I only use NodeRed)

I use what is now called Home Assistant, formerly HASS.IO

I subscribe to Home Assistant Cloud which generates a secure URL for me to access Home Assistant through.
If you don’t it should be your “Base URL”.
Local URL might work but it might also fail due to certificate errors.

If you click on the ... button I’ve highlighted here can you take a screenshot of what you see:

My example:

My JSON lacks the entity ID because it’s already been selected above where Data goes.

Thats what I did send above:

I also tried music as media_content_type: music

I’m confused your first screenshot showed your media_content_type being set to music.
Now it’s audio/mp3.
Have you tried both?

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