Greetings - I’m using the Tesla Solar integration to track/calculate data about my solar installation and I’ve discovered that the number of kWh imported and exported is stored as always-increasing numbers from the time of install.
I’m trying to create a Helper that will look at those entity values and then extract out a summarized value for a given date range (i.e, how much has been exported since midnight today). I’ve tried a History Stats helper but wasn’t able to get any data for and I’m now wondering how to best go about this task.
The built-in Energy distribution card is able to do what I want to do - it either has access to this data or calculates it (or both) and shows the information (highlighted in red, below) for any given day, but I’m not sure how to get at those values behind the scenes, or if I even can.
How do I calculate these derived values given the source entity data is likely stored in the HA database (I’m guessing here, seems like the obvious place) and has to be timestamped as well.
I can work my way thorugh the required SQL - in looking at the SQL Sensor documentation, I have to specify a query as part of setting up the sensor, so that’s going to take some database research on my part to finish that up. I’m running MariaDB on my HA install, so I’ll dig into that.
On the Utility Meter helper… does it collect and/or render data only at the cycle time? I set one of those up previously and I didn’t see any data being collected straight away, but was curious if I’d have to wait a day before any data would populate. If that’s the case, then it probalby won’t suit as I’m looking for the information to be updated in real time (like the energy distribution card) and if it’s always a static number that represents, best case, the prior day, then it won’t be helpful on my dashboard.
Are you getting the sensor data from the Tesla integration or somewhere else? In looking at the entities and sensors on my system, I’m not seeing the 'grid_power_w" sensor, so that’s why I’m asking where that sensor is sourced from.
Add-on question - is it possible to use the date/period picker with a sensor card and step back through the utility meter’s historical data? Will that work or would I need to do something else to page through the data?