home-assistant / frontend

:lollipop: Frontend for Home Assistant
https://demo.home-assistant.io
Other
4.07k stars 2.79k forks source link

Gauge card scaling doesn't work for battery levels #3694

Closed sldewit closed 5 years ago

sldewit commented 5 years ago

Home Assistant release with the issue: 0.98.5

Last working Home Assistant release (if known):

UI (States or Lovelace UI?): Lovelace UI

Browser and Operating System: Chrome browser on Windows 10

Description of problem: The gauge card severity option assumes that the lowest is always the green. However for battery levels this is not the case. In this case the severity color cannot be used.

VDRainer commented 5 years ago

You just need to define the values for the severity.

type: gauge
name: With Severity
unit: '%'
entity: sensor.cpu_usage
severity:
  green: 90
  yellow: 45
  red: 0
sldewit commented 5 years ago

See below image what happens then:

image

When I define it "the other way arround":

image

So it seems that the logic is: If value <= green then green else if value <= yellow then yellow else if value <= red then red.

and what I need is: If value <= red then red else if value <= yellow then yellow else if value <= green then green.

For a value like CPU usage the implementation is correct since lowest value is green, high value is red. But for values like battery level it should be reversed. Op 12 september 2019 16:03:35 +02:00, schreef VDRainer notifications@github.com:

Edit: I just set it up as you said and it does seem to work. But it is weird configuration like this.

You just need to define the values for the severity. type: gauge name: With Severity unit: '%' entity: sensor.cpu_usage severity: green: 90 yellow: 45 red: 0

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/home-assistant/home-assistant-polymer/issues/3694?email_source=notifications&email_token=AM4HRDSMTUDST4XHWIFGLELQJJD3PA5CNFSM4IWCX3CKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD6R75UY#issuecomment-530841299, or mute the thread https://github.com/notifications/unsubscribe-auth/AM4HRDSOPIZJ5NZWPKIZHDTQJJD3PANCNFSM4IWCX3CA.

VDRainer commented 5 years ago

Read the docs

Value from which to start ...

So if you define

severity:
  green: 90
  yellow: 45
  red: 0

Values from 0 to 45 show red, from 45 to 90 show yellow and from 90 to 100 show green.

sldewit commented 5 years ago

Ok. I agree. Now that I read it again it is clear. Thanks.

ChasNelson1990 commented 4 years ago

Sorry, @VDRainer but this doesn't seem to work for me?

My card config is:

entity: sensor.coffecherry_tank
max: 100
name: Water Tank Level
type: gauge
unit: '%'
severity:
  green: 90
  yellow: 45
  red: 0
min: 0

But my gauge (which I have forced to be 20 % for testing) is uncoloured. (And if I swap green and red I get 'correct' colouring.)

Edit: Sorry, forgot to say this is Home Assistant 0.111.3 and I'm using Lovelace UI and a Firefox 77.0.1 instance on Arch Linux. Might be worth saying that I am a custom theme: https://github.com/home-assistant-community-themes/nord

VDRainer commented 4 years ago

Pretty sure it works with the default theme? Most dark themes don't use a redish color for label-badge-red. Create an extra theme for the gauges. Oh, and please don't post in closed issues.

ChasNelson1990 commented 4 years ago

You are correct, my apologies.

Sorry if posting on closed issues when the topic seems to be the same (admittedly it wasn't in the end!) isn't done in home-assistant repos, I couldn't find anything that said so - my bad.