Displaying delta-values in charts?

I do have classical items, which just add consumption of energy, water, …
Is there a way to display delta-values from one item?

What I’d like to achieve is:

  • daily consumption
  • perhaps weekly and monthly consumption

based on just on value-increasing item. Or do I need a virtual proxy item, which gets filled daily/weekly/monthly…?

Yes there is. You need to add an aggregate-series on the page configuration.
See example here:

config:
  chartType: day
  label: Wasserverbrauch
  period: D
  sidebar: true
  visibleTo:
    - role:administrator
slots:
  grid:
    - component: oh-chart-grid
      config: {}
  series:
    - component: oh-aggregate-series
      config:
        action: analyzer
        actionAnalyzerChartType: day
        actionAnalyzerItems:
          - Wasser_Zaehlerstand
        aggregationFunction: diff_last
        dimension1: hour
        gridIndex: 0
        item: Wasser_Zaehlerstand
        name: Wasserverbrauch
        type: bar
        xAxisIndex: 0
        yAxisIndex: 0
  xAxis:
    - component: oh-category-axis
      config:
        categoryType: day
        gridIndex: 0
        monthFormat: default
        weekdayFormat: default
  yAxis:
    - component: oh-value-axis
      config:
        gridIndex: 0
        name: Liter
        nameLocation: end
2 Likes

that’s aggregated for an hour.
What I’m looking for ist to replace this (useless) chart:


or even this:

but something like this (for that specific use case, there’s already a “daily”-item), e.g. starting daily/weekly/monthly:

My example will make this:


out of this:

But it can not be applied as default. You will have to create a custom page.

Or are you searching for something else?

yes, a cumulative line. But starting with 0 daily/weekly/monthly and possibly without the need of proxy items.

This post has been very useful for me as well. I can now make a plot showing e.g. hourly electricity consumption using influxdb persistence. Of course another possibility would be to use e.g. Grafana but that would add another complexity because I would like to keep my OH setup (under Win11) as simple as possible.

I have few questions:
-are there any possibilities to add a label (box) which would show the sum of the hourly values?
-I can create charts e.g. for monthly and yearly consumption but are there any possibilities to include all these charts (hourly, monthly, yearly) in a single page?

You can add a tooltip:

You could add a second grid. See also demo page (user: demo; password: demo):
https://demo.openhab.org/settings/pages/chart/chart_example_combined

A combined view in one grid you need to test. I never tried.

Many thanks for the info. I’ll need to make some testing with the tooltip.

Perhaps I wasn’t clear enough regarding multiple charts. Basically I want to have e.g. 3 separate charts (daily, monthly, yearly) in a page. The combined view has two plots but the X-axis is the same for both. In my case x-axis would be hour, day and month so basically 3 separate charts.

Awesome example. I don’t mean to highjack the thread, but I hope this is somewhat related. From your example I can now finally display data like this:

2023-10-13 10:00:09.626, 17329.3
2023-10-13 11:00:07.614, 17329.73
2023-10-13 12:00:07.487, 17330.16
2023-10-13 13:00:07.537, 17330.57
2023-10-13 14:00:07.477, 17331.68

Like this:

Do you know if it’s also possible to offset the hours? The last one - 14 - actually represents the consumption from 13:00-14:00, so I would rather display 13. I tried Offset Amount and Offset Unit (1 hour), but that seems to do something else (the aggregates change):

And also, display “day” totally confuses me:

Is it mixing yesterday’s data after 14:00 with today’s data until 14:00? Can it be avoided and instead show “last 24 hours”?

Code:

config:
  label: Energi
  sidebar: true
  period: D
slots:
  grid:
    - component: oh-chart-grid
      config: {}
  xAxis:
    - component: oh-category-axis
      config:
        gridIndex: 0
        categoryType: day
        monthFormat: default
        weekdayFormat: default
        dimension1: hour
        action: analyzer
        actionAnalyzerChartType: day
        actionAnalyzerItems:
          - Omnipower_Accumulated
  yAxis:
    - component: oh-value-axis
      config:
        gridIndex: 0
  series:
    - component: oh-aggregate-series
      config:
        name: Forbrug
        gridIndex: 0
        xAxisIndex: 0
        yAxisIndex: 0
        type: bar
        dimension1: hour
        aggregationFunction: diff_last
        item: Omnipower_Accumulated
        service: jdbc

It seems tha the tooltip works only for a single bar. I would like to have a label box which would show e.g. the total day consumption.

@laursen @jlikonen
Sorry, I can not help you with this specific questions.
For me, most of the time it is also trial and error with charts and pages :slight_smile: