Media_dir configuration

hi, i’m sorry, i’ve been trying for hours and nothing i find online is working for me - please help?

i’m running HA container and want to play music stored on the same intelNUC as docker/HA.
i want to be able to stream the music from any networked device - i’m assuming this is possible?
for the avoidance of doubt i can ftp to srv/music

i’m not exactly clear how this is supposed to work, i think (please correct me!):

  1. in docker-compose.yaml i map a real location to the HA container
  2. in HA configuration.yaml i declare media_dirs
    done.

or maybe i need to add a whitelist for external dir, so i did that too but still no media or new folders in media browser…
i’ve tried a load of ways, but the most recent attempt looked like this:

HA configuration.yaml:
default_config:
  whitelist_external_dirs:
    /srv/music
  media_dirs:
    media/music: srv/music
docker-compose.yaml:
  homeassistant:
    container_name: homeassistant
    image: "ghcr.io/home-assistant/home-assistant:stable"
    ports:
      - "8123:8123/tcp"
    volumes:
      - /opt/ha/config:/config
      - /etc/localtime:/etc/localtime:ro
      - /run/dbus:/run/dbus:ro
      - /srv/music:/music
    restart: always
    privileged: true
    network_mode: host

These physical to docker virtual to home assistant mappings require a good dose of :wine_glass: and/or :beer:. So I use docker run not docker compose, so a bit different syntax there.

Be careful of you use or lack of use of ‘slashes’ in your directory specification, this is significant and you seem to be combining directories that start with a slash and directory references that do NOT start with a slash…

On this Ubuntu box, I have physical directory /media where a mount all the ‘shares’ that I want exposed. Then in Docker, I give the container a map to this physical directory to a identical virtual directory in the container named and located the same /media

So the Docker container has a /media directory as well as a /config directory that are mapped to physical /media and physical /home/user/homeassistant

so if I shell into my HA Docker container via Portainer (you can do similar with Docker commands without Portainer) and move to the ‘root’ directory that the container sees. There are the two physical directories exposes as the Docker virtual counterparts and described above, see picture:

Now in HA, you use the virtual directory paths in configuration.yaml

So in the whitelist section, I give access to the ‘root’ of the container, I think the ‘/tmp’ might be unneeded.

Then under this ‘root’ create these nice alias names for the ‘Media Sources’ part of Home Assistant.

I hope I got this correct, and hope it is not too foggy. Good hunting!

---- configuration.yaml, watch your indenting
network:
  media_dirs:
    local: /media
    recording: /media/macmini2014-share/raid01/webcam-videos/frigate/foscam-z2/clips
  

# whitelist_external_dirs:
  allowlist_external_dirs:
    - /
    - /tmp

media_source:

media_player:


---- create and start docker image
docker pull homeassistant/home-assistant:2022.9.7

docker run -i -t -d --name="home-assistant-2022.9.7" \
	-v /home/user/homeassistant:/config \
	-v /media/:/media \
	-v /etc/localtime:/etc/localtime:ro \
	--net=host \
	homeassistant/home-assistant:2022.9.7

Awesome, that looks super useful, thanks!

I just got into bed (and used my new aqara button to switch my lights :heart:) but I’ll check it out tomorrow…

BTW I notice your media_dirs is nested under network, I haven’t seen that before - is it how it has to be, or are you doing it differently for some reason?

I do not use my music archive any more and I am addicted to streaming audio services. However, yes my video library and home security camera video archives are stored on a Synology NAS and old Linux base RAID device. The machine that hosts the Home Assistant Docker container, does not have any of these files local, yes they are network mounts in the /media local directory. When I bring down the Home Assistant system for maintenance, yes there is a set of steps, some automated, some not that I go thru before starting HA. The check that the network volumes are mounted is one of these.

Hope I helped and did not confuse, good luck. So far the media stuff has worked well for me in HA. As I said once I got a basic understanding of the three parts: physical local, Docker virtual and Home Assistant .yaml mapping of locations, things were good.

1 Like

I have a HA in Docker (Debian).
This is what I see:

изображение

изображение

Since I have no floppy / cd-rom / usb stick, I cannot find out what are these enigmatic “folders” for.
What is a meaning of these “folders”?

Also, I see a button on the right top corner:

изображение

“manage” what?

After pressing the button I see this:

изображение

And each label is absolutely confusing:

  1. Where these media files not found?
  2. What means “folders cannot be managed”, how are they supposed to be managed - via yaml?

If I press the “Add media” button - I see a Windows Explorer. After selecting a small mp3 file this is displayed:
изображение

I got an impression that this whole functionality is like an alpha version of some functionality which:

  1. has no clear Docs
  2. was not tested
  3. not user-friendly.

May be it works. But where it is documented then?