kalkih / mini-graph-card

Minimalistic graph card for Home Assistant Lovelace UI
MIT License
2.89k stars 233 forks source link

Line color doesn't change according to the thresholds. #950

Closed CosminFRC closed 1 year ago

CosminFRC commented 1 year ago

Hi,

I have a graph card for a humidity sensor but I can't make it work as it should. The line gets the last treshold color and it doesn't change color when the state changes, although the state color changes according to the tresholds. So, the state color is working great but the line color doesn't. Maybe I messed up something in the yaml config. but I really don't know.

type: custom:mini-graph-card
line_width: 8
font_size: 200
height: 55
hour24: true
entities:
  - entity: sensor.termostat_camera_ami_humidity
    state_adaptive_color: true
    unit: '%'
show:
  labels: false
  extrema: false
  state: true
  name: true
  icon: true
  name_adaptive_color: false
  icon_adaptive_color: false
color_thresholds:
  - value: 0
    color: '#b9fdff'
  - value: 30
    color: '#9da6e5'
  - value: 60
    color: '#f288ff'
name: Umiditate
hours_to_show: '24'
group_by: hourly
ildar170975 commented 1 year ago

Probably there are issues with color_thresholds. But check this, seems to work fine:

type: vertical-stack
cards:
  - type: entities
    entities:
      - input_number.number
  - type: custom:mini-graph-card
    entities:
      - entity: input_number.number
        state_adaptive_color: true
    color_thresholds:
      - value: 0
        color: red
      - value: 100
        color: green
      - value: 200
        color: blue
    hours_to_show: 0.083333
    points_per_hour: 3600
    smoothing: false
    color_thresholds_transition: hard
    line_width: 1
    lower_bound: 0

image

Suggestions: 1.Next time when you post a code - do not post a code with options which are not relevant to a problem (like group_by etc). Use options which HELP to localize an issue - like "normal" colors (hex values are not as clear as "red" or "green"). 2.Check other open issues here, there are already present issues for the same (or similar) problem, no need to register one more.

CosminFRC commented 1 year ago

I copied your code and modified what needed to be modified and apparently it works. I will also take into account your suggestions. Thank you.

ildar170975 commented 1 year ago

I myself decided NOT to use color_thresholds because they MAY NOT work properly... Depends on many factors, unfortunately.

And please make a decision - either CLOSE the issue as solved or add necessary explanations what exactly was wrong and if you can reproduce it.

CosminFRC commented 1 year ago

Apparently it was working but in fact it is not. The line is colored with the color from the first threshold value and then the color does not change when the threshold is exceeded.

ildar170975 commented 1 year ago

Are you talking now about "my code + added your options"? Post:

CosminFRC commented 1 year ago

Yes, your code with my options. Here are some printscreens at different sensor values and no line color change.

Screenshot_20230414_001837_Home Assistant Screenshot_20230414_001824_Home Assistant Screenshot_20230414_001810_Home Assistant Screenshot_20230414_001543_Home Assistant

ildar170975 commented 1 year ago

Test with: points_per_hour - 2x bigger than the actual update frequency smoothing: false color_thresholds_transition: hard

Check if it changes anything.

CosminFRC commented 1 year ago

I modified what you told me and it seems to work now. I'll test it for a few hours and if everything works correctly I'll close the problem as "Solved". Thank you.