Skip to content
This repository has been archived by the owner on Mar 20, 2024. It is now read-only.

Any plans to support HA statistics? #7

Closed
dm82m opened this issue Jan 25, 2022 · 13 comments
Closed

Any plans to support HA statistics? #7

dm82m opened this issue Jan 25, 2022 · 13 comments
Labels
enhancement New feature or request

Comments

@dm82m
Copy link

dm82m commented Jan 25, 2022

Hey Alex,

first of all: thank you very much for your work!

And then a question: currently your chart takes the last saved data. Is there any plan to support also the statistics?

Best,
Dirk

@dm82m
Copy link
Author

dm82m commented Jan 25, 2022

the statistics graph shows older data compared to your history card:

image

image

@alexarch21
Copy link
Owner

Hi, long term statistics support wasn't on my radar at this time. How long is your normal recorder data retention time (ie. purge_keep_days in the recorder config) ? The card seems to be showing less than a day, that's definitely not normal. What happens when you scroll left or increase the viewed time range to a few days or a week?

@dm82m
Copy link
Author

dm82m commented Jan 25, 2022

Default it shows the last 10 days. But no worries I just wanted to asked if statistics support is plannedy

@alexarch21
Copy link
Owner

Ah okay, I'll look into it. I'll mark this as a FR.

@alexarch21 alexarch21 added the enhancement New feature or request label Jan 26, 2022
@jnxxx
Copy link

jnxxx commented Apr 23, 2022

I just found this card and I like it a lot.
+1 for statistics data, to make it even better.

I believe statistics was made as a lightweight method to store long-term data (in lower resolution). So, quite relevant for a History Explorer.
And with this scrolling view, really nice if you could go further back.

Additionally, if you can get statistics data it would be neat to have a delta option for metered values, like an electricity, heat, gas or water meter. There it is not so much the value that is of interest but instead the change, growth or decline.

@KHV8
Copy link

KHV8 commented Jul 13, 2022

Plus one for statestics data.

@alexarch21
Copy link
Owner

Yeah, statistics are on the backlog. I also think that supporting them would be very beneficial. The problem is that supporting them in a good way, seamlessly integrated with normal history and the caching and scrolling etc, is a considerably amount of work. Especially since HA exposes them in a completely different way than normal history, for whatever reason.

So this is something that will definitely come to the history explorer card, but I can't guarantee when exactly.

@rct
Copy link

rct commented Oct 10, 2022

The problem is that supporting them in a good way, seamlessly integrated with normal history

This seems like something where there should be support in the HA integrations that provide history and statistics. From a user's perspective why are they separate and distinct?

Access to the statistics data in HA is so poor right now that there is a lot of room for improvement. So any access to statistics data beyond the current statistics card would be a help.

@FrnchFrgg
Copy link

Apex-charts card already supports long-term statistics. See https://github.com/RomRider/apexcharts-card/blob/master/src/graphEntry.ts#L257 for the if/else clauses with first statistics fetching then normal history fetching. AFAICT the difference is not much and mostly in _fetchStatistics vs _fetchRecent even though the value of the datapoint then comes from item[period] instead of item.state (and there is a difference too for the datetime). To me it seems that retrofitting the statistics fetching into a format understood by the existing history-explorer-card data handling is not too hard.

I have no time right now but maybe at one point in the next month I'll get to it.

@alexarch21
Copy link
Owner

alexarch21 commented Oct 10, 2022

The data fetching itself is not the issue and is already done. The problem comes from the way how the card does the streaming by issuing async fetches. HA reacts weird when issuing multiple statistics and history fetches at the same time. Requests have a tendency to fail randomly and need to be re-requested, at least on the SQLite backend. Besides that, the local caching structure the card uses also needs to be adjusted with a dynamic slot allocation scheme (rather than the current fixed one) so to efficiently handle entities with and without long range stats shown in the same graph or view.

To clarify. I'm not looking into making this a history / statistics toggle where you could select the one over the other in the config. The idea is to fuse both in the same graph, completely transparent to the user, accessing data simultaneously from both sources if available and use the most appropriate source depending on shown time range, how far back you scrolled, etc.

@alexarch21
Copy link
Owner

This seems like something where there should be support in the HA integrations that provide history and statistics. From a user's perspective why are they separate and distinct?

Access to the statistics data in HA is so poor right now that there is a lot of room for improvement. So any access to statistics data beyond the current statistics card would be a help.

When you look at the HA source, it is pretty obvious that the entire statistics thing was bolted onto the existing system as a completely separate entity, with no attempt made to integrate it into the existing history subsystem. This concept of two entirely separate history gathering and request subsystems then carried over to the UX. I don't really understand why it was done that way, but I guess they probably had their reasons.

@alexarch21
Copy link
Owner

V1.0.30 adds (experimental) seamless statistics support.

See this post on the HA forums for more info:
https://community.home-assistant.io/t/new-interactive-history-explorer-custom-card/369450/332

Feedback welcome.

@alexarch21
Copy link
Owner

Long term statistics are now fully supported as of V1.0.32.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

6 participants