kalkih / mini-graph-card

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

Help with thresholds #964

Closed fridrichovsky closed 6 months ago

fridrichovsky commented 1 year ago

Hello, first of all I would like to say that mini graph card is really great card. I am new with HA so I would like ask you if I do something wrong.

What I want is that I will see graph blue for temperature bellow -10, light blue for bellow zero, orange over zero and red over 28.

I set this:

        color_thresholds_transition: hard
        color_thresholds:
          - color: blue
            value: -50
          - color: '#039BE5'
            value: -10
          - color: var(--accent-color)
            value: 0
          - color: '#E74C3C'
            value: 28

Problem is that I do not see expected graph with correct color, but I se black graph.

obrazek

What I have is that my temperature sensor have samples from 1,5C to 18C. It means that my database do not have temperatures bellow zero and over 28C. I did some test. TEST 1. When I set thresholds in "samples" range it works same way as I expected. But with wrong thresholds for me.

        color_thresholds_transition: hard
        color_thresholds:
          - color: blue
            value: 2
          - color: '#039BE5'
            value: 5
          - color: var(--accent-color)
            value: 7
          - color: '#E74C3C'
            value: 10

obrazek

TEST 2. Last threshold over then existing data set highest part to black color, same behavior is for lowest threshold:

        color_thresholds_transition: hard
        color_thresholds:
          - color: blue
            value: 2
          - color: '#039BE5'
            value: 5
          - color: var(--accent-color)
            value: 7
          - color: '#E74C3C'
            value: 28

obrazek

TEST 3. Required thresholds with lower and upper bound works, but it create small graph:

        upper_bound: ~50
        lower_bound: ~-50
        color_thresholds_transition: hard
        color_thresholds:
          - color: blue
            value: -50
          - color: '#039BE5'
            value: -10
          - color: var(--accent-color)
            value: 0
          - color: '#E74C3C'
            value: 28

obrazek

TEST 4: If I change upper_bound lower then highest threshold graph is changed to black

TEST 5: If I set working thresholds and I wait few days. I get new values (for last monitored 48h) that are not in "correct" range. Minigraph is again black.

I would like to use threshold for see temperature ranges. It does not mean that I will see all colors it should be depended on values from last 48 hours (set in hours_to_show).

Thank you for your advices and help

ildar170975 commented 6 months ago
  1. Please post screenshots made in a default light theme. Sorry, I see nothing.
  2. I guess it is rather difficult to see something in a small narrow area. So, retest with a full width card with at least height: 200 defined.
  3. Also, not many people are able to say what "E74C3C" is. So, test either with human-friendly "green/red/..." or easily recognizable "#ff0000 / #00ff00 / #0000ff".
fridrichovsky commented 6 months ago

Add 1. and 2. I changed colors and heigh and mark problem parts.

obrazek

Add 3. It is standard for colors and how to set so customer color. But for you I changed setup

type: custom:mini-graph-card
height: 200
entities:
  - entity: sensor.pokoj_teplomer_humidity
    name: Aktuální vlhkost
    show_legend: false
    smoothing: false
    extrema: true
name: Vlhkost
points_per_hour: 2
color_thresholds_transition: hard
color_thresholds:
  - color: red
    value: 0
  - color: yellow
    value: 40
  - color: green
    value: 45
  - color: blue
    value: 55
  - color: red
    value: 60
ildar170975 commented 6 months ago

Good!

Now retest with:

  1. Replace "green" etc with simple easy recognizable hex colors like "#00ff00".
  2. Show labels = true.
  3. "lower_bound = 0".

And one more test:

  1. Use "green" etc colors (do not replace with HEX).
  2. Show labels = true.
  3. "lower_bound = 0".

And one more test:

  1. Use HEX colors.
  2. Show labels = true.
  3. Do not add "lower_bound".

And 2 more cases - case 1 & case 2 - with "lower_bound=1".


Unrelated:

    extrema: true

this option is misplaced.

fridrichovsky commented 6 months ago

What works is HEX colors. I can not use 'green' or var(--accent-color). When I replaced these values by HEX it helped. It is strange because graph know color and show it but it do black parts.

obrazek

I didn't try set bounds because it works I mentioned in my tests.

Thank you it looks that HEX solved my problem.

ildar170975 commented 6 months ago

Now check this issue: https://github.com/kalkih/mini-graph-card/issues/807 and confirm that you observed the same. If so - I will close this issue as a duplicate, we may continue discussing in that issue then.

fridrichovsky commented 6 months ago

Yes it looks like it is same. I though that problem is connected with scale. Because black color replaced sometimes whole line sometimes some parts. I could not imagine that problem is only with HEX color settings.

ildar170975 commented 6 months ago

Then let's continue our discussion there. https://github.com/kalkih/mini-graph-card/issues/807