That works great thanks! At first I missed the .state
part and logged quite a bit of junk but now it works perfectly!
You use hassio and influxdb addon?
I just have an old hasbian installation.
what would be every hour automation?
thanks.
How would you add a time stamp?
EDIT, found
notify:
- platform: file
name: filenotify
filename: /share/history/10sec_power_reading.csv
#timestamp: true
automation:
- alias: sensor_values_to_file
initial_state: 'on'
trigger:
- platform: time
seconds: 10
action:
- service: notify.filenotify
data_template:
message: '{{ states.sensor.efergy_802171.state }}; {{now().strftime("%Y%m%d-%H%M%S")}}'
Also, if you want to make csv replace the ;
with ,
.
Here is what worked for me (every 5 min):
notify:
- platform: file
name: filenotify
filename: /home/homeassistant/.homeassistant/training.csv
timestamp: true
automation:
- alias: sensor_values_to_file
initial_state: 'on'
trigger:
- platform: time
minutes: '/5'
seconds: 00
action:
- service: notify.filenotify
data_template:
message: ", {{ states.sensor.outside_air_intake_temperature.state }},{{ states.sensor.dark_sky_temperature.state }},{{ states.sensor.dark_sky_humidity.state }},{{ states.sensor.dark_sky_cloud_coverage.state }},{{ states.sensor.dark_sky_uv_index.state }},{{ states.sensor.dark_sky_wind_speed.state }}"
a curiousity, why do you keep track of those dark sky values?
The first value is the temperature inside my fresh air intake for the house - the dark sky relates to outside temps. When I open my fresh air intake it takes air passively through the intake (as the house HVAC runs some fresh air comes in) - so the temp of the intake air is not usually the same as the outside air. I want to train an regressor that can predict intake air temperature based on outside conditions (like if it is sunny the roof will be hot and therefore the air that is taken in will go through the hot attic before coming in). This way I can open the air intake and draw in air only when the air that comes is close to the temp of the house. So I can get fresh air without having to worry about heating or cooling the house with it.
This is my current implementation - just looking at temp over the day and figuring out the times best to open (green) and close (red) the air intake. But my temp sensor in the air intake shows that the intake temp is very different from the forecasted temps…
I know this is an old thread but it’s exactly what I am trying to do. I am getting the error message
" Invalid config for [automation]: [minutes] is an invalid option for [automation]. Check: automation->trigger->0->minutes. (See /config/configuration.yaml, line 190)."
I also have all the below in the confi.yaml
notify:
- platform: file
name: filenotify
filename: /config/TEMPHISOTRY.csv
timestamp: true
automation:
- alias: sensor_values_to_file
initial_state: 'on'
trigger:
- platform: time
minutes: 5
seconds: 0
action:
- service: notify.filenotify
data_template:
message: "{{ states.sensor.lumi_lumi_weather_640d3002_temperature.state }};{{ states.sensor.netatmo_meadowcroft_outdoor_temperature.state }}"
Thank you, that got rid of the error message but still nothing is being written to the file. Any ideas? This is setup to write the data to a file every 5 minutes, so this will not pull history just the data going forward?
I spoke to soon, the moment I posted that reply it wrote data to the file.
It’s only exporting once an hour not every 5 minutes. Thoughts on why?
2020-09-08T22:05:00.010603+00:00 67.6;84.9
2020-09-08T23:05:00.011470+00:00 67.6;84.9
It needs to be: minutes: "/5"
Hopefully last question. Ideas on why the timestamp would be 5 hours off in my export. My home assistant is showing the correct time, but the export is showing as below. As a reference it’s 9/8/2020 7:30PM here now.
2020-09-08T23:55:00.010952+00:00 68.4;84
2020-09-09T00:00:00.010803+00:00 65.7;84
2020-09-09T00:05:00.009439+00:00 65.7;84
2020-09-09T00:10:00.008813+00:00 65.8;83.8
2020-09-09T00:15:00.012108+00:00 67.8;83.8
2020-09-09T00:20:00.011138+00:00 68.4;83.7
2020-09-09T00:25:00.011668+00:00 65.5;83.7
Probably because of the time zone you’re in. Home Assistant uses UTC internally. So, you might want to compensate for that.
I use a HA 0.115.4 installation on RasPi 4 and I am new at Home Assistant.
For later use in MS-Excel I do an export of sensor data to csv-File. To do this, I configured file notification and automation as described in this thread. My continuous export with an interval of 10 minutes works fine.
My problem is, that all data is written into one file I configured with file notification:
notify:
- platform: file
name: filenotify
filename: temp.csv
I better would do the export on a daily base. That means, I would like to have one file per day.
How could I achieve this? Can I use current date in combination with filename? So the file notification service would create a new file at every new day. Something like:
filename: {{now().strftime("%Y%m%d")_temp.csv
Hi
2 questions if I may.
- did you find a solution regarding the new file each day?
- did you notice any misbehavior to HA (eg slower) if the automation is running all the time?