Notify.file - Setup, so confused, please help

I am trying to set up an external file notification within my HA instance that will export sensor data at the end of every day to a csv file that I can later do analysis on. I am tracking how many hours a day and how much energy my A/C system is using relative to the outside temperature.

I already have the message formatted correctly and being sent to my phone every night at 11:59. What I cannot figure out is how to use the notify.file functionality within HA. I have searched the HA documentation, the HA forums and this sub. The more I search and read the more confused I become. It looks like you have to setup multiple pieces within your config file and possibly other places? Can anyone explain to me like I’m 5, how to properly set up this integration so that I can export the data?

This is set up from the UI now.

Go to Settings → Devices & Services, then click the add integration button lower right.

Search for and select the File integration. In the next step select the notification option. Then after that choose where you want your file saved (e.g. /config/my_data_file.csv) and if you want a timestamp added to each line, I would suggest you do add this.

Then create an automation to write to the file at the end of every day:

trigger:
  - platform: time
    at: "23:59:59"
action:
  - service: notify.send_message
    target: 
      entity_id: notify.your_file_notification_entity_id_here
    data:
      message: "{{ states('sensor.first_sensor')}},{{ states('sensor.second_sensor')}},{{ states('sensor.third_sensor')}}"

You can find the entity_id of your notifier in either Developer Tools → States, or Settings → Devices & Services → Entities tab at top of the page.

Replace the sensor entity ids in the template with the sensors you want to record, you can have as many as you want.

2 Likes

@tom_l Thank you so much for the help! I was able to get everything working thanks to your comment. I knew it had to be much simpler than I was making it.

1 Like