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

Enable custom colors for all numeric values (also outside of 0-100 range) #599

Conversation

amsterjanis
Copy link

Since the component can be used for other entity types than just battery (and the readme even includes such examples) I think it makes sense to remove the restriction of 0-100 range for custom colours.

This will enable full functionality when using for negative temperatures, zigbee link quality, disk space etc.

@maxwroc maxwroc added the enhancement New feature or request label Nov 16, 2023
@maxwroc maxwroc merged commit 447fd45 into maxwroc:master Nov 16, 2023
1 check failed
@maxwroc
Copy link
Owner

maxwroc commented Nov 16, 2023

Thanks for contribution!

@maxwroc
Copy link
Owner

maxwroc commented Nov 16, 2023

Merged it too fast... now when looked at the full code:

I'll need to revert this change. Sorry

@maxwroc
Copy link
Owner

maxwroc commented Nov 16, 2023

BTW You can always overwrite the 0-100 value by using value_override. As it was done in the mentioned examples. Not the ideal solution but working

@maxwroc
Copy link
Owner

maxwroc commented Dec 31, 2023

Ok I have looked at this again and as I have mentioned we have two problems:

  • the first one can be fixed easily just by removing this condition and maybe later adjusting the threshold finding logic few lines below (if needed)
  • the second one with the gradient we can take the value range which user provided in steps and treat them as the maximum supported range, this way any incoming value can be converted to 0-100 based on such supported range e.g.
color:
  steps:
    - value: -3
      color: #ff0000
    - value: 0
      color: #ffff00
    - value: 7
      color: #00ff00
  gradient: true
  • -3 will be treated as 0
  • 0 as 30
  • 7 as 100

And this is what will be passed to the getGradientColors , so the gradient can be calculated properly

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

Successfully merging this pull request may close these issues.

2 participants