I am trying to setup an automation that would be triggered when a specific file is modified.
First usecase that I am trying to implement is to have a real time copy of /config/home-assistant.log file, so that I can decide of the retention time. Reason is that I run HassOS on RPI, and whenever a crash occurs (once every few days), I currently lose the logs during restart so I cannot investigate the crash root cause.
To do so, I added the following in my configuration.yaml:
Yes I restart after every modification, and I also tried to exec the automation to ensure that notification works fine and it does !
Regarding the devtool, I tried to use it but not sure what I should listen to, and it is linked to your second advice regarding pattern matching —> I don’t understand how to define multiple watchers as they have no id or name, so I don’t know how to id them precisely in the listener or in an automation (meaning, what if I have multiple log files in the same folder, what happens ?)
Tell me if I am not clear !
Then if any of them change the folder watcher will generate an event. I know it is probably not ideal when you want to watch just one file, I was just interested from a debugging perspective.
Thank you !
So apparently it was a star issue, both *.log and *home-assistant.log work !
This does however highlight another issue (maybe I am dealing wrongly with original need): automation run = new logs … and new logs = automation run … hello infinite loop I exploded the 300 notif limit in seconds before I could stop the automation ^^
Any idea to prevent a specific automation from writing logs ? Or maybe an idea on another way of dealing with this log retention issue ?
Thanks again for the help !
Well, thank you for this proposition.
I tried it but unfortunately, I encountered so many issues when trying to implement something like that, that it’s becoming to complex for me ! There are issues with file rotation, file retention, message containing quotes, mounting /config folder, message truncated, … … …)
I think I’ll just hope that this feature request gets implemented in a near future Better logging !!!
But it was nice to play with something new, I learned a few things in the process, so that’s cool !!
Thanks again for your time and help on this topic !