Creating Text File on Home Network Drive

Is there any way to have Hubitat create a file in a particular location on a network drive on the same LAN with a small snippet of text?

I'm imagining such an app would need the local address location and user/password for the location, the name of the file to be written, and the text to be written to the file. Also a trigger, but that could be a virtual switch.

It sounds simple, but I have no idea how to implement it.

For anyone wondering, my use case is for using Assistant Computer Control. It's an app for PCs that performs various activities based on commands placed in a text file. It is intended to use a voice assistant, IFTTT, and a cloud storage service, but could work locally. All that's needed is a way to create a file with your given commands, upon your given trigger.

I see with Rule Machine, it's possible to write a custom file to local storage on the Hubitat. Is there a way to extend the capabilities of Rule Machine to write to network locations elsewhere on the LAN, or to access the local file location on the Hubitat by other devices on the LAN?

1 Like

Do the files created by RM have a URL associated with them? If so, they could continue to be hosted on HE but accessed "remotely" from other network devices.

1 Like

Yes, the files would be stored in Hubitat and accessible via the hub’s file manager. Right-clicking on the file from the File Manager (via settings) will allow for a copy of the URL to be made, and then used elsewhere.

1 Like

I checked into it, but unfortunately, the resulting URL is simply a web page that prompts a download of the file. Assistant Computer Control requires a directory to monitor, and the URL unfortunately won't suffice.

Is there any way to access the "local" directory where these files are stored as if they were a networked folder?

1 Like

If you have a file called "file1.csv", you should be able to access it from:

http : // [HE-Hub-IP] / local / file1.csv

The Hub IP can also be a DNS name

Unfortunately, no, that won't work. Assistant Computer Control needs a directory to monitor. An http address won't work.

One possibility, is there any Hubitat app that can write to a cloud storage service? That would work as well.

I started looking into simply having the rule create the file in a cloud storage service, in this case Google Drive. It seems possible, since there are ways to use the Google API to create files. I see where people have written data from Hubitat to spreadsheets using Rule Machine, so what I want to do seems possible, but possibly far simpler.

Now to figure out the Google API for this though, which I'm not at all familiar with.

1 Like

Yeah, I haven't really ventured into that either. I took a look at setting up a developer account and have installed one or two apps / drivers developed here on the Community, but never anything myself. You may want to look at one of the Google Calendar drivers to give you a head start, or maybe the driver / app for the work on spreadsheets.

Are you wanting to populate a spreadsheet, or just a file with text in it?

At this point, I really need to figure out how to just do a simple "hello world" sort of example using Rule Machine and the Google API. Think of it as, how does one create a rule in rule machine with the action to:

  1. Create a file on Google Drive called "Hello.txt".
  2. Create the file in a directory called "Hello" on the Google Drive.
  3. Populate the text file with the phrase "Hello world!"?

I posted another thread that's a bit more specific on this, since it seems this is the simple hurdle I need to overcome.

The end goal is to have rules with actions I can use to kick off things with Assistant Computer Control. It's an app for PCs that watches a cloud folder (or any folder) on the PC for a text file to come in with simple commands that do things like lock the PC, mute the PC, etc.

Got to love the world of smart home tech. We daisy chain together so many things, but I guess that's programming in general, ha ha.

I think with most of their stuff if you want to make the call from something you right, you typically need to have either 2 or multi-factor authentication. I could be (and most likely am) wrong, but I don't expect you will be able to make a HTTP call or upload a file as simply as you may with some other services. That's why I would expect you will need to write a driver or an app. But I'll leave it to those that have actually used their platform to clarify that for you.

An out of the box consideration.....

One could use @ogiewon's Hubduino talking to an Arduino board (ESP32). Sent the text to the Arduino and have it write to a local LAN directory. To be honest I've not done the last part but from posts I've seen in the Arduino forum suggest it's possible.

Perhaps Dan can tell us if Hubduino can write the data directly to a local folder.

One benefit. Stability once one gets it working, no API changes to worry about.

2 Likes

HubDuino has no support for writing files of any type.

If you already have an always-on Windows machine (or other OS) running, you could have ACC watching a folder on its file system. There are utilities that should be able to copy the file(s) from HE over to the PC for you on a schedule, and then ACC could do its thing from there.

Just a thought. One of my favorite ways to get files onto Google Drive is to have Google's own Windows app "Backup & Sync" (called something else now) running. When a new file gets placed anywhere on the mapped drive in Windows Explorer, it's automatically synced not only to my Google Drive, but also backed up onto my Synology NAS via CloudSync.

Can you name any utilities specifically? Also, the schedule part could be a sticking point. ACC is meant to work rather quickly. I really don't want to wait 5 minutes for ACC to get the file and execute. A utility that could watch for a file to come into existence at any time would be ideal.

As for using Google Drive, that is another area I'm looking at. If only I could figure out how to use Rule Machine to create a file on Google Drive using the API.

PowerAutomate may be worth a look.... It is free for Windows 10 and allowed me to download a json file from my HE hub. You could write to the file as part of your RM rule and have the PowerAutomate flow pick sync it regularly. Next thing to look at would be triggering this and what options for a destination you have / want.

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.