kalkih / mini-graph-card

Minimalistic graph card for Home Assistant Lovelace UI
MIT License
2.96k stars 232 forks source link

documention: thresholds #894

Closed nschloe closed 7 months ago

nschloe commented 1 year ago

The main documentation gives

color_thresholds:
  - value: 0
    color: "#ff0000"
  - value: 1.333333
    color: "#ffff00"
  - value: 2.666667
    color: "#00ff00"
  - value: 4
    color: "#0000ff"

as an example for color thresholding. What exactly does this mean?

jlsjonas commented 1 year ago

Hi, this should indeed be cleared up a little!

Essentially, the color_treshold value works like a minimum: if the graph value is higher than a threshold, its color will apply (highest gets precedence and the first color is used as the lowest color, regardless of its value)

Between 0 and 1.3333 we have #ff0000?

Correct!

What happens below 0?

Currently, the first threshold color is used; although we might want to expose the default color if no threshold was reached in the future (to improve multi-graph & allow for "red alert only" thresholds)

What happens above 4?

#0000ff is applied.

i.e.:

color_thresholds:
  - value: 0 # currently ignored
    color: "#ff0000"
  - value: 1.333333 # anything above 1.33333 
    color: "#ffff00"
  - value: 2.666667
    color: "#00ff00"
  - value: 4
    color: "#0000ff"
nschloe commented 1 year ago

If the the first "threshold" is ignored, then perhaps it shouldn't be there at all. That'd make it clearer that the thresholds are thresholds from below.

Lemonadel commented 11 months ago

/Hi, it looks like it’s broken or something for past few months? Or user is broken? :D

Env: HA on HAOS on RPi4 IMG_2172

Watched on iOS HA app iOS 16-17

My config (skipping value 0 does nothing)

Code:

- type: custom:mini-graph-card
   name: VOC last hour
   entities:
    - entity: sensor.airquality_drukarka_voc_index
      color_thresholds:
      - value: 0
        color: blue
      - value: 100
        color: blue #'#44739e'
      - value: 200
        color: orange
      - value: 300
        color: red
   hours_to_show: 1
   hour24: True
   points_per_hour: 60
   show:
      legend: True
      icon: False

Results:

IMG_2171

IMG_2173

ildar170975 commented 11 months ago

color_thresholds

This is a global property, not per entity. image

type: vertical-stack
cards:
  - type: entities
    entities:
      - input_number.number
  - type: custom:mini-graph-card
    entities:
      - entity: input_number.number
    color_thresholds_transition: hard
    color_thresholds:
      - value: 0
        color: blue
      - value: 30
        color: green
      - value: 50
        color: magenta
      - value: 80
        color: red
    hours_to_show: 0.08333
    points_per_hour: 600
    height: 200
    lower_bound: ~0
    show:
      points: false
      labels: true
Lemonadel commented 11 months ago

I don't know how I managed to write it per entity not global as you said and not found it for several months :D

Thank you so much, naturally works like a charm!

ildar170975 commented 7 months ago

Explanations were provided. Docs need to be updated: some clarifications to be added. PR: https://github.com/kalkih/mini-graph-card/pull/1058

ildar170975 commented 7 months ago

v.0.12