I’m looking for a way to dump historical sensor data to a variable so I can tie it to an AI task for predictive analysis.
For example, I have an ESP32 weight sensor tied to my water softener salt tank. I track the weight so I can see when to add salt. What I’d like to do is dump a section of that sensor data (say 30 days) into a variable that I can then feed into an AI Task for processing.
The AI Task is pretty straightforward, but I can’t find a way to dump the individual sensor valuse, along with date/time and save them.
Open the History panel from the left hand menu, select your sensor entity and set the date and time range you want. Then click the three dots icon on the top right of the page and select “Download data”. This will download a csv file of your data with timestamps.
Note that data from older than your recorder purge_keep_days setting (10 days by default) will be an hourly statistical average.
Also a quicker way to get to the history graph is to click the entity in your dashboard then the “Show more” link in the pop-up card.
You can use the recorder.get_statistics action to get statistics data. If your weight sensor is set up properly with a state class and a unit of measurement, then you should have hourly statistics for that entity recorded indefinitely.
You can use that action in an automation, process it with a template (if necessary) and send it out to your AI action.