mini-graph-card icon indicating copy to clipboard operation
mini-graph-card copied to clipboard

Graph with aggregate_func: diff should show diff value instead of total value

Open EmJay276 opened this issue 3 years ago • 2 comments

Hi, I have a sensor for my total energy consumption and I am trying to rebuild the "energy-usage-graph" from the energy dashbaord with the mini-graph-card.

Using the "aggregate_func: diff" option works fine, but the value shown is still the total value instead of the diff value.

Plotting the energy consumption within the last 24h gives this graph (realy nice!), but the total power consumed (within the last 24h) is not "75,29 kWh" (this is the total value sind start of the sensor). grafik

type: custom:mini-graph-card
entities:
  - entity: sensor.energy_total
    aggregate_func: diff
color_thresholds:
  - value: 0
    color: '#2ecc71'
  - color: '#f1c40f'
  - value: 1
    color: '#e74c3c'
hour24: true
points_per_hour: 1
lower_bound: 0
hours_to_show: 24

I would expect to show the power consumed within the last 24h, which is roughtly 6 kWh. Any suggestions hot to solve this?

EmJay276 avatar Feb 21 '22 22:02 EmJay276

Hey, the graph shows the current state by default indeed We do have a last option to show the value of the last graph point instead but you'd like a current - starting value, right?

show:
    state: last

Should already give you the last instead of current state, hope this helps for now.

Putting the extra feature on our radar!

jlsjonas avatar Feb 22 '22 21:02 jlsjonas

Hey, the graph shows the current state by default indeed We do have a last option to show the value of the last graph point instead but you'd like a current - starting value, right?

Putting the extra feature on our radar!

Hey,

a current - starting value is exactly what I am looking for (and expecting as default when I'm using the aggregate_func: diff) Thanks for adding!

Cause you mentioned: Using the state: last results in a nice graph for a group_by: date graph for several days :+1:, but the value shown is not correct. It should be 7.54 kWh instead of 8.09 kWh. If I use smoothing: false the value 7.54 kWh is correct. Already mentioned in https://github.com/kalkih/mini-graph-card/issues/659, https://github.com/kalkih/mini-graph-card/issues/722

smoothing: true

type: custom:mini-graph-card
entities:
  - entity: sensor.energy_total
    aggregate_func: diff
color_thresholds:
  - value: 0
    color: '#2ecc71'
  - color: '#f1c40f'
  - value: 14
    color: '#e74c3c'
hour24: true
lower_bound: 0
hours_to_show: 240
show:
  state: last
group_by: date

grafik

smoothing: false

type: custom:mini-graph-card
entities:
  - entity: sensor.energy_total
    aggregate_func: diff
color_thresholds:
  - value: 0
    color: '#2ecc71'
  - color: '#f1c40f'
  - value: 14
    color: '#e74c3c'
hour24: true
lower_bound: 0
hours_to_show: 240
show:
  state: last
group_by: date
smoothing: false

grafik

EmJay276 avatar Feb 22 '22 21:02 EmJay276