Can't play local audio file to chromecast audio

Hi,

I cant play a local file to my chromecast audio. This is the current setup in my automation.yaml

- alias: 'test alarm sound'
  trigger:
    platform: state
    entity_id: input_boolean.input_boolean_test
    from: 'off'
    to: 'on' 
  action: 
    - service: media_player.play_media
      data:
        entity_id: media_player.audio_chromecast
        media_content_id: '/home/homeassistant/.homeassistant/media/alarm.mp3'
        media_content_type: 'audio/mp3'

I’ve also tried media_content_type: 'music' but that hasn’t worked either.
The input boolean works as I tested it with a push message and it worked fine.
Any ideas?

You can’t play local files, there is a bug report for this.

At this time you need to use your external url:

https://YOUR-URL.duckdns.org/alarm.mp3

Should also note that you would need to drop alarm.mp3 into your /home/homeassistant/.homeassistant/www forlder for this workaround to work. Also, I would think that you would be able to reference it with

http://:8123/alarm.mp3, but maybe not since there is a bug involved

Ok thanks. I spent a while trying to work it out. I don’t think the external url will work for me as it’s not exposed to internet.

I have since tried moving the file from /media to /www with no success but I haven’t tried referencing it through http://mylocalip:8123/alarm.mp3 since being in the /www folder so I’ll try. Cheers

Did you solve this?
I have my file in www folder of hass but all I get is 404: Not Found. Both using internal/external URL

No, I didn’t figure it out. If you can find a way please let me know

Try
media_content_id: http://hass_ip:8123/local/test.mp3
media_content_type: ‘music’

That doesn’t seem to work either. I think it might be an issue with casting to chromecast audios

As an initial test, shouldnt I be able to put http://hass_ip:8123/local/test.mp3 in browser and be able to access file?

Yes if you put in your own IP address in and have the mp3 file in the www directory.

The other thing you can try is.
http:
base_url: http://hass_ip:8123

I have just got it working using this

- alias: 'test alarm sound'
  trigger:
    platform: state
    entity_id: input_boolean.input_boolean_test
    from: 'off'
    to: 'on' 
  action: 
    - service: media_player.play_media
      data:
        entity_id: media_player.lounge_speakers
        media_content_id: https://myduckdns.duckdns.org/local/alarm.mp3
        media_content_type: 'audio/mp3'
4 Likes