Chart: Daily/Monthly/Yearly solar production from ever increasing yield total - Hoymiles HM-1500

Hello,
I’'m a complete beginner when it comes to openHAB and I have difficulties understanding the various concepts of this tool. I am a professional programmer though, so I’m confident that with the right information I’ll be able to figure things out. However, I think I need some conceptual help from you.

I use rrd4j persistence and have a Hoymiles HM-1500 solar inverter from which I read various channels via MQTT. One channel gives me the (accumulated) yield total, which is an ever increasing value similar to a power meter.

Another channel gives me the yield day, which resets to zero and increases once the inverter goes on in the morning, when the first sunlight hits the panels and the daily yield is reset.

The reset is not at 0:00 but when the inverter goes on:

I was able to create a chart page to display the daily power production with day-of-month:

config:
  chartType: month
  label: Solar Yield - Day of Month
  sidebar: true
slots:
  grid:
    - component: oh-chart-grid
      config:
        show: true
  xAxis:
    - component: oh-category-axis
      config:
        categoryType: month
        monthFormat: default
        weekdayFormat: default
        gridIndex: 0
  yAxis:
    - component: oh-value-axis
      config:
        gridIndex: 0
        name: kWh
  series:
    - component: oh-aggregate-series
      config:
        gridIndex: 0
        xAxisIndex: 0
        yAxisIndex: 0
        type: bar
        item: HM1500_HM1500_YieldDay
        aggregationFunction: last
        dimension1: date
        name: kW/h pro Tag
    - component: oh-aggregate-series
      config:
        name: Letzter Monat
        gridIndex: 0
        xAxisIndex: 0
        yAxisIndex: 0
        type: line
        item: HM1500_HM1500_YieldDay
        dimension1: date
        offsetAmount: 1
        offsetUnit: month
        aggregationFunction: last
  legend:
    - component: oh-chart-legend
      config:
        show: true
        orient: horizontal
  tooltip:
    - component: oh-chart-tooltip
      config:
        show: true
        orient: vertical

Now I would like to create 2 more charts:

  1. The first one should display the monthly power production on a yearly base and just like in the chart above, I’d like to have bars for the current year and a line for last year. So the x-axis should display the months (January, February, etc.) and the y-axis should display the power production. But how would I do that? I would need to take the last entry from each month and subtract the last point from the month before to get the actual delta which I would like to display as the bar.

    For example on July 1st 0:00 the yield total was 106 kW/h. On August 1st 0:00 it was 199 and on September 1st it was 374. So the bar should display 106 for June, 93 for July and 175 for August.

  2. The second chart should also be a bar chart and each bar should represent a whole year. Not sure if this is even possible. In the first year, I’d like to see only one bar, in the second year a second bar and maybe you can have up to the last 5 or 10 years so in the 11th year the 1st year will fall off the chart.

I hope the provided information is enough to guide me to the right location. :slight_smile: Thank you in advance.

  1. You’ll have to create a separate Item and a rule to do your delta calculation.

  2. Same approach. You’ll need a separate Item and rule for this as well.

The charts in OH don’t have a whole lot of bells and whistles to do more than just show what’s there in the database. If you need more, you have to do the aggregations in another Item or rule, or use some other service for charting like Grafana.

I see. So I would basically use OH to pipe stuff to a grafana instance and embed charts from there on the dashboard. phew. I’ll start with the item+rule approach first :smiley:

There really isn’t anything to do to “pipe” the data. You would have to use an external database like PostgreSQL, MariaDB, or InfluxDB instead of rrd4j. But Grafana will read from the same database that OH writes to.

Actually I like the rrd4j database because of the size limitation. What I meant was something like a rule to manually persist only the values I want to e. G. Mariadb. :slight_smile: I don’t want everything in mariadb to save some storage space

Which is what I describe above. Create a separate Item and make sure it’s excluded from automatically being persisted. Then in a rule, when you want to save the value, call tehg persist action on the Item.

rlkoshak, in fact you can do quite lot of different things with the build-in charting in OH.

I found a nice widget in this post. I modified it slightly for my purposes. You can put as many widgets in your page as you need. It does the delta calculation as well. I’m using InfluxDB but you can change it to rrd4j. Only thing which I haven’t figured out yet is how to calculate e.g. total daily and monthly electricity consumption. My code for plotting the electricity consumption is:

uid: Sahkonkulutus_tunti
tags: []
props:
  parameters:
    - context: item
      description: Main toggle item (use for single toggle or as main switch for group)
      label: Item
      name: item
      required: false
      type: TEXT
    - context: text
      default: You forgot to set a card title
      description: Pretty card label
      label: Title
      name: title
      required: false
      type: TEXT
  parameterGroups: []
timestamp: Oct 14, 2023, 3:17:47 PM
component: f7-card
config:
  title: =props.title
  class:
    - padding-bottom
slots:
  default:
    - component: f7-row
      config:
        class:
          - margin-top
      slots:
        default:
          - component: f7-col
            config:
              width: 75
            slots:
              default:
                - component: oh-chart
                  config:
                    chartType: day
                    label: Kulutus
                  slots:
                    grid:
                      - component: oh-chart-grid
                        config:
                          containLabel: false
                    xAxis:
                      - component: oh-category-axis
                        config:
                          gridIndex: 0
                          categoryType: day
                          weekdayFormat: default
                          monthFormat: default
                    yAxis:
                      - component: oh-value-axis
                        config:
                          gridIndex: 0
                          name: Kulutus (kWh)
                    series:
                      - component: oh-aggregate-series
                        config:
                          name: Sähkönkulutus
                          service: influxdb
                          aggregationFunction: diff_last
                          gridIndex: 0
                          xAxisIndex: 0
                          yAxisIndex: 0
                          type: bar
                          item: =props.item
                          dimension1: hour
                    tooltip:
                      - component: oh-chart-tooltip
                        config:
                          action: analyzer
                          actionAnalyzerChartType: day
                          actionAnalyzerItems:
                            - props.item
                          aggregationFunction: sum
                          presetFeatures:
                            - dataZoom
                          right: right
                          show: true
                          top: top
                    legend:
                      - component: oh-chart-legend
                        config:
                          bottom: 3
                          type: scroll
                    dataZoom:
                      - component: oh-chart-datazoom
                        config:
                          type: inside

Attached please find a screen copy on my page for the electricity meter. The chart on the left is the hourly consumption, middle one the daily and the last one the monthly consumption. By clicking “<” or “>” buttons you can go back and forth in time. As you can see you can add several widgets on the same page.

Can this widget be modified, so that you also see decades or 5 years. I also want to see the past in years.

I think one year is the longest period. I’m using the following code for yearly consumption:

uid: Sahkonkulutus_vuosi
tags: []
props:
  parameters:
    - context: item
      description: Main toggle item (use for single toggle or as main switch for group)
      label: Item
      name: item
      required: false
      type: TEXT
    - context: text
      default: You forgot to set a card title
      description: Pretty card label
      label: Title
      name: title
      required: false
      type: TEXT
  parameterGroups: []
timestamp: Oct 14, 2023, 5:52:25 PM
component: f7-card
config:
  class:
    - padding-bottom
  title: =props.title
slots:
  default:
    - component: f7-row
      config:
        class:
          - margin-top
      slots:
        default:
          - component: f7-col
            config:
              width: 75
            slots:
              default:
                - component: oh-chart
                  config:
                    chartType: year
                    label: Kulutus
                  slots:
                    dataZoom:
                      - component: oh-chart-datazoom
                        config:
                          type: inside
                    grid:
                      - component: oh-chart-grid
                        config:
                          containLabel: false
                          left: "40"
                          width: 83%
                    legend:
                      - component: oh-chart-legend
                        config:
                          bottom: 3
                          type: scroll
                    series:
                      - component: oh-aggregate-series
                        config:
                          aggregationFunction: diff_last
                          dimension1: month
                          gridIndex: 0
                          item: =props.item
                          name: Sähkönkulutus
                          service: influxdb
                          type: bar
                          xAxisIndex: 0
                          yAxisIndex: 0
                    tooltip:
                      - component: oh-chart-tooltip
                        config:
                          action: analyzer
                          actionAnalyzerChartType: month
                          actionAnalyzerItems:
                            - props.item
                          aggregationFunction: sum
                          presetFeatures:
                            - dataZoom
                          right: right
                          show: true
                          top: top
                    xAxis:
                      - component: oh-category-axis
                        config:
                          categoryType: year
                          gridIndex: 0
                          monthFormat: default
                          name: Kuukausi
                          nameGap: 25
                          nameLocation: center
                          weekdayFormat: default
                    yAxis:
                      - component: oh-value-axis
                        config:
                          gridIndex: 0
                          name: Kulutus (kWh)
                          nameGap: 25
                          nameLocation: center

This is basically very similar to my code above.

Only problem I’m having are the lines in the tooltip part:

action: analyzer
                          actionAnalyzerChartType: month
                          actionAnalyzerItems:
                            - props.item
                          aggregationFunction: sum

I would like to get the total daily, monthly or yearly consumption but it seems that the tooltip is not meant for this purpose so the snippet above doesn’t work.

Hi Jari, I really like your widget as I was looking for something similar. Two of them work fine (day and year overview). However I tried to get it working for an overview on a month base (aggregated per day) but don’t get it working. Below my code, maybe you can see whatever I am doing wrong or even share your code (again)?

I am running OH 4.0.2.

uid: barchart_day_v1
tags: []
props:
  parameters:
    - context: item
      description: Main toggle item (use for single toggle or as main switch for group)
      label: Item
      name: item
      required: false
      type: TEXT
    - context: text
      default: You forgot to set a card title
      description: Pretty card label
      label: Title
      name: title
      required: false
      type: TEXT
  parameterGroups: []
timestamp: Oct 15, 2023, 9:07:20 AM
component: f7-card
config:
  class:
    - padding-bottom
  title: =props.title
slots:
  default:
    - component: f7-row
      config:
        class:
          - margin-top
      slots:
        default:
          - component: f7-col
            config:
              width: 75
            slots:
              default:
                - component: oh-chart
                  config:
                    chartType: month
                    label: Usage
                  slots:
                    dataZoom:
                      - component: oh-chart-datazoom
                        config:
                          type: inside
                    grid:
                      - component: oh-chart-grid
                        config:
                          containLabel: false
                          left: "40"
                          width: 83%
                    legend:
                      - component: oh-chart-legend
                        config:
                          bottom: 3
                          type: scroll
                    series:
                      - component: oh-aggregate-series
                        config:
                          aggregationFunction: sum
                          dimension1: weekday
                          gridIndex: 0
                          item: =props.item
                          name: Electricity_usage
                          service: jdbc
                          type: bar
                          xAxisIndex: 0
                          yAxisIndex: 0
                    tooltip:
                      - component: oh-chart-tooltip
                        config:
                          action: analyzer
                          actionAnalyzerChartType: weekday
                          actionAnalyzerItems:
                            - props.item
                          aggregationFunction: sum
                          presetFeatures:
                            - dataZoom
                          right: right
                          show: true
                          top: top
                    xAxis:
                      - component: oh-category-axis
                        config:
                          categoryType: month
                          gridIndex: 0
                          monthFormat: default
                          name: Day
                          nameGap: 25
                          nameLocation: center
                    yAxis:
                      - component: oh-value-axis
                        config:
                          gridIndex: 0
                          name: Usage (kWh)
                          nameGap: 25
                          nameLocation: center

Best regards.

Hi Jari, never mind my question. Stupid mistake: dimension1: weekday should be dimension1: date.

Hi HWL, OK good that you managed to find the mistake.

Actually you don’t need a widget at all. You can also make chart pages:

This topic was automatically closed 41 days after the last reply. New replies are no longer allowed.