Auto-Generate a Local File

I am a new Hubitat user seeking input.

I have a rule which uses motion and contact sensor events to set a connector variable. The rule appears to work as expected. However being both curious and cautious I am using "Send notifications log to a local file to log sensor events” and “Append to local file” the status of the connector variable string; so I might have a record of an event sequence for which I may not have considered. The rule is successfully generating a local log file with the data in a readable manner.

Given I got this far. It was my hope to push it and use RM 5.1 to auto generate a new local file on a daily basis aptly named 14-Jan-2022.txt, 15-Jan-2022.txt, etc.

I “think(?)” I have used/tried the info here appropriately: Local Files in Rule 4.0 in an attempt to generate a file name and target file but I have reached a dead end.

I write this post now because I am slamming my wall against the head as it does not seem doable.

If I am missing something obvious, please enlighten me as I would be delighted to learn it was something obvious that I was missing or had yet to learn.

Thank You.

This should be possible. You can use a string variable in the rule where you define the local file name, using %variable-name% (put your own variable name between the % characters). You would have to construct the file name first some how, but that is doable also. For example, when setting a string variable one of the things you can put in the string value (in a rule action) is %date%.

I had a bit of a play around with this earlier and could only enter a string for the file name when using the write to a file action. Appending to a file displayed a drop-down list of the files on the hub. I'm expecting the OP will be wanting to append throughout the day as events are logged. Am I right in this understanding? Or is there some other way of doing this in RM?

Entering a %variable-name% in the local file name field of the "write to file action" returns a "Bad File Name" error.

What value did you try storing in the variable?

I just used simple routine words without any wild characters.
e.g. "filename" "bob" "zeke" "alice" minus the quote marks.
It would appear that the Local file name field in new file creation action does not like "%"
I am using RM 5.1
For kicks I tried a different browser with the same result.

Yes, you're right. It's checking for a valid file name, and failing at that point to substitute the variable before the check. That bug will be fixed in the next release. Sorry for that!

3 Likes

Thank you for your efforts and rapid response/s. I truly appreciate it.

Download the Hubitat app