Is it possible to mount a HA directory/folder to a Raspberry Pi on the same network?

I have been unsuccessful at getting a Samba share from a Raspberry Pi (w/ cam) to my HA instance, which runs on a Windows 10 machine via VirtualBox VM. So, I am looking for alternatives to get pictures (taken by the Pi) over into my HA instance so I can use them in Lovelace, send them with notifications, and maybe do some object/person detection with Tensorflow later.

In HA, I have the standard directories - config, share, addons, ssl, and backup. Keeping in mind that I am a Linux neophyte - Is it possible to mount the /share directory to the Pi somehow - so that I can write the images captured by the Pi cam directly to /share?

If this is not possible - how else could this (the movement of Pi based images to HA) be accomplished?

I guess you need to configure the Samba client on your HA.
How will you push these pictures the moment they are taken to be used by HA?
I think it makes more sense it around and make your RPi write directly to the HA VM storage - as you already mentioned yourself.

I’m not a Linux expert either but I know that you need to have the Samba server & client installed.
To be able to mount a share, you have to create a directory on the client to mount/map the share to.

I’ve been thinking about this issue for a while.
Hard to prescribe a Linux solution to a “Linux neophyte”.

I’m with Nick on this one. You should try and resolve your issues and use SMB.

Though I am thinking that it may be better to have your HA as the SMB server, and your Pi pushing photos onto there.
My reasoning is based on the assumption that you won’t need the pictures if HA is down, so when a picture is taken, it should be uploaded to HA via SMB.

That’s opposed to getting the HA to connect to your PI which is the SMB server. Note that on Windows 10, you will need to look at creating firewall rules to allow the inbound connection.

I have to ask, are you running NAT or Bridged adapter on this VM?

You could also do FTP, or even SSH to copy files across.

hey @Nick4, thanks for the reply.

I actually have Samba add-on configured and working already in HA - so that would be the SMB server, right?. I put the Samba client on the Pi last night, and could not figure out how to see the Share from HA. I can get to the standard directories via a separate Windows 10 laptop (ie not the Windows machine running the VM). So the directories are “out there” being served from HA, I just don’t know how to find them from the Pi, and mount them so I can write files to it.

Right now, I have an ugly but functioning python script that, when a button is pushed, a pic is taken and stored in a local directory on the Pi. Instead, I’d like to write that picture file directly to HA in a directory called /config/www/doorbell if I can ever figure this out!

Just noticed afterwards that it’s Cliff there! :rofl:

What are you running on the RPi?
Have a look at this: How to mount SAMBA share (SMBFS) in Linux

Running Rasbian on the Pi. thanks for the link - will try that when I get home from my mail route, if Ma let’s me on the internet :slight_smile:

I think part of my confusion is…what am I ACTUALLY trying to link to as a share. Because the files are being served from a VM installed using this method - so it’s not a WIN10 share, even though the VM is running on top of WIN10. Is it technically a Linux share because its a Linux VM w/ Ubuntu, even though I’m ultimately running HassOS? My ignorance is showing…

“It’s a little known fact that the USPS created Samba and Linux after WWII to control the mail sorting system” -Cliff Clavin

@fanuch added some more context in my convo with @Nick4 if that helps. My understanding is that I already have HA as the SMB server, via the Samba add-on. Would that be the correct way to describe it?

I used this method - so bridged adapter, though I freely admit that I do not know what that is exactly.

You could also do FTP , or even SSH to copy files across.

I started looking into the copy via SSH method last night. I was able to do it via the command line, enter my password, and it worked. Ideally, I’d need this in a python script - with keys - so I need to research that. If you know of any example python scripts out there that already do this, I’d be eternally grateful!

Unless your W10 firewall blocks the traffic from/to the VM you have to ignore that.
You just have a virtualised Linux that is seen as a host on the network with a share.
Just like the W10 machine where the VM runs on, any other client on the network that can use a Samba share, is able to connect to that share.

I can’t comment on the HassOS matter since I have no idea atm of it’s structure/possibilities but if you have created the share, that should work.
One more thing: you might have to look for the specifics on connecting to a Samba share on the RPi since it’s Raspbian, which can be a little different from general Linux/Ubuntu/… guides.

EDIT: if you can write directly from the RPi to the Samba share you don’t need any script so I would take that route and it’s like @fanuch already mentioned: if the RPI doesn’t run/function nothing has to happen.

Great - I think I understand a bit better now.

Regarding python script - I mention that method for 2 reasons:

  1. I already have a py script that rings the bell, then takes the snapshot - so it only seemed logical to append code to this existing py script that would move the image over to HA.
  2. Someone else suggested to me that I could use the Push integration and use an HTTP POST to push the image to HA. I have not been able to find any examples on how to do that just yet. A lot of examples on how to do the HTTP POST, but I can’t figure out the address to post it to yet.

Why would you go through all the trouble to install a Samba server & client and not just write the image directly to the share but move it with a script as an extra step…
By not writing to the SD card of the RPi, you also minimize the wear of it.
If you want to handle the moving of the image, you could have used scp which is a standard tool and is installed with Raspbian.

By writing directly to the share, you don’t need any extra handling/additional command/more points of failure/…

Regarding the push integration: I think you cannot push from an external source towards HA; that would be called a pull anyway.

Ok sorry about that, forget moving the image. As you said, writing directly from the Pi camera to the share on HA is the objective. I think I have made some progress - but still hung up. After looking at this page, I ran:

/usr/bin/smbclient -L HASSIO9

This prompts me for the “WORKGROUP\pi’s” password, so I entered the password I set in the Samba server (the HA add-on config) and it for whatever reason, it says “Anonymous login successful” and lists the directories on my HA instance (whose name is HASSIO9)

pi@DB3A:~ $ /usr/bin/smbclient -L HASSIO9
Unable to initialize messaging context
Enter WORKGROUP\pi's password: 
Anonymous login successful

	Sharename       Type      Comment
	---------       ----      -------
	config          Disk      
	addons          Disk      
	ssl             Disk      
	share           Disk      
	backup          Disk      
	IPC$            IPC       IPC Service (Samba Home Assistant)
Reconnecting with SMB1 for workgroup listing.
smbXcli_negprot_smb1_done: No compatible protocol selected by server.
protocol negotiation failed: NT_STATUS_INVALID_NETWORK_RESPONSE
Failed to connect with SMB1 -- no workgroup available

Success, right? Not quite, yet. The guidance from the above link says “Get the password for the ‘guest’ account or for your personal account on that machine.” In my case, I assume “personal account on that machine” means the Samba server password (which is also the pwd I use to log into HA, and the Pi…I know, bad practice…) This is my Samba add-on config within HA:

workgroup: WORKGROUP
username: myusername 
password: mypwd
interface: ''
allow_hosts:
  - 10.0.0.0/8
  - 172.16.0.0/12
  - 192.168.0.0/16
  - 'fe80::/10'
veto_files:
  - ._*
  - .DS_Store
  - Thumbs.db
  - icon?
  - .Trashes
compatibility_mode: false

Since I can actually see the folder I thought it was working. So per the link above, I tried this:

pi@DB3A:~ $ /usr/bin/smbclient \\\\HASSIO9\\share
Unable to initialize messaging context
Enter WORKGROUP\pi's password: 
Anonymous login successful
tree connect failed: NT_STATUS_ACCESS_DENIED

So, progress has been made - but not sure what these errors are, or what password it is expecting. Getting closer, thanks for sticking with me!

SMB1 is a version of the SMB implementation and there is also v2 and v3.
Maybe it’s related to that version:

  • different versions between server & client
  • limitations of SMBv1