Point media_dirs: at NAS share?

Disregard - found help on Reddit!

If anyone is wondering:
‘cd /media/frigate/clips;for file in *.mp4;do cp -u “$file” /media/camsonplex/"$(TZ=America/New_York date -r “$file” +"%Y%m%d_%H_%M_%S")_${file:0: -29}.mp4";done’

Great idea!

I think a file sensor in HA would be the best solution.
Any ideas how to implement this?

Dominik - That may be a better solution that I have not looked into. My guess is you’d have to set the sensor to run the shell command when a new file is detected. Might even be possible through the sensor to identify the specific file name and avoid my for loop solution.

The 5-minute check is a bit wasteful as it could be hours between actual clip generation. The “-u” flag prevents it from continually overwriting existing files though. It only actually writes new files over.

it needs testing, but would it be as simple as putting a text file in a location with a status of “up”

so text file on NAS called sensor.json
{“nasshare”: “up”}


  - platform: file
    name: Media_Status
    file_path: /<media mount>/<directory>/sensor.json
    value_template: '{{ value_json.media_up }}'
    unit_of_measurement: "status"

Honestly not sure if this will “just work”, probably best to try with a local file before making it a remote file. testing might just involve renaming the file

@Dominik.W thanks for reawakening my interest in this question. I believe I may have found an even easier way :slight_smile: This is completely inspired by your service which launched a command from within a docker container

As above - much cleaner approach and helps keep us out of the linux shell :slight_smile: Of course confirming the command works in the shell is definitely appropriate.


  mount_media: mount -v -t cifs -o vers=1.0,noserverino,username=<youruser>,pass=<yourpass>,domain=WORKGROUP,sec=ntlm //192.168.1.x/Music /media

Then create an automation:
Name: Mount Media on Start

Trigger type: Home Assistant
Event: start


Action type: Call service
Service: shell_command.mount_media

Now to figure out the file sensor … and a tweaked automation to remount if the folder/mount drops.


Thanks a lot for your command and automation. For me the command in terminal is working fine and I have no issue to see all my movies on my NAS in the terminal when I list the mounted dir.

But whenever I add the mounted folder to a media library (Jellyfin in this case) it says the mount folder is empty.

Any idea?

Hey @bjornb the first time I mounted it, I had a similar experience, what was critical was to mount it as /media that is the default location for the media integration to look for files. On my system /media is empty by default

Also see this post for an example:

Been reading through with great interest as this is exactly what I’m trying to do.
Am I right in thinking this method means we don’t have to do anything with portainers and it can be done straight into config.yaml?
I’m running HA Blue so don’t want to complicate things if I can at all avoid it.
So far I’ve got;
mount_media: mount -v -t cifs -o vers=1.0,noserverino,username=guest,pass=,domain=WORKGROUP,sec=ntlm // /media

media: /media`
But aren’t seeing anything in the media folder after several attempts & restarts.

In answer to your first question then yes, assuming all dependencies are installed it should just work.

Can you ssh/putty into your HA blue box to get into a command prompt?
You should be able to test and see if it works, run the mount command and then use the ‘ls’ command to view the folder.

Alternatively, assuming HA Blue has portainer installed, you can use the exec console and test the commands by attaching to the home assistant container

Thanks Markss, not tried ssh but I can access no problem with the samba client on my phone.
I’ve installed the samba add on obviously but nothing else, which other dependencies are you referring to, do I need ssh?
Edit, just remembered ssh is pre-installed on HA Blue but is not on my media server. I’ll install later & see how I go on.

Not sure if it can be called a step forward but I installed SSH server & can access the directory where my music is stored from another device on my Lan but still no result with HA being able to do so. I do however now get this error log.
Logger: homeassistant.components.shell_command
Source: /usr/src/homeassistant/homeassistant/components/shell_command/init.py:113
Integration: Shell Command (documentation, issues)
First occurred: 9:29:52 (3 occurrences)
Last logged: 10:46:25

Error running command: mount -v -t cifs -o vers=1.0,noserverino,username=xxxxx,pass=xxxxx,domain=WORKGROUP,sec=ntlm // /media, return code: 111
NoneType: None

Just in case somebody missed it:

1 Like

John, did you ever figure out a solution using HA Blue?

Hey Dax, no didn’t get any further with it.
Seems like it should work and I’m sure it’s just my inexperience & lack of knowledge.

Thanks to all the posts in this thread I’ve been able to mount my NAS from within HA (instead of Ubuntu host) using the SSH & Web Terminal add-on to run:

mount -v -t cifs -o vers=1.0,noserverino,username="user",pass="pass",domain=WORKGROUP,iocharset=utf8,dir_mode=0777,file_mode=0666,sec=ntlm //192.168.1.x/share/media /media/nas

Although the mounted drive files can be see from the command line and even show up in the Media Browser, the /media/nas folder is empty within Plex. Same if I mount it to /share/nas which is a location that works if I mount via the host system (Ubuntu) /etc/fstab.

Has anyone got this working with Plex too?

I have been trying on and off with HassOS but I get the same as you or that it does not exist in the Fstab.

The problem is that i can easily mount something using the SSH webterminal but home assistant itself runs in a container of some sort and so the mount will work on a linux level but not in home assistant itself. You will have to mount a drive in the home assistant container itself to get it to work. But i havent been succesfull so far on doing that.

I tried a shellcommand but keep getting different errors. I guess in the home assistant container i dont have the rights to mount something.

I keep getting “return code: 127” when using sudo in front and 255 without sudo. It just doesnt work.

Please vote for my feature request in this functionality for the media browser:

1 Like

Bigger FR here


100% agree. “HA is by nerds for nerds” , where it should be “HA is by nerds for NOOBS”