Hi All, I have a sensor that I wish to write out it value to a CSV file, every so often.
So I followed the following steps,
(a) Added the following to my Configuration.yaml file
(b) Added the File Intergration and setup as below
(c) Created the automation shown below
(d) created the directory /tmp at the root level on my HA green box.
Note: I even tried creating the tmp directory inside the config directory as someone suggested that paths are relative to this directory.
I also created the file in each of these directories with a touch w.log command.
(e) I then manualy ran the automation which showed no errors and give the following trace output.
(f) check the file w.log in the tmp directory, size 0 bytes. If my automation ran with no errors WHAT FILE DID IT WRITE THE DATA TO?
Any help would be gratefully received. Many thanks.
As a side note, I could us the method described by David Proffer.
Query example to get whole house power usage for last two days, the SQL code may vary some for use with SQLite. Be gentle with your queries on the SQLite database of HA, if that is your default database, as it not as robust as other database. If you are going to experiment, first shutdown HA for a bit and copy the SQLite database to a test copy and then explore this copy of the data without effecting your HA running instance :
-- get SCE whole house power
SELECT
*
FROM
states
WHERE (entity_id = 'sensor.home_instantaneous_demand'
AND last_updated > now() - interval '2 days')
ORDER BY
last_updated DESC;
-- sqlite interval example :
-- https://stackoverflow.com/questions/1101182/what-are-the-sqlite-equivalents-of-mysqls-interval-and-utc-timestamp/7547245