#Play local sound using media_player.play_media or announce

1 messages · Page 1 of 1 (latest)

marble hill
#

Looking for some help with pathing audio. This works fine:

action: media_player.play_media
data:
  media_content_id: http://192.168.0.25:8123/local/alexaclone/broadcast.mp3
  media_content_type: music
target:
  entity_id: media_player.vaca_51de8bc0646f80c9_none

Catch is I want to change that media_content_id path to use the local file system but I can't for the life of me figure out the right way to do this. The above file is located in /config/www/alexaclone/broadcast.mp3 I've had this problem before but trying to solve it once and for all. Ideas? Is this limited to a url?

I Taking a step back, I am wanting to allow the user to select a standalone file with the assist_satellite broadcast action from a blueprint I ma writing. It seems to want to use the media_source rather than pick a file from the file system. I was trying to get the format correct by using the above but running into this pathing issue. So the real question is can I get broadcast to use a local file that is not called by url or stored as a media source?

storm vine
#
sequence:
                    - action: media_player.play_media
                      metadata:
                        title: creepy-hollow-369570.mp3
                        thumbnail: null
                        media_class: music
                        children_media_class: null
                        navigateIds:
                          - {}
                          - media_content_type: app
                            media_content_id: media-source://media_source
                          - media_content_type: ""
                            media_content_id: >-
                              media-source://media_source/local/music-for-ghost-stories
                      data:
                        media_content_id: "{{ random_audio }}"
                        media_content_type: audio/mpeg
                      target:
                        entity_id: media_player.living_room_homepod
#

I have an automation where I am using this to play local audio on a homepod speaker.

#
variables:
  random_audio: |-
    {{ [
      "media-source://media_source/local/music-for-ghost-stories/creepy-hollow-369570.mp3",
      "media-source://media_source/local/music-for-ghost-stories/mysterious-dark-background-310162.mp3",
      "media-source://media_source/local/music-for-ghost-stories/scary-horror-creepy-music-359998.mp3",
      "media-source://media_source/local/music-for-ghost-stories/scary-horror-music-351315.mp3",
      "media-source://media_source/local/music-for-ghost-stories/horror-background-atmosphere-slow-344899.mp3"
    ] | random }}
#

The media content is a variable in my automation but it does not need to be. I just wanted there to be some randomness to what plays.

#

I think this may require music assistant.

marble hill
#

//media_source/local/ is this the Home Assistant 'Media Sources' locacation or is the your own path? If the HA media location, I am not wanting to be forced to use that. This is part of a bigger project which will have media files stored in other directories.

storm vine
#

Location is the media folder for home assistant. /media.

#

For security reasons, you usually can't access files and folders from anywhere I think. You may have to do something to make the files accessible from a different folder. The default location does allow nesting folders.