Smartmeter: Get delta values from "today" into a label cell

Hey guys.

I want to have the today’s value from the energy smartmeter within the label card in my OH overview page.

Yes. I can use a rule and put the data into another item. This is what I already use. But I want to save one rule and one item if possible.

I tried different things but in the end all of them are not working.

Any other suggestions?

component: oh-label-cell
config:
  expandable: false
  footer: = items.smartmeterEHZM_10180.displayState
  icon: iconify:mdi:power-from-grid
  label: = items.smartmeterEHZM_10180.deltaSince(now.minusDays(1)).displayState
  stateAsHeader: true
  title: Power from Grid
  trendItem: powerFromGrid_daily
  actionPage: page:page_59c71b4dfe
  action: navigate
  actionModalConfig: {}

Widgets are a completely different environment from rules. All you have access to from the Item in a widget is the state in various formats (number, displayState, etc.). You do not have access to any of the persistence functions in a widget.

The solution is to do what you have working, use a separate Item and a rule.

1 Like

Thx for your explanation.

@rlkoshak Sorry, I have a following question. Yesterday I created a chart with daily energy consumption.

config:
  chartType: month
  label: Power from Grid (kWh) 1-0:1.8.0
slots:
  grid:
    - component: oh-chart-grid
      config: {}
  xAxis:
    - component: oh-category-axis
      config:
        gridIndex: 0
        categoryType: month
        monthFormat: short
        weekdayFormat: short
  yAxis:
    - component: oh-value-axis
      config:
        gridIndex: 0
        name: kWh
  series:
    - component: oh-aggregate-series
      config:
        name: Power from Grid (kWh) 1-0:1.8.0
        item: smartmeterEHZM_10180
        gridIndex: 0
        xAxisIndex: 0
        yAxisIndex: 0
        type: bar
        dimension1: date
        aggregationFunction: diff_last
  tooltip:
    - component: oh-chart-tooltip
      config:
        confine: true
  legend:
    - component: oh-chart-legend
      config:
        bottom: 3
        type: scroll

I also have the today’s consumption item.

items.getItem("powerFromGrid_today").postUpdate(items.getItem("smartmeterEHZM_10180").persistence.deltaSince(time.toZDT('00:00')).state);

Do you know why both values are different?
Graph.
image
Item.
image

And … bonus question. I tried to get PowerFromGrid “and” PowerToGrid" with the same conditions to the same graph. I failed. Any hint? Or do I need to create two charts?

I don’t really do much with charts so will be of limited help here.

And there really isn’t enough information to say what is going on. It’s not clear what Item is being shown and how it’s updated.

I don’t think Charts update dynamically though. If there is a change in the Item’s state that change won’t necessarily be reflrected in the chart until you refresh the chart. That can account for a difference.

Not enough information to say. But I do know you can chart more than one Item on the same chart. Beyond that :man_shrugging: . We don’t know what you actually tried in enought detail.

I did loaded the chart with some seconds shifted to the Main UI item.
The item got calculated each time the smart-meter get a new value (from or to grid)

Got my chart now with much more trial and error. I already did this before, but it was a bit special. However. This is working now. Except the tool tip. It would be much better if I have both values per day on the same tool tip. This is a minor thing.

config:
  chartType: month
  label: Power from/to Grid (kWh)
slots:
  grid:
    - component: oh-chart-grid
      config: {}
  xAxis:
    - component: oh-category-axis
      config:
        gridIndex: 0
        categoryType: month
        monthFormat: short
        weekdayFormat: short
  yAxis:
    - component: oh-value-axis
      config:
        gridIndex: 0
        name: kWh
  series:
    - component: oh-aggregate-series
      config:
        name: Power from Grid (kWh) 1-0:1.8.0
        item: smartmeterEHZM_10180
        gridIndex: 0
        xAxisIndex: 0
        yAxisIndex: 0
        type: bar
        dimension1: date
        aggregationFunction: diff_last
    - component: oh-aggregate-series
      config:
        name: Power to Grid (kWh) 1-0:2.8.0
        item: smartmeterEHZM_10280
        gridIndex: 0
        xAxisIndex: 0
        yAxisIndex: 0
        type: bar
        dimension1: date
        aggregationFunction: diff_last
  tooltip:
    - component: oh-chart-tooltip
      config:
        confine: true

Updated chart including my special wishes.

config:
  chartType: month
  label: Power from/to Grid (kWh)
slots:
  grid:
    - component: oh-chart-grid
      config: {}
  xAxis:
    - component: oh-category-axis
      config:
        gridIndex: 0
        categoryType: month
        monthFormat: short
        weekdayFormat: short
        axisTick: {
          alignWithLabel: true
        }
  yAxis:
    - component: oh-value-axis
      config:
        gridIndex: 0
        name: kWh
  series:
    - component: oh-aggregate-series
      config:
        name: Power from Grid (kWh) 1-0:1.8.0
        item: smartmeterEHZM_10180
        gridIndex: 0
        xAxisIndex: 0
        yAxisIndex: 0
        type: bar
        dimension1: date
        aggregationFunction: diff_last
    - component: oh-aggregate-series
      config:
        name: Power to Grid (kWh) 1-0:2.8.0
        item: smartmeterEHZM_10280
        gridIndex: 0
        xAxisIndex: 0
        yAxisIndex: 0
        type: bar
        dimension1: date
        aggregationFunction: diff_last
  tooltip:
    - component: oh-chart-tooltip
      config:
        confine: true
        trigger: 'axis'
        axisPointer: {
          type: 'cross'
        }
  legend:
    - component: oh-chart-legend
      config:
        bottom: 3
        orient: horizontal
        show: true