State map labels being used for both axes
See original GitHub issueI’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:
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?
Issue Analytics
- State:
- Created 4 years ago
- Reactions:2
- Comments:9 (1 by maintainers)
Top GitHub 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.
State maps is one of the global items that should be made entity specific so this should be resolved in the 0.12 release (the one after this month’s release)