Hubitat Elevation Release 2.2.1 includes a new hub facility to support local files stored on the hub. These files can be created and managed in the hub web interface, and are also supported in Rule 4.0.
In Rule 4.0 local files are very similar to local variables of type String. There is a new action in the Set Mode or Variable section called Write Local File. This can be used to write a string to a local file. If the file does not already exist, it is created. If it does already exist, it is overwritten. There is also an action to append to a local file, that adds to the end of an existing file.
Note: Local file names may only contain these characters: A..Z, a..z, 0..9, - and _. Periods are also allowed but not as first character of file name.
In any context in Rule 4.0 where a String variable could be used with %variable-name%, a local file can be used by using %/local/filename%. Thus, the various actions that set a String variable by manipulating a string can manipulate the contents of a local file to set a String variable. The contents of a local file can be used in all other contexts where a String variable could be used as well.
A second way to create a local file in Rule 4.0 is to create a local variable whose name begins with /local/. When this is done, a local file is created with the name that follows /local/. This local file can be used in any context where a String local variable can be used, with one exception: A local variable that represents a local file cannot have a Connector. Deleting a local variable that represents a local file, deletes the local file. There is also an action to delete a local file.
It is important to note that there is a single file space for all local files on a hub. So if two rules "create" a local file of the same name either by Write Local File or be creating a local variable whose name begins with /local/, these would be referencing a single file of that name. It is possible for rules to pass information to each other by referencing the same local file, but care should obviously be taken as to which rules write to a given file.
Local files can be accessed on the LAN at [hub-ip]/local/fileName
.