Adding Media Folder Mapping from NAS via NFS

Hi All - Just wanted to share;

After several unsuccessful tries over the years, got the media folders mapped from my NAS library and it works.

In order to do this please ensure your NFS (nas) server:

  • has a static IP
  • has the required shares exposed
  • all shares have the appropriate permissions

Prepare The HA:

  1. Open Terminal session to your HA host
  2. Most of you are running on docker so you will need to access your homeassistant docker instance
docker exec -it $(docker ps -f name=homeassistant -q) bash
  1. Create a folder(s) within /media/ folder of your choice in my case I have 2
mkdir /media/MOVIES
mkdir /media/MUSIC
  1. Next test if you are able to mount manually from the command line. This would be used later to create a shell command service.

eg.

mount -t nfs4 192.168.1.5:/MOVIES /media/MOVIES
  1. See if the mapped content is visible in HA in the media folder in your lovelance interface
  2. If successful we will now need to create an automation so each time you reboot the docker or the host, mapping will happen again

Start by editing your configuration.yaml to add the shell commands which will become callable by automations.

Add the following lines, ensure they are the same command as used for testing in step 4.

# Custom Shell
shell_command:
  map_nas_video_folder: mount -t nfs4 192.168.1.5:/MOVIES/ /media/MOVIES
  map_nas_music_folder: mount -t nfs4 192.168.1.5:/MUSIC/ /media/MUSIC

Next restart your HA instance as the new command needs to be added by the configuration you’ve added above.

Once restarted you can check your media folders again, and you’ll see that your MOVIES, MUSIC folders are empty

  1. Create automation with each start of HA, to execute shell commands we’ve defined above.
- id: '1611345337440487'
  alias: 'Mount NFS Folders'
  description: ''
  trigger:
  - platform: homeassistant
    event: start
  condition: []
  action:
  - service: shell_command.map_nas_video_folder
    data: {}
  - service: shell_command.map_nas_music_folder
    data: {}
  mode: single
  1. Restart HA, you should now see the folders in your media and content mapped from your NAS.

Enjoy casting or playing back your favorite files through the HA interface.

13 Likes

Hi all,

New to HomeAssistant and found this old post when looking for something similar. I am using HA 2023.11.0. I decided to reply to this old thread with my approach in case other people like me try to find this :slightly_smiling_face:

I am using ‘docker’ as well and mounted an NFS volume on the host (under /media/doodles) and then passed it as a volume to docker (also as /media/doodles, see below). My media are now visible under the Home Assistant Media browser in the sidebar (http://xxx:8123/media-browser/browser) and I can play them on my devices. Yeah !!

For completeness, my docker launch command looks like this:

docker run -d \
  --name homeassistant \
  --privileged \
  -d \
  -e TZ=Europe/Brussels \
  -v /home/wijle/homeassistant/config:/config \
  -v /media/doodles:/media/doodles \
  --network=bridge \
  -p 8123:8123 \
  ghcr.io/home-assistant/home-assistant:stable
1 Like