I apologise if this is a stupid question, but I have a NAS and it is currently my media server.
Is there a way to point the new feature at this server location rather than copying all the media locally?
e.g.
media_dirs:
media: //nas/music
I apologise if this is a stupid question, but I have a NAS and it is currently my media server.
Is there a way to point the new feature at this server location rather than copying all the media locally?
e.g.
media_dirs:
media: //nas/music
It not a stupid question. I have no idea how to do it but I want to. Who would keep all their media under HA? I’m guessing that it can be achieved via something like this https://markontech.com/linux/mount-a-network-shared-drive-on-gnu-linux-tutorial/ but as with so much linux stuff its hardly a user friendly experience.
Just found this: Mount remote smb share on hassio which might be useful if you have unix file support on your nas
Saw you mentioning samba mounting thread, I just checked it more and it mounts samba just as well as nfs. See 35st comment with NFS/Samba shell command different examples: Mount remote smb share on hassio
Thanks a lot. I’m having some issues getting this working. I’m running on a proxmox box and here’s the system info:
|arch|x86_64|
|---|---|
|chassis|vm|
|dev|false|
|docker|true|
|docker_version|19.03.11|
|hassio|true|
|host_os|HassOS 4.13|
|installation_type|Home Assistant OS|
|os_name|Linux|
|os_version|5.4.63|
|python_version|3.8.5|
|supervisor|245|
|timezone|Europe/London|
|version|0.115.2|
|virtualenv|false|
So there is already a “media” directory in place as part of the install.
I’m trying to connect to a share (movies) on my Western Digital Mycloud (drywall (192.168.1.121) which should be open to public.
homeassistant:
media_dirs:
movies: /mnt/media2
shell_command:
mount_movies_folder: mkdir -p /mnt/media2;mount -t cifs -o username=anonymous,domain=WORKGROUP //192.168.1.121/Movies /mnt/media2
This is the automation:
- id: 'XXXXXXXXXXXX'
alias: Map Movies Folder
description: ''
trigger:
- platform: homeassistant
event: start
condition: []
action:
- service: shell_command.mount_movies_folder
data: {}
- delay: 00:02:00
- service: shell_command.mount_movies_folder
data: {}
mode: single
A config check brings back no errors so formatting looks good but I’m not seeing what I was anticipating which would be my movies folder avaiable under media_browser and I get this error:
Logger: homeassistant.components.shell_command
Source: /usr/src/homeassistant/homeassistant/components/shell_command/__init__.py:111
Integration: Shell Command ([documentation](https://www.home-assistant.io/integrations/shell_command), [issues](https://github.com/home-assistant/home-assistant/issues?q=is%3Aissue+is%3Aopen+label%3A%22integration%3A+shell_command%22))
First occurred: 17:27:21 (1 occurrences)
Last logged: 17:27:21
Error running command: `mkdir -p /mnt/media2;mount -t cifs -o username=anonymous,domain=WORKGROUP //192.168.1.121/Movies /mnt/media2`, return code: 255
NoneType: None
Is there some way I can test the command line etc via terminal? If you could me some pointers that would be appreciated.
yes,
cd /mnt
ls -la
#here configrm that media2 is here
mount -t cifs -o username=anonymous,domain=WORKGROUP //192.168.1.121/Movies /mnt/media2
cd /mnt/media2
) folder and check that the files are there (ls -la
)Thanks a lot for the guidance…
Got portainer installed and configured as you said. media2 there but mount failed. as you suggested I tried changing the username and that works. - in the HA portainer console I can ls the directories and the content is there.
Unfortunately the media2/movies folder still doesn’t appear in HA media browser.
If I look at the HA instance console in proxmox I see this:
Really appreciate you help on this
Reboot HA through server management: http://homeassistant.local:8123/config/server_control
after that, login with portainer, and check if folder is mounted (if files are there, then we can ignore the proxmox log, means it does mount)
#force less secure SMB version
mount_movies_folder: mkdir -p /mnt/media2;mount -t cifs -o vers=1.0,noserverino,username=anonymous,domain=WORKGROUP //192.168.1.121/Movies /mnt/media2
If still doesn’t work, add -v to mount command and compare output from portainer shell, and output from proxmox log and find differences if any
mount -t cifs -v -o vers=1.0,noserverino,username=anonymous,domain=WORKGROUP //192.168.1.121/Movies /mnt/media2
See more info on mount options https://linux.die.net/man/8/mount
Getting somewhere but its now 1:30am and I have work tomorrow Will update later today - thank you so much.
EDIT:
so I got it working with the following config.
homeassistant:
media_dirs:
music: /mnt/media2
shell_command:
mount_music_folder: mkdir -p /mnt/media2;mount -t cifs -o vers=1.0,noserverino,username=<username>,domain=WORKGROUP //192.168.1.121/music /mnt/media2
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.
hi,
First I tried it with
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?
Thanks
I got the share working on my NAS by making sure that not only did the USER have access, but also the EVERYONE group.
Also needed to be su root. The command as per below prompted me for the password and then worked!
mkdir -p /mnt/media;mount -t cifs -o vers=1.0,noserverino,username=<username>,domain=WORKGROUP //192.168.1.x/Music /mnt/media
With some adjustments i was able to make is work for a remote folder shared on my Plex PC.
Thank you for your help.
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…
This really needs to be done as an integration, ideally from the base platform, alternatively via HACS.
My easy way:
On the root system
sudo nano /etc/mountnasha.sh
insert
#!/bin/bash
sleep 5m
sudo docker exec homeassistant mount -t cifs -o "domain=WORKGROUP,username=xxxxxx,password=xxxxxx" //192.168.1.xxx/Medien /media
then
sudo nano /etc/systemd/system/mountnasha.service
insert
[Unit]
Description=Mount NAS Media to HomeAssistant
[Service]
Type=simple
ExecStart=/etc/mountnasha.sh
[Install]
WantedBy=multi-user.target
then
sudo systemctl enable mountnasha
restart your host and you’re done…
Thanks! Does this persist after update if using Home Assistant OS ?
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 guess this doesn’t work on hassos?
A couple of ideas have stemmed from this:
Hello -
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.