Local Files in Rule 4.0

Any further development that could allow for groovy access to the local file space?

I am porting over a Fully Kiosk Browser driver I had written on SmartThings and webCoRE. It allows for real time response from the tablet camera and grabs an image from the camera. With SmartThings I put the image in the carouselTile to display on the SmartApp. It would be great to store that image(s) on the Hubitat hub and allow local http access.

2 Likes

Hi @Bloodtick_Jones !

I've developed a very basic local file access "driver". Take a look at it and see if it somehow can help you:

As I said, it has very basic capabilities and I'm willing to enhance it if some new use cases arise.

Marco

3 Likes

@nowon,

I believe that this limitation has something to do with memory constraints.

As far I could "feel", a file is fully kept in memory before written to a file. Have you ever tried to "append" additional data to an existing file, just to see if this limit of 52 MB is overcome?

Marco

no I haven't will give it a try when I get home tomorrow.
But I think you are correct it is the same problem we were having with hubs locking up during nightly backups. Now backups are much smaller and no more issues with hubs locking up.

1 Like

Hello, how can I read a data file using groovy?

As in the local files? There is currently no api to read them. They can only be accessed by rule machine. You could of course do an httpGet on the url of the local file though

1 Like

Okay, thanks. Will there be an api eventually?

See above for the beginnings:

@maffpt I tried just appending a test file slowly increasing it's size 16 mb at a time and re-uploading over writing the same file over each time and it looks like it maxes out at 51 mb.
Looking at your DH and rule I don't see how I can add to the file size expect very very slowly.
We can not open the file from Hubitat and simply keep adding data and saving it directly.

@NoWon,

Have you installed the app and a Virtual Device to your app/driver to handle the file?

What I'd like to suggest is, starting from a file with 51 MB already, add to it a 1 Mb string and see what happens. Then again and again.

However, with the 51 MB threshold, probably you'll not be able to open the file in your app/driver if it is greater than 51 MB, but I expect that playing it would be possible, if it is an audio file, of course.

This 51 MB threshold probably - I repeat, probably - is a buffer size limit within the HE local files modules.

I did but was not able to create a child device so was not able to make any edits using your s/w.
I only tried a text file not sure how you can use your s/w to edit a mp3 file.
I am sure you are correct about the buffer size restriction.

Let me take a look at my code.

Be back soon.

I am using a local file to log anything happening to my devices overnight that I should know about. I am writing an app to monitor whether conditions are such that condensation might form on my house windows. It's too complex for a rule. I'd love to be able to write to my custom log if the conditions were met overnight. I do appreciate this local file feature and hope it is expanded.

Use a string variable connector and a rule to do the writing. Your app can stuff the string into the variable connector (device.setVariable(string)), and rule can append that to the file.

1 Like

Thanks for this, I was looking for an easy way to track when / how often my sump pump runs. This is simple and perfect. Zooz Zen15 power = 0, write time and date to file.

I would like to be able to test if a local file exists. I am using local files to create excel files (csv) for graphs and it works great. After a time I delete the local file and start capturing new data. At this time I am manually overwriting the file with an empty file that just has headers I want for the graphs. What I want to do is just delete the local file and then in RM...
If /local/filename not exist
Write string to local file with header info ( which creates new file)
Else
Write append data to file
end if

1 Like

Any way we can put html into a local file using RM? Right now the write/append statements are limited to text only :frowning:

I know html is intentionally stripped out of notifications for security reasons. Maybe itā€™s the same for local files?

Yeah, I guess so too.
Boo!

Bumping this thread in hopes to get groovy access to the file space. Would be awesome.

2 Likes