Media folder location?!

I can’t seem for the love of god seem to figure out where the “new” media folder is located.
I’m running HassOS.
My testing tells me it’s not;

  • At the “actual” root; /media - this folder already has “cdrom”, “usb”, and “floppy”
  • At the /root; this is where I see addons, backup, config, share, and ssl.
  • At the /root/config; there’s no folder in here called media.
  • At /home/hassio - that folder is just empty.

The information here must be wrong - if that suggests the first point in my case.
I tried creating a new subdirectory and setting a media_dirs: to that folder but then I get this error;

not a directory for dictionary value @ data['media_dirs']['media']

Why can’t the media tab just show where it is located? Why do we have to guess?

4 Likes

I had the same problem in my Home Assistant installation. To fix this, I created a directory titled “media” in my config folder.

For the configuration I used

homeassistant:
  media_dirs:
    media: /config/media

For some reason the media directory in the root folder would not work whatsoever so I had to declare it myself.

4 Likes

I think it’s just on HassOS that it was assumed it would work flawlessly for all, so there is no real mention of location.

homeassistant:
  media_dirs:
    media: /config/media

Thanks, man! This should be in the official documentation!

1 Like

I can confirm this was the only way I was able to get this to work and I spent hours trying multiple configuration options. The only way it worked was when I decided to user a different folder as suggested by @jaxonstagecrew and add media_dirs to my config.yaml. I tried just using a different folder without editing my config.yaml and it did not work.

It is. In two different locations.

1 Like

So what is the conclusion? For hassos we have to use the /config/media folder for this? If I want to use /mnt/media, it won’t work?

None of those mention /config/media

3 Likes

It seems the documentation is not up to date or is incorrect.
It shows that an external directory like /mnt/recordings can be specified but that’s incorrect. You can only specify directories within the directories that are mapped on the docker process as volumes. I see the following volumes mapped on my homeassistant docker process

vijay@debian-home:/mnt$ docker inspect -f '{{ .Mounts }}' homeassistant
[{bind  /etc/machine-id /etc/machine-id  ro false rprivate} {bind  /usr/share/hassio/tmp/homeassistant_pulse /etc/pulse/client.conf  ro false rprivate} {bind  /usr/share/hassio/audio/asound /etc/asound.conf  ro false rprivate} {bind  /run/dbus /run/dbus  ro false rprivate} {bind  /usr/share/hassio/homeassistant /config  rw true rprivate} {bind  /usr/share/hassio/ssl /ssl  ro false rprivate} {bind  /usr/share/hassio/share /share  rw true rprivate} {bind  /usr/share/hassio/media /media  rw true rprivate} {bind  /usr/share/hassio/audio/external /run/audio  ro false rprivate}]
vijay@debian-home:/mnt$

If I am incorrect in saying this , please correct me.

Is there a way to use a USB stick as the media source?

is there a way to add a PC folder or Synology folder as the media source?

For anyone who comes across this and is looking to use external urls for notifications like I was here’s a few pointers. Just like the OP says, the documentation is terrible and I spent hours on this.

I have Core/OS on Rasp Pi. That makes a difference per the documentation. So don’t follow my instructions if you have a containerized version.

First you need to create a media folder in the config folder. This would be root/config/media. If you use visual studio or file editor you can’t get to root. The easiest way to know you’re in the right spot is if the configuration.yaml is in the same location. That’s where you want to create the media folder.

The OP states that he made the following change:

However if you do this then your relative URL will be /media/media instead of media/local. Per the instructions here you should make this local like so:

homeassistant:
  media_dirs:
    local: /config/media

Make sure that you put /config/media otherwise your root/media folder will be used. The official documentation that I linked only says /media. While I was able to get the media browser to show files in root/media it’s not a very accessible location should you need to make changes.

When linking an image, video or audio clip to a notification you should only put the relative URL only. So if you wanted to send an image to your mobile you would do so like this:

image: "/media/local/image.png"

For the media folder you DO NOT need to add allowlist_external_dirs as others mention.

Lastly, even though you can be logged in through your local browser to home assistant, the URL path will fail without the authSig key. Since one is not generated when you copy/paste the URL in the browser you will not be able to access the media folder without using the built in media browser. So DO NOT test the media folder access using a URL directly in the browser. It will fail.

Hope this helps anyone who comes across this.

9 Likes

I am still going nuts with this issue. I have just changed the config - I hope - to what you have suggested above:

  • configuration.yaml
homeassistant:
  customize: !include customize.yaml
  media_dirs:
    local: /config/media

I tried to change configuration.yaml folder back to

media_dirs:
    media: /config/media

I still cannot browse the media. Correction: I just realized that the Media Browser is specific to a media player. I can conform that I can see the media in the Media Browser for the Google Mini’s but not for the Sonos players.

However, when I go to the media players, I can select and play the sounds on my Google/Nest Mini’s


However, if I try to select media from one of the Sonos media players I get an error.

I am at my wits end!!! Any and all help will be greatly, greatly appreciated.

Did you ever find a solution to this? I’m at the same point. I can get a file to cast to Google Home after creating the folder and declaring it in config.yaml as suggested by @DevOpsTodd , but can’t get it working for Sonos. So infuriating! TTS to Sonos works, so there must be a way to send a local file.

I am also having this problem. It’s infuriating that something this simple isn’t working because of bad documentation.

media_dirs:
  local: /media

or

media_dirs:
  local: /config/media

Gets me this error, Integration error: media_dirs - Integration 'media_dirs' not found.

i am having the same issue, i am using it on debian supervised, but i want to have it use the external hdd or share

I was also having the same issue with the supervised container installation. I found a solution with a simpler approach.

The supervised container for homeassistant mounts /usr/share/hassio/media to /media within the container. See the output of docker inspect -f '{{ .Mounts }}' homeassistant command.

So, in /etc/fstab, I added my “bind” mount point over /usr/share/hassio/media. My example line if /etc/fstab is here:

/home/media /usr/share/hassio/media none defaults,bind 0 0

When the docker container is started, it now sees the contents of /home/media where /usr/share/hassio/media is located, and that is what is /media within the homeassistant container.

I added a file called filetest89734364783209847128374681234872342341234234.mp3 and found it with the find command.
image
It is in the root directory so you can’t access it from the rest of HA

I think the best option is adding another config directory like @jaxonstagecrew did:

This is just for information

Thanks,

Inglan

Like everyone else, I feel like I’m going crazy here. I am running HomeAssistant OS on an SBC (RPI4).

Configuration.yaml

homeassistant:
  media_dirs:
    media: /config/media

Card where I’m trying to render the picture

cards:
  - variables:
      person: person.norm_rasmussen
      bg: |
        [[[
          if (states['person.norm_rasmussen'].attribute == 'Home')
            return 'url(/config/media/pictures/norm_home.PNG)';
          return 'url(/config/media/pictures/norm_work.PNG)';
        ]]]

This is what loads in the card. It is looking for the picture, but won’t load it? Am I just an idiot in regards to this?
Screen Shot 2022-05-11 at 12.26.14 PM

New to this… but just want to add what I observed so far to this (rather old) thread - I’m running Home Assistant in docker compose mode and the following doc really helps (in addition to the 2 doc pages linked above):

https://www.home-assistant.io/more-info/local-media/setup-media

I have a docker volume mount to /media to my compose.yml file (this is for docker compose):

services:

  homeassistant:
    container_name: homeassistant
    image: "ghcr.io/home-assistant/home-assistant:stable"
    volumes:
      - /home/pi/hass:/config
      # added this:
      - /home/pi/media:/media
      - /etc/localtime:/etc/localtime:ro
    restart: unless-stopped
    privileged: true
    network_mode: host

The default in HA is to look for files in /media. So whatever files I stick into my /home/pi/media folder on raspberry pi, they will show up in the Home Assistant media folder under the “Local Media”.

However, what I notice is that if I DO NOT mount the volume in docker as done above, the HA media will show 3 folders : “cdrom”, “floppy”, and “usb”. I can then click on “Manage” on the right corner and add my files from my PC or my phone (via the companion app). The question is - where are these files located (which is the original OP question!)?