I encountered an issue where the trendline for an item is not visualized even though the analyzer functions as expected. I spent some time in getting behind this issue so I want to share the solution for others encountering this.
trendlines need the data to be persisted in fixed time intervals. The default is every minute.
The trendline is using every 60th value to draw the trend (so the default is every hour).
There is an undocumented parameter “trendSampling” that can be used to change it.
Having a custom persistence strategy for e.g. every 10 minutes this parameter needs to be set to 6 to get the same result (every hour).
Having a persistence strategy on every change might causes data that is not usable for the trendlines and results in weird behavior. In my case a temperature item from my radiator does not have 60 changes a day, so nothing gets shown.
The default setup for OH3 comes with a rrd4j persistence. Without any changes it will persist every known item value every minute.
In my setup I installed the influxdb persistence addon (kept from former OH2 installation). It is set in a text based config file. The item persistence strategy for influx is to persist every change.
Installing the influx addon, causes the default rrd4j persistence to be removed completely.
Anyway getting the data series by calling http://[openhabip:port]/rest/persistence/items/[trendItemName] works fine.
The problem is, that the trendline needs to have a fixed interval to be drawn.
(due to the implementation openhab-webui/oh-trend.vue at main · openhab/openhab-webui · GitHub)
I use the persisted data with grafana and I do not want to record every minute.
Following this post I found during my research, I decided to install rrd4j addintionaly and explicitly in my addons.cfg file.
Afterwards rrd4j needs to be set in settings->persistence as default and then everything is working again. Data is then persisted in influx and rrd4j afterwards.
Having a look at the implementation I noticed an undocumented parameter “trendSampling” that can be used in widget configurations to set the detail level of the drawn line. It defines how many recoded data points get skipped between each point to draw the trend.
Maybe it is not documented, because the behavior can be ambigous due to different persistence strategies.
trendSampling: 10 on the left and none on the right
component: oh-label-card config: title: Temperature item: localCurrentTemperature trendItem: localCurrentTemperature trendSampling: 10