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

adaptive_color feature not working correctly with binary values

Open enselerizer opened this issue 1 year ago • 1 comments

Sorry in advance if this issue is a duplicate. I am using mini-graph-card to display state history of binary sensors. It works great, and even color_thresholds feature colors the graph correctly, as shown in an example below. However, name_adaptive_color and icon_adaptive_color features don't seem to work with binary values, always displaying a color that is mapped to zero value.

Here is an example:

type: custom:mini-graph-card
icon: mdi:door-closed
name: Office door state
hours_to_show: 24
points_per_hour: 10
update_interval: 1
animate: true
hour24: true
lower_bound: 0
upper_bound: 1
aggregate_func: max
line_width: 4
color_thresholds:
  - value: 0
    color: "#76FF03"
  - value: 0.6
    color: "#FF1744"
entities:
  - binary_sensor.access_control_module_v1e_office_door
state_map:
  - value: "off"
    label: " "
  - value: "on"
    label: " "
  - value: unavailable
    label: " "
show:
  fill: fade
  points: false
  labels: false
  name_adaptive_color: true
  icon_adaptive_color: true

Resulting card appearance: image

enselerizer avatar Oct 14 '24 16:10 enselerizer

I think, it is because we can (currently) only interpolate numeric values in the colour thresholds. We treat everything else as 0:

https://github.com/kalkih/mini-graph-card/blob/49ca1cd8627381e2981f57906014f615f08301c9/src/main.js#L644-L646

Maybe some logic could be borrowed from the Graph rendering here... But I couldn't find it yet...

akloeckner avatar Jan 13 '25 12:01 akloeckner