You were right about the spacing - my bad. My WDis old, a version 1 hardware/firmware and the key point seems to be specifying the “vers=1.0,noserverino,”. Using the same principles I was able to mount other shares as well.
Thanks again for the assistance and the education.
mount -t cifs -o username=hassos,domain=NASVolume //192.168.178.49/media /mnt/media
but I got
mount: mounting //192.168.178.49/media on /mnt/media failed: Host is down
Because my NAS is running on v1.0 I tried it with
mount -t cifs -o vers=1.0,noserverino,username=hassos,domain=NASVolume //192.168.178.49/media /mnt/media
But then I got
mount: mounting //192.168.178.49/media on /mnt/media failed: No error information
Any idea what could cause “No error information”?
Homeassistant is running on a raspi 3B+ with HassOS 4.13.
I just wanted to test the mounting part and haven’t done the automation part yet.
Also, my NAS has two shares: backup and media. Is it possible to mount the whole share or do I have to specify the folders in it?
Could you specify what you did?
I now managed to mount the nas (the nas folders are visible via ssh and ls command)
But i can’t add it to the media browser (HA doesn’t accepts the mounted folder as a media source)
So I have arrived at a similar point<successfully mounted via shell and visible to the ls command but not visible in the media browser, nor samba add on via windows explorer> (if not the exact same point) via different method.
I discovered this (Use network drive ) post before I discovered the post that I am replying to now, but my goal is media as is the point of our current post. I used the SSH & Terminal addon (the unofficial one, that allows for unprotected mode, the official one failed when I tried)
being that the files are indeed mounted from the shell command and ls -la lists root twice for each line item and based on a few other context clues my current suspicion is that that all of the files are mounted and only visible too the root user account. I suspect that whatever user account the system sees me and the lovelace media browser as is a different non-root user. I am a utter linux novice so I have no idea how to even begin testing for that or changing the user account the network share is mounted to.
but maybe with that idea as a prompt someone else here can add some magic to the conversation???
Edit to add:
after reboot the mount seemed gone, remounting was trivial via the same method as before (hell the shell remembered the command and suggested it just a few characters in). Of note and lending weight to my suspicion, after remounting the share and validating via the ls command everything was listed; I switch over to the official ssh & Terminal and navigated to the same directory and issued the same ls command only to see absolutely nothing. I believe the official SSH & Terminal sees the directory from the same non-root user account as everything else.
I guess I should also add the command just because it might help so
mount -t cifs -o username=user,password="password",domain=domain.com "//192.168.1.250/some folder/structure that had/spaces so I fixed/with quotes" /media/mount
Should be noted my password which has a symbol in it was screwing things up for the longest until I put it in quotes. if the folder structure has spaces in the name you will need quotes on that too, also if copying from windows explorer address bar make sure to reverse all of the slashes from \192… to //192…
Yes. Because you change it on the host, not inside the homeassistant docker container…
Did it work for you?
But if you do an server restart in HA, the mount is gone… than you can type the command manually in an ssh shell… perhaps there is another way… I’ll think about it…
I’ve got my cifs mount and copy working but I need some help structuring the copy. I’m running Frigate add-on and it stores video clips like this:
parking-1614646104.016776-mbk3v1.mp4
I have an automation running the shell command below every 5 mins to transform the filename by extracting the file creation date and prepending it onto the file name, then truncating the data at the end, and copy it to a mounted folder.
cd /media/frigate/clips;for file in *.mp4;do cp -u “$file” /media/camsonplex/"$(date -r “$file” +"%Y%m%d_%H_%M_%S")_${file:0: -29}.mp4";done
This is working great and produces this from the file above:
20210302_00_48_51_parking.mp4
The file creation date is in UTC. The last thing I want to accomplish here is to change that to my local time. Which is Detroit time (or UTC-5). All my attempts so far have not worked. If successful, the resulting file name would instead be:
20210302_19_48_51_parking.mp4
Can someone smarter than me re-work my cp statement to make this happen?
Thanks in advance! Let me know if this is not the best place for this question and I can move it.
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’
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.
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 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 Of course confirming the command works in the shell is definitely appropriate.
configuration.yaml
shell_command:
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
Triggers:
Trigger type: Home Assistant
Event: start
Conditions:
Actions:
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.
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