What is the proper way for an Automation to write to a file? I have been bashing my head trying to get it to work, and netiher myself or Chatgpt (not saying much) can figure this out. I have a custom android app which generates alerts. Eventually I will do something about them but for now I just want to log the occurence and title.
The sensor works, it collects the attributes and the automation is triggered however the automation cannot write the file. I tried writing to /config/www/notification.log or /homeassistant/www.notification.log and even tried under my own folder which had 777 permissions /mylogs/notification.log. In all cases, no file was present. I tried also to push it via a script with no result.
I went with shell_command because the notify.send_message didn’t work either. I read that post and updated my settings but still no file present and no errors. The entity has updated data, the automation timestamp does show it triggered but no file. Not my day
Yes I have tried to /mylogs and even to within the homeassistant folder with no luck with just:
homeassistant:
allowlist_external_dirs:
- mylogs/
it got pretty annoything so I just ended up putting it into another entity and logged it in memory so I can at least see it as a card on the dashboard.
input_text:
last_notification_log:
name: Last Notification Log
initial: ''
max: 24000
I’ll leave it for now. Once I know how to proceed further I’ll try to figure out this log to file thing. Thank you everyone for the help!