Last week I was pointed towards HomeAssistant as a solution for my automation problem. Unfortunately I’ve gathered some bits of information as I have no previous experience with any automation systems, but I see I’ll take me much more time to apprehend all HA scripting possibilities than I’ve anticipated. Therefore I’d like to ask if someone is willing to give me a bit of a push. And for that I’m offering a BIG THANK YOU!
I have a smart power plug I need to leave on or switch on/off depending if certain criteria has been met. This criteria is in form of a file presence (/config/checkfolder/check-file.txt) which doesn’t need to contain any data - can be completely empty. If the file has been found then no action is to take place and file is to be deleted. So far I’ve got this much regarding to implementing it but I don’t know what would be the best approach to achive it and I definitely don’t know how to implement if … then conditioning … and actually I haven’t figured if I can store return value to a variable from find_file or delete_file shell command …
shell_command:
find_file: find /config/checkfolder -name check-file.txt
delete_file: find /config/checkfolder -name check-file.txt
My idea is to make such script (?) called via SimpleScheduler add-on (or maybe Automations → Time pattern trigger?) every 15 minutes. I’ve also figured how to whitelist the folder so at least that’s not an issue.
Now if the check-file.txt has been found it should be deleted and no action should take place, so maybe command could look like:
shell_command:
find_file: find /config/checkfolder -name check-file.txt -exec rm -f /config/checkfolder/check-file.txt
but if it hasn’t been found then I want to turn off, wait and turn back on the smart plug.
But as I’ve already mentioned I don’t know if I can implement if … then conditioning in it.
If you’re willing pleae help me out. Thank you.