[RELEASE] File Manager Device

The methods have been sitting in my repository for some time now, and have been implemented successfully in several places, but until now weren't very useful unless you wanted to write code. While the best way to fully utilize this code is still as a child device for an app or another device, this device driver provides some standalone capabilities and allows an application, RM, webCoRE, or anything else that can utilize a device interface, to write, append, and retrieve textual and image data from Hubitat's Local File Manager.

Write and Append take two parameters:

  • Hub Local File Name
  • Data String to add to the file

For both the file will be created if it doesn' t exist. Write will overwrite any existing data in the file, while append will add it to the end.

Read takes one parameter

  • Hub Local File Name
    and returns the file contents

xFer File allows for the import of a text file from the net and needs two parameters

  • URL for the source file
  • Hub Local File Name to store the data

Like the write command, the file will be created if it doesn't exist or overwritten if it does exist.

Driver is available through HPM or may be directly imported from:


I have been wanting to use HE and webcore to update my many different music playlists (as I add and delete music to/from my collection). Will this driver allow me to load an entire playlist, add a new song, sort the list with webcore, and then output the new list back to my HE?

The write works well, and it can execute the readFile() command, just haven't figured out what webCoRE does with the return from the command yet. In a regular app it would be a simple

var = devHnd.readFile('webCoRE.txt')

I apologize first off for posing such a vague question.

What would be an example of this? Could someone automate a shopping list with this? Weekly meal planning for family viewing? Forgive me if I'm way off on my understanding of potential.

Let's say you have a temperature device that you check with a rule every 10 minutes to make sure it stays within bounds. After a while you decide that you'd like to plot that temperature over a period of months; simple way to gather the data for doing that would be to append a new date stamped temperature entry into a file each time the rule ran, and then with another app read that file and plot the data.

1 Like

Was hoping to get around the 1024 byte attribute limit by returning directly to the rule/piston, but appears that I can’t make it work that way - I’ll add a readFile with offset to bring back the data 1024 bytes at a time - should be able to get it up by late tomorrow.

Are you sure that this is an actual limit for attributes? I store image bytestreams much larger than 1kB in one of my drivers. You can't display them on a dashboard if greater than that size, but there's no issue I have seen with actually storing bigger attributes.

I’ve accidently pushed more, but at some point I get an error that crashes the driver. I will see if I can find the actual limit though.

1 Like

Cool, I am curious.

Just for reference, I have an image value in an attribute on my driver. It's a data URL that renders to the device page, and with the little bit of HTML around the base64 image data, it is currently storing ~32k characters.

Is there a way to delete a line from a file? So, if you only wanted to capture the last 1000 events, you would append line 1001, then delete line 1. Deleting lines by date would be even better, but seems like more of a database operation.

1 Like

It’s what we use to call a sequential text file, so the easiest way to trim the top would be to read the file and determine the how many bytes you want to remove and use that as your starting point when re-writing the file, i,e, fileData = fileData.substring(500)

1 Like

Is your driver capable of this? If you say yes, I'm not sure I'll be able to sleep tonight... too many possibilities!

Oh that’s easy, that line is about all it takes to implement a fileTrimTop, full function would look like:

def fileTrimTop(fname, trimOffset){
   fileData = readFile(fname)
   writeFile(fname, fileData.substring(trimOffset)
1 Like

I've been trying [unsuccessfully] to get Google Charts to read and plot a data set using html and csv files on my HE. I had basically abandoned the idea because I thought it would be impractical to manually "manage" the source data file when it got too long. Your driver seems to be able to solve that problem. The next hurdle is pulling that data into a google charts object. The documentation says it's possible, but I'm not a programmer so the developer docs might as well be written in ancient Sanskrit...

1 Like

v0.1.0 changes:

  • Added temporary fileContent attribute (erases after 30 seconds - plenty of time for automation to process); if you use this option it is recommended that you set Event and State history for this device to 1 (no need to store the file in the file system and twice in the database).
  • Added fileList attribute
  • Added fileTopTrim command to allow the removal of the first X characters in the file
  • Added copyFile command to allow copying one local file to another
1 Like

v0.1.0 should allow you to do this via:

* execute the readFile command

  • assign attribute fileContent to a variable
  • add data, sort, etc.
  • writeFile from the variable

New webCoRE functionality (as of 30Mar22) natively lets you:

  • read file into $file variable
  • set variable to $file + new content
  • sort, etc.
  • write file back out from variable

v0.2.0 Adds a callback option for apps that want to use this as an addon device instead of a child device, i.e.

input "fileDev", "capability.actutator", title: "Select File Device", required: true, submitOnChange: true

Using this option, implementation on the app side will look similar to:

def retVal    
fileDev.readFile("someFile.txt") {cb ->
       retVal = cb

Shoutout to @gopher.ny for pointing out this option to me.


@Pantheon latest release of webCoRE now incorporates file read/write/append/exist natively:


Awesome!! Thanks for the heads up.

v0.2.2 corrects the retrieval of text files that have embedded extended characters, i.e. characters that use umlauts etc.

1 Like

Download the Hubitat app