Setting up local media sources
Home Assistant includes a built-in media browser (in the sidebar under Media > My media) that lets you browse and play your local media files. Before you can use it, you need to make sure your media files are accessible to Home Assistant.
On Home Assistant Operating SystemHome Assistant OS, the Home Assistant Operating System, is an embedded, minimalistic, operating system designed to run the Home Assistant ecosystem on single board computers (like the Raspberry Pi) or Virtual Machines. It includes Home Assistant Core, the Home Assistant Supervisor, and supports apps. Home Assistant Supervisor keeps it up to date, removing the need for you to manage an operating system. Home Assistant Operating System is the recommended installation type for most users., the /media folder is created automatically with no configuration needed. On Home Assistant ContainerHome Assistant Container is a standalone container-based installation of Home Assistant Core. Any OCI compatible runtime can be used, but the documentation focus is on Docker. [Learn more], you need to mount a volume to /media when starting your container.
Files stored in your media directories are only accessible to users who are logged in to Home Assistant. This is different from the www folder, where files are publicly accessible without a login, which is useful for things like images in notifications, but not something you typically want for your personal media library.
Setting up a media folder on Home Assistant Operating System
No setup is required. The /media folder is automatically created and available in the media browser as soon as Home Assistant starts.
To add files, follow the steps on adding media.
Setting up a media folder on Home Assistant Container
On Home Assistant ContainerHome Assistant Container is a standalone container-based installation of Home Assistant Core. Any OCI compatible runtime can be used, but the documentation focus is on Docker. [Learn more], you need to mount a directory on your host machine to /media inside the container. This must be done when starting or recreating the container.
Using Docker CLI
Add -v /PATH_TO_YOUR_MEDIA:/media to your docker run command:
docker run -d \
--name homeassistant \
--privileged \
--restart=unless-stopped \
-e TZ=MY_TIME_ZONE \
-v /PATH_TO_YOUR_CONFIG:/config \
-v /PATH_TO_YOUR_MEDIA:/media \
-v /run/dbus:/run/dbus:ro \
--network=host \
{{ site.installation.container }}:stable
Using Docker Compose
Add a volume entry for /media in your compose.yaml file:
services:
homeassistant:
container_name: homeassistant
image: "{{ site.installation.container }}:stable"
volumes:
- /PATH_TO_YOUR_CONFIG:/config
- /PATH_TO_YOUR_MEDIA:/media
- /etc/localtime:/etc/localtime:ro
- /run/dbus:/run/dbus:ro
restart: unless-stopped
privileged: true
network_mode: host
environment:
TZ: Europe/Amsterdam
After restarting the container, your media files will appear in the media browser, under Media > My media.
To add files, follow the steps on adding media.
Adding additional media directories
This applies to both Home Assistant Operating SystemHome Assistant OS, the Home Assistant Operating System, is an embedded, minimalistic, operating system designed to run the Home Assistant ecosystem on single board computers (like the Raspberry Pi) or Virtual Machines. It includes Home Assistant Core, the Home Assistant Supervisor, and supports apps. Home Assistant Supervisor keeps it up to date, removing the need for you to manage an operating system. Home Assistant Operating System is the recommended installation type for most users. and Home Assistant ContainerHome Assistant Container is a standalone container-based installation of Home Assistant Core. Any OCI compatible runtime can be used, but the documentation focus is on Docker. [Learn more].
You can expose more than one media directory to the media browser. For example, a network storage path on Home Assistant OS, or an additional mounted volume on Home Assistant Container.
Prerequisites
- If you want to use media from a network storage, connect the network storage first.
- Refer to the instructions on how to connect network storage.
- Once connected, the media from network storage is automatically added to the local media browser.
To add additional media directories
-
Open your
configuration.yamlThe configuration.yaml file is the main configuration file for Home Assistant. It lists the integrations to be loaded and their specific configurations. In some cases, the configuration needs to be edited manually directly in the configuration.yaml file. Most integrations can be configured in the UI. [Learn more] file. -
Under
homeassistant:, add amedia_dirs:entry with one or more directories:homeassistant: media_dirs: media: /media recordings: /mnt/recordings photos: /mnt/photosEach key is the label that appears as the folder name in the media browser. For example,
recordingswill show up as “recordings” in the media browser, pointing to/mnt/recordingson disk. -
Save the file and reload the configuration to apply the changes.
-
To add files, follow the steps on adding media.