Write files from Hassio to a (Synology) NAS (SMB Share)

Hello!

2 months ago I made the choice to migrate to HA because of the great customizable interface and flexibility with components. Currently I am still running Domoticz.

Most automation I have migrated and tested on HA. But there is one automation that I cannot fully port to HA.

On Domoticz I have a bash script running that is activated when someone presses my doorbell (433mhz)

  1. Grab camera snapshot
  2. Send it to a Telegram group
  3. Rename the file to snapshot-date/time.jpg
  4. copy this file to a (locally mounted) folder on my Synology NAS.
  5. Delete the file from the SD card.

Taking a snapshot and sending it to Telegram is not the issue, but saving it to my NAS is.
Is there any way to achieve point 4 mentioned above in HASSIO?

Hope you can help me :slight_smile: thank you in advance!

Considering the amount of replies, Iā€™m assuming there is no good solution for this.

Iā€™ve managed to create a workaround:

  • Iā€™ve mapped the SMB share of the HA addon in my synology.
  • the Camera script writes the snapshots in a temp folder
  • every night the Synology runs a bash script to move the files from HA to Synology.

I would love to see mapping of SMB shares coming to Hassio.

I have finally found a decent solution. In node red there is a SMB node available. This does exactly what I want. https://flows.nodered.org/node/node-red-contrib-smb

2 Likes

Hello.
I am very interested in your work but I cannot configure the ā€˜node-red-contrib-smbā€™.
My Home assistant is installed on a VMM in my Synology DS916 + NAS.
I want to copy the daily ā€˜Snapshotā€™ to a ā€˜Backupā€™ directory on my NAS.
Can you give me the details of your ā€˜Flowā€™ please.
Best regards
Bruno

Hi Bruno,
I am not sure how this will work with snapshots. I am using the upload to dropbox addon for snapshots.

However, what I do, is get the photo via the IP camera snapshot URL with a HTTP request node. Then I use a function node to format the filename: snapshot_[date-time].jpg and finally I use a SMB create file node to upload it to the correct folder.

Possibly you can do the same thing via the SMB addon.

Could you please specify whatā€™s your exact problem? What is it that you canā€™t configure in the SMB node?

Cheers

Hello Hammer,

I have exactely the same need as you and i canā€™t figure out how to use the SMB node to move the file from the Pi to the NAS.

Up to now, I only manage to create an empty file (1oct) on the NAS with the well formated file name (thanks to msg.filename). But how to pass the .jpg payload? all the example found on internet explain how to pass text payload (.csv JSON etc) but nothing about other file type.

And if I try to use the ā€œmove fileā€ function instead of ā€œcreate fileā€ function, I canā€™t figure out neither how to do it; it seem that the node do not accept Unix path format as an input. Or maybe it is due to the container limitation (docker)?

Well if you could explain how you manage to do it, I would be very gratefull!

SMB NAS

How did you manage to authenticate to a remote SMB host from the NodeRED SMB config?

I keep getting authentication errors on any remote systems that arenā€™t the HA host system.

Hi JMG,

I have totally missed your reply to this topicā€¦

I have no experience with moving filesā€¦ In my flow I write the foto directly to the file in the share using the create file function. I guess whatā€™s going wrong is that I think that both ā€œPathā€ variables are pointing to your NAS. So a local path will not work.

Cheers!

Hi Arretx,

I just filled in the authentication parameters, please see screenshot.
Please note that this node supports SMBv2