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
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.
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
-
Folder structure
This is what I see in Visual Studio Code
-
Media Browser
I get an error.
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.
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?
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!)?
With Docker, if you write to a path that’s not mounted, the file will be located within the Docker container. If you run sudo docker exec -it homeassistant ls /media
(or sudo docker exec -it homeassistant /bin/sh
then ls /media
), you’ll see them. On a default Docker installation on Debian using overlay2 (which is the default unless you explicitly change it to use something fancy like ZFS), they’ll be somewhere in /var/lib/docker/overlay2/
.
Note that storing files within the container itself is a bad practice. They’re expected to be ephemeral, and things like docker compose down
and upgrading the Docker image will remove the entire container, including any files within it.
can you please guide how to change the path of the media folder. I am running homeassistant supervised on raspberry pi 4 with a debian 11 OS
Two years later and I’m trying to figure this out… I don’t understand the use of the new Media section if all media is root.
I’ve created ‘/config/media’ and added the following to my config file…
media_dirs:
local: /config/media
I’ve tried ‘/media/local/fam.png’ as path.
In checking paths via ‘ls’ in Terminal, my pics added to ‘Media/My media’ folder still show on root. If I’m not to use the Media section to link pictures to from within the Frontend (Dashboard card), do I need to manually upload them? So confusing.
Not only that, but one is in quotes and the other is not.
Sooooooo painful. Talk about putting all your geekery into question, this took me a long time to get right. HAdevs need to spend less time making nice thermostat cards. and spend more time on this.
Anyway, just wanted to say thanks. This worked for me. HAcore running on a HABlue Odroid. iOS notifications with image attachments - check.
Can you tell me what I’m doing wrong?
Configuration error!!!
Not a directory for dictionary value @ data[‘media_dirs’][‘media’]
my configuration.yaml for my home assistant core
# Loads default set of integrations. Do not remove.
default_config:
# Load frontend themes from the themes folder
frontend:
themes: !include_dir_merge_named themes
automation: !include automations.yaml
script: !include scripts.yaml
scene: !include scenes.yaml
homeassistant:
media_dirs:
media: /config/media
folder structure