Mini-graph-card: State map labels being used for both axes

Created on 18 Feb 2020  路  3Comments  路  Source: kalkih/mini-graph-card

I'm not sure if this is happening because I'm doing something wrong or not understanding the intended behaviour. But, when I define a state_map in my graph, I'm seeing mini-graph-card attempt to map both primary and secondary y axes using this map. This leads to a visual bug in how the axes are labelled, and a bunch of warnings thrown in the console.

I'm attempting to graph two sensors. The first is a standard binary sensor, and the second a number between 0-4 inclusive (For context, this is for a smart bassinet. One sensor shows whether the bassinet is on, the second the level of "soothing" it is using). I've configured the card like this:

type: 'custom:mini-graph-card'
name: Snoo state
entities:
  - entity: binary_sensor.snoo_asleep
    name: Asleep
    aggregate_func: min
    color: grey
    show_state: true
    show_line: false
    show_points: false
  - entity: sensor.snoo_soothe_level
    name: Soothe level
    show_legend: true
    y_axis: secondary
    aggregate_func: max
lower_bound_secondary: 0
upper_bound_secondary: 4
hours_to_show: 12
points_per_hour: 60
smoothing: false
color_thresholds:
  - color: '#0000ff'
    value: 0
  - color: '#6600cc'
    value: 1
  - color: '#00ff00'
    value: 2
  - color: '#ffff00'
    value: 3
  - color: '#ff0000'
    value: 4
state_map:
  - value: 'off'
    label: Awake
  - value: 'on'
    label: Asleep

What I'm seeing is that values on the secondary Y axis are also being mapped according to the state_map. This can be seen in the Y axis labels, as well as when a point on the graph is selected:
Screen Shot 2020-02-18 at 9 49 13 pm

The labels on the secondary Y axes are marked "Asleep" and "4" when they should be "0" and "4". Additionally, mousing over a 1 point indicates that the Level at that time is "Awake" when it should be "1".

This can also be seen with the card logging warnings in the console. When points on the graph higher than 1 are moused over, the card logs this:

mini-graph-card:  value [3] not found in state_map mini-graph-card-bundle.js:1:66925
mini-graph-card:  value [4] not found in state_map 2 mini-graph-card-bundle.js:1:66925
mini-graph-card:  value [2] not found in state_map mini-graph-card-bundle.js:1:66925

I think what I'm expecting here is for the card to not look up numeric values in the state map. But, more broadly, would it also be worthwhile making state maps axis-specific?

enhancement

Most helpful comment

Hello,
Yes this is indeed an issue, I'm leaning towards making it axis specific, started working on just this a few weeks ago: https://github.com/kalkih/mini-graph-card/commit/822d3f529ab76ba58c72916dc3a0041dda8f2a14.

All 3 comments

Hello,
Yes this is indeed an issue, I'm leaning towards making it axis specific, started working on just this a few weeks ago: https://github.com/kalkih/mini-graph-card/commit/822d3f529ab76ba58c72916dc3a0041dda8f2a14.

Really not want to be pushing something, but whats holding this up?
The work done in the branch looks good to me?

I have the exact same issue here any updates when this is going to be merged?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

NapalmCandy picture NapalmCandy  路  4Comments

clydefrog76 picture clydefrog76  路  6Comments

skarfacegc picture skarfacegc  路  7Comments

simonwood0609 picture simonwood0609  路  7Comments

QkulleQ picture QkulleQ  路  7Comments