Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FR] Support numerical range values for state_map #1097

Open
DeFlanko opened this issue Apr 30, 2024 · 5 comments
Open

[FR] Support numerical range values for state_map #1097

DeFlanko opened this issue Apr 30, 2024 · 5 comments
Labels
feature request New feature or request

Comments

@DeFlanko
Copy link

DeFlanko commented Apr 30, 2024

Looking to utilize the State_map function for heart rates:

type: custom:mini-graph-card
labels: true
name_adaptive_color: true
lower_bound: 50
color_thresholds:
  - value: 180
    color: '#9A56A3'
    name: High Performance Zone
  - value: 155
    color: '#3B9555'
    name: Performance Zone
  - value: 135
    color: '#EA9423'
    name: Fitness Zone
  - value: 110
    color: '#FEEB3F'
    name: Health Improvement Zone
  - value: 90
    color: '#8CABD7'
    name: Inactive
state_map:
  - value: 180
    color: '#9A56A3'
    label: High Performance Zone
  - value: 155
    color: '#3B9555'
    label: Performance Zone
  - value: 135
    color: '#EA9423'
    label: Fitness Zone
  - value: 110
    color: '#FEEB3F'
    label: Health Improvement Zone
  - value: 90
    color: '#8CABD7'
    label: Inactive
height: 50
hours_to_show: 4
points_per_hour: 12
line_width: 3
animate: true
show:
  name_adaptive_color: true
  icon_adaptive_color: true
  labels: true
entities:
  - entity: sensor.google_pixel_watch_jd_heart_rate_2
name: Heart Rate

currently it wont show what heart zone the sensor is in. Would be nice to see that next to the bpm
image

@DeFlanko DeFlanko changed the title Enhancement - Show state for numerical range values Enhancement - Show state for numerical range values for Heart Rate Zones Apr 30, 2024
@ildar170975
Copy link
Collaborator

ildar170975 commented May 1, 2024

Suggest to re-read Docs & check your code.
Just a 1st glance:

type: custom:mini-graph-card
labels: true

Here the labels is misplaced.

color_thresholds:
  - value: 180
    color: '#9A56A3'
    name: High Performance Zone

The color_thresholds does not have name option.

state_map:
  - value: 180
    color: '#9A56A3'
    label: High Performance Zone

The state_map does not have color option.

Also, state_map does not work for ranges, it works for exact values.

@ildar170975 ildar170975 added the question Further information is requested label May 1, 2024
@DeFlanko
Copy link
Author

DeFlanko commented May 1, 2024

which is why i asked it to be an enhancement request, i completely understand how the state_map is only for single digit non ranged values, but i'm looking to have it look to ranged values so that anything in between the two heart ranges can named that state_mapped value.

Corrected all the code logic btw, still works - but again asking for the state_mapped value to be a range.

type: custom:mini-graph-card
name_adaptive_color: true
lower_bound: 50
color_thresholds:
  - value: 180
    color: '#9A56A3'
  - value: 155
    color: '#3B9555'
  - value: 135
    color: '#EA9423'
  - value: 110
    color: '#FEEB3F'
  - value: 90
    color: '#8CABD7'
state_map:
  - value: 180
    label: High Performance Zone
  - value: 155
    label: Performance Zone
  - value: 135
    label: Fitness Zone
  - value: 110
    label: Health Improvement Zone
  - value: 90
    label: Inactive
height: 50
hours_to_show: 4
points_per_hour: 12
line_width: 3
animate: true
show:
  name_adaptive_color: true
  icon_adaptive_color: true
  labels: true
entities:
  - entity: sensor.google_pixel_watch_jd_heart_rate_2
name: Heart Rate

@ildar170975
Copy link
Collaborator

I see, then the issue title is currently not clear.

@ildar170975 ildar170975 changed the title Enhancement - Show state for numerical range values for Heart Rate Zones [FR] Support numerical range values for state_map May 1, 2024
@ildar170975 ildar170975 added feature request New feature or request and removed question Further information is requested labels May 1, 2024
@DeFlanko
Copy link
Author

DeFlanko commented May 1, 2024 via email

@ildar170975
Copy link
Collaborator

ildar170975 commented May 1, 2024

As a workaround:

  1. Create a template sensor with desired values like "low", "average", "high".
  2. Add this sensor on a card as the 2nd entity with showing a state but w/o showing a graph.

Alternatively - do NOT create a sensor but simply change a card's background color accordingly to show a current status (card-mod using jinja templates).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants