File sensor

Hello guys

I am trying to create a custom file sensor which sends me the complete data from a file and not just the last line of that file.
The idea is to setup a local file which stores all my tasks and through TTS, every morning once I switch off my alarm, it reads me out my tasks for the day.
I am able to save data to local file using command line sensor but the only problem I am facing is in sensing the complete data to TTS.
My current logic is to send the complete content data to a custom file sensor, and make tts read it when I run the automation.

Here is the link for reference of the file.py sensor: https://github.com/home-assistant/home-assistant/blob/dev/homeassistant/components/sensor/file.py

When returning the data, it is returning the last ‘line’ but I want to return the ‘file_data’ itself.
I tried applying this ‘data = data + line’ , but it is not working. Shows ‘unknown’ in the sensor value. (it offcourse shouldn’t work because ‘data’ is not defined earlier in the ‘for’ loop)

It might be easier to use mqtt sensor to hold the data instead of a file since HA can publish and read mqtt easily.

1 Like

That’s a way to go about it. But as of now all of my other automations have been built around the idea where data comes in through a file as a sensor.
I’m sure there must be a way to do it through a custom file sensor as well.
If nothing works, I will have to shift to MQTT.