|
1 | 1 | --- |
2 | 2 | title: "Setting up local media sources" |
3 | | -description: "More information on how to set up local media sources in Home Assistant." |
| 3 | +description: "Learn how to configure local media sources in Home Assistant so your audio and video files are available in the media browser." |
| 4 | +related: |
| 5 | + - docs: /more-info/local-media/add-media |
| 6 | + title: Adding your media to Home Assistant |
| 7 | + - docs: /integrations/homeassistant/#media_dirs |
| 8 | + title: Media directories configuration |
4 | 9 | --- |
5 | 10 |
|
6 | | -Home Assistant has a local media folder. Any audio or video files placed in this folder will be accessible via the media browser. |
| 11 | +Home Assistant includes a built-in media browser (in the sidebar under {% my media_browser title="**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. |
7 | 12 |
|
8 | | -The easiest way to manage your local media is using the tools accessible in the toolbar of the media browser when browsing the local media folder. |
| 13 | +On {% term "Home Assistant Operating System" %}, the `/media` folder is created automatically with no configuration needed. On {% term "Home Assistant Container" %}, you need to mount a volume to `/media` when starting your container. |
9 | 14 |
|
10 | | -## Using custom folders |
| 15 | +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](/integrations/http/#hosting-files), 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. |
11 | 16 |
|
12 | | -It is also possible to set up custom and additional media directories. To do |
13 | | -so, you'll need to adjust the [core configuration][basic-configuration]. |
| 17 | +## Setting up a media folder on Home Assistant Operating System |
14 | 18 |
|
15 | | -This example adds the two media folders to Home Assistant: |
| 19 | +No setup is required. The `/media` folder is automatically created and available in the media browser as soon as Home Assistant starts. |
16 | 20 |
|
17 | | -```yaml |
18 | | -# Example configuration.yaml |
19 | | -homeassistant: |
20 | | - media_dirs: |
21 | | - media: /media |
22 | | - recording: /mnt/recordings |
23 | | -``` |
24 | | -
|
25 | | -The above example adds two media folders to Home Assistant. They will |
26 | | -show up as "media" and "recording" in the media browser. You can add |
27 | | -as many media folders as you like, using any name you want. |
| 21 | +To add files, follow the [steps on adding media][add-media]. |
28 | 22 |
|
29 | | -## Home Assistant Container |
| 23 | +## Setting up a media folder on Home Assistant Container |
30 | 24 |
|
31 | | -If you run the Home Assistant Container you'll need to |
32 | | -add a Docker volume mount to the Home Assistant container, to mount in |
33 | | -your local media. |
| 25 | +On {% term "Home Assistant Container" %}, 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. |
34 | 26 |
|
35 | | -The default path Home Assistant will try to use, is `/media`. |
| 27 | +### Using Docker CLI |
36 | 28 |
|
37 | | -For example, if you are currently using this command for Docker: |
| 29 | +Add `-v /PATH_TO_YOUR_MEDIA:/media` to your `docker run` command: |
38 | 30 |
|
39 | 31 | ```bash |
40 | | -docker run -d --name="home-assistant" \ |
| 32 | +docker run -d \ |
| 33 | + --name homeassistant \ |
| 34 | + --privileged \ |
| 35 | + --restart=unless-stopped \ |
| 36 | + -e TZ=MY_TIME_ZONE \ |
41 | 37 | -v /PATH_TO_YOUR_CONFIG:/config \ |
42 | | - -v /etc/localtime:/etc/localtime:ro \ |
43 | | - --net=host \ |
| 38 | + -v /PATH_TO_YOUR_MEDIA:/media \ |
| 39 | + -v /run/dbus:/run/dbus:ro \ |
| 40 | + --network=host \ |
44 | 41 | {{ site.installation.container }}:stable |
45 | 42 | ``` |
46 | 43 |
|
47 | | -You'll need to change it to this: |
| 44 | +### Using Docker Compose |
48 | 45 |
|
49 | | -```bash |
50 | | -docker run -d --name="home-assistant" \ |
51 | | - -v /PATH_TO_YOUR_CONFIG:/config \ |
52 | | - -v /PATH_TO_YOUR_MEDIA:/media \ |
53 | | - -v /etc/localtime:/etc/localtime:ro \ |
54 | | - --net=host \ |
55 | | - {{ site.installation.container }}:stable |
| 46 | +Add a volume entry for `/media` in your `compose.yaml` file: |
| 47 | + |
| 48 | +```yaml |
| 49 | +services: |
| 50 | + homeassistant: |
| 51 | + container_name: homeassistant |
| 52 | + image: "{{ site.installation.container }}:stable" |
| 53 | + volumes: |
| 54 | + - /PATH_TO_YOUR_CONFIG:/config |
| 55 | + - /PATH_TO_YOUR_MEDIA:/media |
| 56 | + - /etc/localtime:/etc/localtime:ro |
| 57 | + - /run/dbus:/run/dbus:ro |
| 58 | + restart: unless-stopped |
| 59 | + privileged: true |
| 60 | + network_mode: host |
| 61 | + environment: |
| 62 | + TZ: Europe/Amsterdam |
56 | 63 | ``` |
57 | 64 |
|
58 | | -If you are using Docker compose, you can add a volume to your composition file |
59 | | -in a similar fashion as listed in the command above. |
| 65 | +After restarting the container, your media files will appear in the media browser, under {% my media_browser title="**Media** > **My media**" %}. |
| 66 | +
|
| 67 | +To add files, follow the [steps on adding media][add-media]. |
| 68 | +
|
| 69 | +## Adding additional media directories |
| 70 | +
|
| 71 | +This applies to both {% term "Home Assistant Operating System" %} and {% term "Home Assistant Container" %}. |
| 72 | +
|
| 73 | +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. |
| 74 | +
|
| 75 | +### Prerequisites |
| 76 | +
|
| 77 | +- If you want to use media from a network storage, connect the network storage first. |
| 78 | + - Refer to the [instructions on how to connect network storage](/common-tasks/os/#network-storage). |
| 79 | + - Once connected, the media from network storage is automatically added to the local media browser. |
| 80 | +
|
| 81 | +### To add additional media directories |
| 82 | +
|
| 83 | +1. Open your {% term "`configuration.yaml`" %} file. |
| 84 | +2. Under `homeassistant:`, add a `media_dirs:` entry with one or more directories: |
| 85 | + |
| 86 | + ```yaml |
| 87 | + homeassistant: |
| 88 | + media_dirs: |
| 89 | + media: /media |
| 90 | + recordings: /mnt/recordings |
| 91 | + photos: /mnt/photos |
| 92 | + ``` |
| 93 | + |
| 94 | + Each key is the label that appears as the folder name in the media browser. For example, `recordings` will show up as "recordings" in the media browser, pointing to `/mnt/recordings` on disk. |
| 95 | + |
| 96 | +3. Save the file and [reload the configuration](/docs/configuration/#reloading-the-configuration-to-apply-changes) to apply the changes. |
| 97 | +4. To add files, follow the [steps on adding media][add-media]. |
60 | 98 |
|
| 99 | +[add-media]: /more-info/local-media/add-media |
0 commit comments