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!
Note: The “unmount” functionality is now officially supported through the Manage API, and functions essentially the same as it did in prior versions of EPIC firmware (pre-3.0). However, if you are using this project with multiple USB drives inserted, please post in the thread below as you will need to make some modifications to the Node-RED flow and groov View page.
With that out of the way, if you want to try this out yourself, go ahead download the zipped groov View page 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.
Next you will need to add the following tags to either an existing Data Store or a new one (I call my Data Store for this project simply “nodered”).
There are four booleans, two boolean tables
copyUSBwith length 5, and two string tables
filesUSBalso with length 5:
With these buttons and tables you can display any number of files by “scrolling” through the file lists – you’re not limited to just five!
Import the groov View page through groov Build to get the required page and gadgets (consider backing up your current project first).
Once the page is imported, assign each tag to their respective gadget. You will only need to do this once, but be sure to get each one right:
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” (or whatever you called yours if you made a different one, just make sure the spelling exactly matches what you have in groov Build).
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 --> file_management.zip (5.6 KB)