I’ve been reading a bit, trying to figure out what the best approach is, but I’m not really sure yet.
My end goal is to log a ton of data, from primarily MQTT sources, and have it automatically upload to my Google Drive. I’d like the data split into files each containing just a single day. Ideally the files should be plain text, as this is easily imported in to most programs.
Currently I have InfluxDB installed, but I can’t find where the data is stored.
TL:DR: I want to save MQTT data to Google Drive, each day a separate file, in plain text format.
Reading the documentation I can’t see if it possible to aggregate multiple “notifications” into a single file. I.e. all measurements from a Sonoff POW into a single file.
Howcome? Data is being sent from the sensor via MQTT once every 10 seconds.
(Bonus question: Is it possible to add headers for the data an easy way? I guess I could just run an automation that creates the file with the headers…)
That’s definitely a possibility as well. With the current “save value every 10 second” solution, I guess there’s a risk of saving duplicate values if a value hasn’t been updated. I feel that isn’t the proper approach.
I’d like all of the data management to be contained within HA, so the method covered in “Visualize your IoT data” is not optimal.
From the link that you provided, it seems like that method is manual. Or is there a way to make it automatic? I only have a limited experience with HA, and is still learning.
My current code works almost as it should. For some odd reason it logs every minute, not every 10 seconds.
However it just creates a file named ‘{{now().year}}-{{now().month}}-{{now().day}}’.csv. The idea was that whenever the date changed, the filename would also change and a new file would automatically be made. Neat… if it worked.
Someone suggested doing it with a shell_command instead, and posted this:
shell_command:
write_data_to_file: "echo 'data' | tee -a /share/{{now().strftime('%Y-%m-%d.csv')}}"
But that just results in: ERROR (MainThread) [homeassistant.components.shell_command] Error running command: echo ‘message’ | tee -a /share/{{now().strftime(’%Y-%m-%d.csv’)}}, return code: -11
I’m open to any ideas. I don’t have much experience with HA, so I might miss otherwise obvious mistakes.