Support Energy date picker? #463
Replies: 5 comments 8 replies
-
I second this request. It would enable a lot more entities to be graphed. This would be most useful to show data held in entities with state_class: total or state_class: total_increasing. For these entities the data is stored in the statistics table and it looks like a time-series table: column start_ts in the statistics table represents the time column (in UTC). The value to show is however harder to retrieve. Each time-frame's value must be calculated by taking the difference of the [sum] columns on 2 rows: the [sum] value of the row at the end of the time frame minus the [sum] value of the last row before the start of the time-frame. The recorder stores the statistics in 2 different time series:
Which results in this table:
To get the values per day, week, month, etc. one would simply sum up all the hourly values for that day, week, month, etc.. I very much would like to be able to create a graph from these total and total_increasing statistics, especially using the energy dashboard's date selection card as the selection criterium for the time-frame as was suggested by the OP. To give you an impression of which data could be easily put into a graph once this gets implemented, run the following query against your own homeassistant db:
|
Beta Was this translation helpful? Give feedback.
-
The Sankey Chart card supports having a date selector. It might be a good reference on how to implement it here. |
Beta Was this translation helpful? Give feedback.
-
I could really use this. |
Beta Was this translation helpful? Give feedback.
-
There have been some projects already supporting the energy date range picker as it is now. Besides that these projects show that it is very well possible to use the existing energy date picker, introducing another method will render such initiatives practically useless. I would therefor suggest to have the apexchart card support the existing date picker as well or at least make your solution compatible with the standard date picker as well.
These are the ones I use, there probably are more that I haven't discovered yet. |
Beta Was this translation helpful? Give feedback.
-
I also started with wanting to have a working response to something like energy date picker (I am specifically using Energy Period Selector Plus ). IMO, it's a set of features that are needed for reasonable experience, and they aren't necessarily specific to the energy date selection mechanism. Here's what I ended up with so far (I shall PR this when development here resumes):
There are some other little things that need fixing. E.g. compare likely results in two similar graphs, so things like extremas labels need to be placed a bit more intelligently. And probably a sane shared tooltip for irregular series (which is, arguably, an ApexCharts bug, so maybe working around it here is not the way). All of the above is still using ApexCharts-Card's data acquisition (just controlling it to match the current date range(s)), but I suppose for energy (or anything that's in HASS' collection), one could just use data_generator to read stats through the HASS object to avoid reading the data twice from the server. |
Beta Was this translation helpful? Give feedback.
-
It would be great if we could put an apex chart on a page containing type: energy-date-selection as mentioned here https://www.home-assistant.io/dashboards/energy/ and the apex chart adjust to match the dates/period in the picker. I'm sure it's possible using a combination of config template card and this websocket
but im yet to figure out how.
Any idea?
Beta Was this translation helpful? Give feedback.
All reactions