I am running OpenHAB version 5.1.0 M2 in a docker container on my NAS. I am starting to create pages and found that in the standard label cell there is a trendline drawn in light blue in the background of e. g. a temperature:
It looks like the trendline reflects the temperature flow of the current day ( “D” or “24h” ). Is there a way to customize the trend line time interval to reflect e. g. 2 days or 1 week?
Probably it is the Trend Line Width or trendWidth but the documentation has no explanation about it?
@justaoldman, thank you very much for your response
trendSampling only increases/decreases the accuracy of the graph within the same time interval:
trendSampling < 60 = higher accuracy
trendSampling > 60 = lower accuracy
This is the sampling rate in the same time window. You can see in the screenshot where the left cell has the default (trendSampling=60) that the middle graph (trendSampling=30) is finer and the right graph (trendSampling=120) is smoother. This is because there are more data samples in the same time in the middle graph (every 30 seconds) and less data samples in the right graph (every 120 seconds) - and they all are showing the same time interval:
yes, I guess I misunderstood what you were asking.
For changing the actual total time displayed in the graph you would likely need to change your persistence configuration and maybe even the type of DB storage used for persistence for that item to increase the default sample duration.
@JustinG
Do you know where that hard coded value is located?
Any Idea why 24 hours was selected as the value?
I also had previously wanted to alter that trend line for some items that a long duration such as 24 hours was less meaningful for a quick glance at a widget.
The API call is made in the oh-trend component. The call is to the persistence/items/{item name} end point and the call itself is fully basic. That means that the API call returns its default time range which is the most recent 24 hour period. So the value is technically set in core and not even in the UI. Changing that would require reworking that API call to possibly include the beginning and end times.
Thanks @JustinG
I did look at the trend.vue code and saw what you mentioned regarding the api call to the persistence as a basic itemname with no other parameters. So I understand now why it just returns past 24 hours only. @florian-h05 I saw where you did a fix on the trend component for an issue with sampling back in 2023 is there any possible concern from a performance perspective that would prevent adding something like a trend duration variable that allowed increasing or decreasing the amount of total time a trend sample could be? Perhaps in hours and default it to 24 if no value is declared?
Anyway, I don’t see a reason to not allow other time frames, but I am against changing the default to a higher value.
That would increase the data points requested per trend line, which will increase network traffic and may be a problem both with slow persistence services and low bandwidth networks.
So I would be happy to accept a PR allowing different time frames than the 24 hours. I think specifying time frames in hours makes most sense. But I would add a word of warning to the parameter description so that users are aware, I don’t want to get „bug reports“ „my trendlines load super slow“ after users setting the time frame to a week.
Thanks for the reply @florian-h05
I guess I did not realize that was not you.
I doubt I would not be the correct person to do a PR as I have not done enough in vue be confident in making that kind of change but hopefully someone with more experience in that code style might consider picking this up as a possible enhancement.
Honestly, I do not think anything I may come up with even using AI to assist would properly solution such a change to the codebase.
It depends on how much you are into programming in general if you can do it.
In your case the required change only requires modifying JavaScript code, no need to touch the Vue template. So if you have experience with JavaScript or Java that should be sufficient.
You need to add a new parameter for the time range, then use it when requesting data from persistence (examples of how to build query parameters for persistence can be found in chart-mixin.js) and you should be finished.