Write data to csv files and store in Network drive

Hi,

I want to collect data from HA sensors into csv-files and store those in a defined network drive. The storage should be done automatically every week into file looking like this: data$YY$WW.csv. The file structure should be: Date, Sensor1, Sensor2, … with a header description. A Network drive is already there. Does anybody can provide a script for this? Thanks,

Holger

OK, thanks, understand so far. But how do I realize, saving all data from the specified sensors of the last week?

What do you mean by:

This method writes data when you call the service. You can do this using an automation and a time pattern trigger. It can only write current data. Not data from the past.

You can accumulate data over time with history_stats.

I’m not sure what you’re after, but for example I accumulate my heating system oil burner runtime, along with the runtime for each heating and cooling zone. These all go into csv files. I track each on/off event, as well as a daily summery of run-time for each entity.

I’ve posted some of this process before. There are a couple of posts in this thread which might help explain what I’m doing.