To allow file management outside of the groov Manage interface I’ve put together this groov View page and Node-RED flow. I am using this to move files between local, on-board storage and an attached USB drive, as well as safely unmounting, all from just one page on my groov EPIC. There is NO use of groov Manage required after the initial setup; the only requirement is access to a groov View page!
Disclaimer: The “unmount” button uses an undocumented API endpoint that is not supported at the time of posting this flow – please use your own judgement and run your own tests before deploying this. This post will get an update when the feature is fully supported – until then, keep in mind that with great power there must also come great responsibility!
With that out of the way, if you want to try this out yourself, go ahead download the zipped groov Project and Node-RED flow attached to this post and follow these steps to import and configure everything:
Enable USB automount if you haven’t already.
In groov Manage select System, Settings, and then USB. Enable the USB and Automount options.
Restore the groov View project through groov Build to get the required page, gadgets, and tags. (Backup your old project first!)
The username for the project is “
opto” and password is just “
Import the Node-RED flow – it should look like this:
Get an API key for the unmount command: Go to groov Manage and copy the API key for a user with groov Manage permissions. (If you have not set up your groov View in Node-RED yet, I suggest choosing a user that also has groov View permissions.)
Double click on the “set headers” function node at the top of the imported flow. Change the value of “
host” to your local devices hostname, and paste the API key exactly as copied from your groov Manage user account page for the “
apiKey” value. Click Done to save the changes.
Next, double click any groov Node to configure the connection to your new project. Select the pencil icon next to the Data Store “nodered”.
If you already have your localhost groov Project configured in Node-RED, you can use that.
If you don’t, click the pencil icon next to Groov Project (add new groov-project), leave the groov Address as
localhostand paste the API key you copied earlier as long as it has groov View permissions.
Click “Update” and then “Done” to save this configuration. All the groov nodes are now using this API key, so you don’t need to make any other changes.
Deploy the flow and go back to groov View, it’s ready to go!
How to use the page:
- First you will need to insert your USB drive and click Refresh to see the file lists.
- Use the arrows to move through the file lists, by default it will jump 5 items at a time like going through pages. If you prefer line-by-line “scrolling”, go into Node-RED and inject 1 into flow.scroll_offset. You do not need to redeploy for the change to take effect.
- To move a file from local storage (/home/dev/unsecured) click the “>” button gadget to the left of the file name that you want to move. The button will light up and then go dark after the move command is complete, but you will need to click refresh to see a file move to the other list.
- Similarly, to move a file from USB storage (/run/media/sdb1), just click the “<” button to the right of the file name listed under USB files, and refresh to confirm that it has moved.
- Once you’re happy with where all the files are, click unmount in the top right and wait a moment after the unmount light turns back to green, just to make sure it has time to finish.
- BEFORE you pull out the USB drive, try to refresh the list first. If all the file names disappear, you’re good to go ahead and remove the drive. If the files are still listed, the drive is probably still busy, so double check any apps that might be using it, and try again.
Final note: If you unmount and then decide that you want to see the files on your drive again, you MUST physically disconnect your USB media and plug it in again. The unmount button has a confirmation lock on it to avoid doing this accidentally, but do keep this limitation in mind.
As always, feel free to dive into the groov View page and function blocks to modify them for your needs, and please share any successes (or failures) in the thread below. Happy coding!
DOWNLOAD LINK --> flow_and_groov.zip (293.6 KB)