Open klonwar opened 3 weeks ago
Retest with this config:
type: custom:mini-graph-card
entities:
- entity: ...
show_state: true
show_fill: true
state_adaptive_color: true
color_thresholds: ....
color_thresholds_transition: hard
hours_to_show: 24
points_per_hour: 60
line_width: 1
show:
labels: true
icon_adaptive_color: true
height: 300
It works OK in my setup:
That is the point! It works fine when setting entity like you did! All other graphs working fine.
But if I try to use attribute
like:
...
entities:
- entity: weather.openmeteo
attribute: temperature
show:
icon_adaptive_color: true
It just stops showing color on the icon
I see, there is a problem with attribute. Thanks for reporting. Will take a look.
For you - a suggestion: when you will post a code next time for issues: -- always post a short minimal code: no card-mod, no possibly unrelated options -start from a simple case, increase a complexity step by step; -- for testing thresholds - use SIMPLE clear colors like "red", "#ff0000" (nobody will decode smth like "ae54f3"); and "hard" transition.
@akloeckner Can you have a look if it is related somehow to the recent changes?
type: vertical-stack
cards:
- type: custom:mini-graph-card
entities:
- entity: sensor.xiaomi_cg_1_co2
<<: &ref_settings
color_thresholds:
- value: 450
color: red
- value: 500
color: orange
- value: 510
color: yellow
- value: 520
color: green
- value: 530
color: cyan
- value: 540
color: blue
- value: 550
color: lightgreen
- value: 560
color: magenta
color_thresholds_transition: hard
hours_to_show: 0.25
points_per_hour: 240
aggregate_func: last
show:
labels: true
points: true
icon_adaptive_color: true
height: 300
- type: custom:mini-graph-card
entities:
- entity: sensor.xiaomi_cg_1
attribute: co2
<<: *ref_settings
In case of using attribute
- color is taken for the 1st threshold.
Thank you for your suggestions!
In case of using attribute - color is taken for the 1st threshold.
yep, same for me
And if I add in your config another threshold with value is less or equal 0, the issue I've described reproduces!
color_thresholds:
- value: 0
color: purple
- value: 10
color: red
Result:
(And in icon's html: style="color: #;"
)
And if we set value to 1
color_thresholds:
- value: 1
color: purple
- value: 10
color: red
Result:
And if I add in your config another threshold with value is less or equal 0, the issue I've described reproduces!
I am not following, which particular my config do you mean? Post a full (but still minimized) code.
Ok, here
type: vertical-stack
cards:
- type: custom:mini-graph-card
entities:
- entity: sensor.xiaomi_cg_1_co2
<<: &ref_settings
color_thresholds:
- value: 0
color: purple
- value: 450
color: red
- value: 500
color: orange
- value: 510
color: yellow
- value: 520
color: green
- value: 530
color: cyan
- value: 540
color: blue
- value: 550
color: lightgreen
- value: 560
color: magenta
color_thresholds_transition: hard
hours_to_show: 0.25
points_per_hour: 240
aggregate_func: last
show:
labels: true
points: true
icon_adaptive_color: true
height: 300
- type: custom:mini-graph-card
entities:
- entity: sensor.xiaomi_cg_1
attribute: co2
<<: *ref_settings
With this config It'll set style="color: #;"
for the icon
With added "purple":
And in Code Inspector it is "rgb(128,0,128)" (which I believe could be a "purple"):
Interesting! I'm using last version I believe (v0.12.1) and with first threshold value <= 0 it sets this
And if you set -1 as a value?
But maybe we should concentrate on that attribute-first-threshold problem. Just thought that these two may be related
But maybe we should concentrate on that attribute-first-threshold problem
Agreed. But anyway show me YOUR code which causes "color: #"
And I am using Guess this may explain a difference.
My code is
type: vertical-stack
cards:
- type: custom:mini-graph-card
entities:
- entity: sensor.aqs_temperature_1
<<: &ref_settings
color_thresholds:
- value: -1
color: purple
- value: 10
color: red
- value: 15
color: orange
- value: 20
color: yellow
- value: 25
color: green
- value: 30
color: cyan
- value: 35
color: blue
- value: 40
color: lightgreen
- value: 45
color: magenta
color_thresholds_transition: hard
hours_to_show: 0.25
points_per_hour: 240
aggregate_func: last
show:
labels: true
points: true
icon_adaptive_color: true
height: 300
- type: custom:mini-graph-card
entities:
- entity: weather.openmeteo
attribute: temperature
<<: *ref_settings
I just adapted yours for my sensors (changed entities and thresholds values)
Recheck with 0.12.2-dev.2
Yep, in dev.2 it sets color in rgb
format instead of hex, and it's purple, so the first threshold is used
I think, the icon (and also the name) do not use attribute for calculating their colours, see here:
And here
Does the colour become correct, when you hover over a point?
Does the colour become correct, when you hover over a point?
yep, it does
:+1: I cannot promise anything right now. But that should be solvable...
Could you check out #1131, please? It seems to work on my end, but I did not thoroughly test it.
@akloeckner
Could you check out #1131
Tested with that js and still an icon uses the 1st color:
type: vertical-stack
cards:
- type: custom:mini-graph-card
entities:
- entity: sensor.xiaomi_cg_1_co2
<<: &ref_settings
color_thresholds:
- value: 500
color: red
- value: 570
color: cyan
- value: 610
color: yellow
- value: 700
color: green
color_thresholds_transition: hard
hours_to_show: 6
points_per_hour: 240
aggregate_func: last
show:
labels: true
points: true
icon_adaptive_color: true
height: 300
- type: custom:mini-graph-card
entities:
- entity: sensor.xiaomi_cg_1
attribute: co2
<<: *ref_settings
Hmm... Did you change the URL (HA side caching) and reload the page (browser side caching)? If yes, is it also wrong with soft transition?
What I usually do is:
I believe, HA has a caching mechanism, which will result in the server not serving the changed file to the client, if the URL is unchanged. That's why I always change the resource URL before your step 4. (Edit dashboard -> manage resources -> add some arbitrary digits to the URL: /hacsfiles/mini-graph-card/mini-graph-card-bundle.js?hacstag=1512800620121blabla
) But maybe that is not necessary anymore. 🤔
@akloeckner I have no idea where I messed up - but right now I made one more attempt - repeated SAME actions listed here (except deleting gz-file - it was already deleted) - and here it is (separate sensor on the top, an attribute on the bottom):
Let's release it )))).
Alright. :+1:
I have a graph for openmeteo weather:
And it's colors are correct except for the icon.