Hassio and local audio

So, the media_player platform configuration in configuration.yaml is set according to the MPD instructions, but the media player card on my dashboard shows that the MPD media player is unavailable. I’ve tried every combination of URL from the https to http with duckdns to the internal IP address of the system. While I can access Mopidy and stream music from the media folder on my Pi3, I can’t get Hassio to recognize it. Ideas?

Hi all,

I’m new on hass.io and I was wondering if someone find out how to use usb speaker with it.

(in particular I will use a jabra 410).

Please help.
I have tried a lot of options but can’t get my usb speaker on the raspberry pi to play a local mp3 file.
I installed the mopidy add-on for Hass.io
Mopidy options:
{
“local_scan”: true,
“options”: [
{
“name”: “local/media_dir”,
“value”: “/share/mopidy/media/”
},
{
“name”: “m3u/playlists_dir”,
“value”: “/share/mopidy/playlists/”
}
]
}

My configuration:
media_player:

  • platform: mpd
    host: 192.168.1.101

My test automations:

Google TTS worked as follows
- service: tts.google_say
data:
message: “Good Morning”

I load an mp3 file in the directory /share/mopidy/media/
And a playlist file with one of the mp3’s in /share/mopidy/playlists/

Tried a couple of options but no sound on the usb speaker
entity_id: media_player.mpd
media_content_type: music
media_content_id: /share/mopidy/media/test.mp3

or

      entity_id: media_player.mpd
      media_content_type: playlist
      media_content_id: testlist

The only option that played the mp3 on the speaker was:
In this test the mp3 for this test was in the www directory
media_content_id: https://my-domain.duckdns.org:8123/local/test.mp3

Does it mean I can only play a local mp3 if I have an internet connection? Or can you spot an error in the settings above?
Thanks in advance.

Did you ever figure out how to change the output back to the audio jack?

Did you manage to find out what the media_content_id should be for audio files stored in /share/mopidy/media?

1 Like

yes see https://community.home-assistant.io/t/tts-using-built-in-rpi3-analogue-audio-output-with-hassio/32475/20 Basically this work for me also
{
“entity_id”: “media_player.mpd”,
“media_content_type”: “music”,
“media_content_id”: “local:track:test.mp3”
}

1 Like

Thanks! It worked for me. I can call the service and play the local mp3 files.

However, when I tried to play the mp3 file in a automation.yaml, it doesn’t work.

  • action:
    • data:
      entity_id: media_player.mpd
      media_content_id: local:track:test.mp3,
      media_content_type: music
      service: media_player.play_media

I have an error that logged “Error doing job: Task exception was never retrieved”. Any suggestions?

mine looks like this:

action:
..- service: media_player.play_media
....data:
......entity_id: media_player.mpd
......media_content_id: local:track:test.mp3  
......media_content_type: 'music'

Note I have just added the … to get some spacing

Thanks!!! All good now. I just needed to restart the mopidy music service. Thanks again for the assistance. :slight_smile:

Hey @arretx did you solve the MPD unavailable issue? I am having the same problem

I have the same issue concerning the unavailable media_player. What i did learn from the logs though is that the mediaplayer is trying to acces the wrong url:

it’s trying to reach: https://xxxxx.duckdns.org:8123/api/tts_proxy/etc

the correct url is:
https://xxxxx.duckdns.org/api/tts_proxy/etc

I tried everything, but i can’t get mopidy to get the url request right, but this is probably the reason it returns ‘unavailable’.

I am using hass.io. I didn’t have a www directory inside config so I created it. However, when I dropped my files into that directory I was unable to retrieve them using a URL. Do I need to do anything special when using duckdns?

solved: I didn’t realize you have to restart ha after creating the folder.

Here is how I solved to play MP3/WAV files using mopidy on a HASS.IO system:

https://www.amalytix.com/en/home-assistant-with-conbee-ii-deconz-xiaomi-aqara-and-hass-io-from-scratch/#play-audio-1

This worked a treat for me! Way better than VLC / Modipy

FYI you need to update your config.json to include this line to get it to work properly:

“arch”: [“armhf”, “armv7”, “aarch64”, “amd64”, “i386”],

1 Like

you are a life saver ! … install of the Addon worked after your suggestion. However I wasn’t able to call the service. I used the below format but its not even allowing me to save it. Under developer tool “call service” area. when i select the service and put the data. it says incorrect json. I also tried in the automation and tried to call this service there but it is not even saving the data portion of the service. What am i doing wrong.

service: hassio.addon_stdin
data:
addon: local_audio_player
input: “http://localhost:8123/local/doorbell.mp3

Hit and trial and got it to work. Used below json format to call the service .

The only issue now is the audio plays but it cuts off before it completes. For example. say, the audio file is 3 seconds. but it cuts off after 2 sec. does anyone know why its happening?

{
“addon”: “local_audio_player”,
“input”: “http://<local_ip>:8123/local/audio/03-back-door-open.mp3”
}

Hello, i’m working to play local audio file through audio jack in my home assistant running in docker and then i ended up here.
Is this solution still aplicable? Because i tried to install this addons after following steps over here, but no addons shows up. Can you please help me? Thanks.

1 Like

Hi, I’m also running home assistant/HASSIO in docker. I’ve installed the add on.

I added BestLibre repository to the add-on store and then installed the Mopidy add on from there.

It seems to be running an all, but I don’t see a media player in developer tools to play the audio from. Am I supposed to be seeing media_player.mpd somewhere or is it added separately?

I think you should try to add media_player.mpd in the configuration.yaml file.

Thanks mate. I suppose that is pretty obvious, thanks for the reply.