kalkih / mini-graph-card

Minimalistic graph card for Home Assistant Lovelace UI
MIT License
3.04k stars 235 forks source link

[FR] Separate "decimals" options for each entity #863

Open szymucha94 opened 1 year ago

szymucha94 commented 1 year ago

Please separate "decimals" parameter for main entity value that is shown on the card and additional entities that are shown only as graphs. Currently I'm forced to use "decimals: 2" for both graph and main entity which results in unnecessary zeros after decimal point for power usage while two decimal points are necessary for energy consumption readings: 1 2

Please, pretty please :) Cheers

ildar170975 commented 1 year ago

main entity value that is shown on the card and additional entities that are shown only as graphs.

Not clear what you mean by "main value shown on the card" & "additional entities shown only as graphs". Every entity may be shown as a graph and/or as a state. Do you mean that your card (which you decided not to explain by a code) contains 2 entities - with a state, w/o a graph + w/o a state, with a graph ?

szymucha94 commented 1 year ago

This is my card:

type: custom:mini-graph-card
view_layout:
  column: 2
entities:
  - entity: sensor.mainenergymetercurrent_power
    show_graph: false
    show_state: true
  - entity: sensor.mainenergymetertotal_energy
    show_graph: true
    show_state: false
    name: Energy consumption
name: Current Power Consumption
hour24: true
aggregate_func: delta
hours_to_show: 18
height: 88
decimals: 2
points_per_hour: 1
update_interval: 600
labels_secondary: false
group_by: hour
show:
  graph: bar
  labels: false
  fill: true

What I need is to represent sensor.mainenergymetercurrent_power as integer and sensor.mainenergymetertotal_energy as float. Currently if I set "decimals: 0" sensor.mainenergymetercurrent_power is represented as expected, but sensor.mainenergymetertotal_energy (per hour) is shown as zero. So I've set "decimals: 2" which makes sensor.mainenergymetertotal_energy (per hour) readable, but on the other hand sensor.mainenergymetercurrent_power now has useless zeros after dot.

ildar170975 commented 1 year ago

Next time use TRIPLE "`" for code. Formatted the code by myself.


labels_secondary: false - must be used inside the show section. Here this option is meaningless - you have no entities assigned for the secondary axis.


So, your proposal is to support separate decimals options for each entity?

szymucha94 commented 1 year ago

Yes, precisely.

jlsjonas commented 1 year ago

This will be fixed as part of the configuration update, allowing you to set most options on entity-level with global defaults/overrides!

SeBsZ commented 1 hour ago

Hey was this ever added? I'm trying to show two entities, one without decimals and the other has 1 decimal. I can't set this to show correctly without per-entity decimal settings. Is this still planned or does someone know of a workaround?