Lets just start of by saying I’m new and clueless.
I have tried lots of different approaches, but can’t get any of them to work.
What I’m trying for is to look for the presence of a text file called file.txt in a directory on my server.
Path to file is from server root: /data/hass/files.txt
I want this read out as a message, and the file deleted upon a successful read.
Can anyone point me in the right direction?
I have tried the file sensor, but the configuration checker keeps saying my config is wrong.
Invalid config for [sensor.file]: not a file for dictionary value @ data[‘file_path’]. Got ‘/data/hass/les.txt’. (See ?, line ?). Please check the docs at https://home-assistant.io/components/sensor.file/
Even if you got the file sensor working, that wouldn’t solve the “delete upon successful read” part of the requirement. I’m not aware of any standard feature of HA that would do this. (There might be; I just don’t know.)
The tack I would take is to set up something outside of HA (e.g., a cron job that runs a shell or Python script periodically) to monitor the file, and when it exists, read its contents and then delete it. Then fire an event in HA via its REST API, including the file contents as event_data. Then in HA you could use that event to trigger an automation that does whatever you want with the message.
Or, if you’re comfortable with Python programming, you could even create a custom HA component that would do the work.
Or, is file.txt just an in-between you created from some other process running outside of HA? If so, maybe that process could fire the event in HA directly instead of creating file.text.