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

bug(color_thresholds): no longer appearing after introducing a `state_map`

Open Tamas-Toth-ebola opened this issue 2 years ago • 6 comments

Hi!

First of all I would like to throw a very big 'thanks' for your work(s) as this card is almost the only card type in my HA config and I really love it. So really lot of thanks for your efforts so far!

But from another aspect I got a soft problem/bug at my use cases.

Environment:

  • Home Assistant 2022.4.7 ('Core' through Docker)
  • Latest 0.11.0 'Mini Graph Card' (through HACS)

If we use state_maps we can not use color_thresholds with them (and I do not really see the reason of that), as the result is always the usage of the defined color in the thresholds object. Check the following sample.

The config:

type: custom:mini-graph-card
entities:
  - entity: sensor.u_s_air_pollution_level
    name: Air quality
font_size_header: 10
font_size: 66
hour24: true
height: 50
line_width: 1
hours_to_show: 168
align_state: center
show:
  labels: false
color_thresholds:
  - value: hazardous
    color: '#ff3d00'
  - value: very unhealthy
    color: '#ffff00'
  - value: unhealthy
    color: '#ffff00'
  - value: unhealthy for sensitive groups
    color: '#ffff00'
  - value: moderate
    color: '#ffff00'
  - value: good
    color: '#64dd17'
state_map:
  - value: hazardous
    label: Hazardous
  - value: very unhealthy
    label: Very unhealthy
  - value: unhealthy
    label: Unhealthy
  - value: unhealthy for sensitive groups
    label: Unhealthy for sensitive groups
  - value: moderate
    label: Moderate
  - value: good
    label: Good

And the result: image

Could anybody please help on it? Thanks for it in advance!

Tamas-Toth-ebola avatar Apr 28 '22 08:04 Tamas-Toth-ebola

Hey, could you try using the label value instead of the incoming value? It shouldn't do that though :)

jlsjonas avatar May 26 '22 23:05 jlsjonas

Hi, I can confirm the same, I also have the described problem. Is there any progress on this? @jlsjonas what do you mean to use label instead of incoming value? do you mean in the colour_thresholds using label instead of value? If so, I tried it and it throws an error...

badewanne1234 avatar Nov 16 '23 20:11 badewanne1234

Hey, I meant to use the label as value (f.e. Hazardous instead of hazardous) as we're not using the raw values.

For backwards compatibility, we'll have to support both when(/if) fixing this

jlsjonas avatar Nov 16 '23 21:11 jlsjonas

I tried to use the label value as well (however one must still indicate the label value as value: Hazardous instead of label: Hazardous - the color thresholds requires a value, if using label as an indicator, it throws an error. Regardless of the test, it did not work anyway unfortunately...

badewanne1234 avatar Nov 21 '23 21:11 badewanne1234