AmoebeLabs / swiss-army-knife-card

The versatile custom Swiss Army Knife card for Home Assistant allows you to create your unique visualization using several graphical tools, styling options and animations.
224 stars 19 forks source link

Icon (ok) and segmented arc (nok) not showing the same color at exact colorstop limits #191

Open AmoebeLabs opened 1 year ago

AmoebeLabs commented 1 year ago

Bug report notice

Before you file a bug, make sure that you did not make a configuration mistake. The Swiss Army Knife in its current state does not yet have full configuration sanity checks!

So make sure your problem is not related to that!

Bug description

A clear and concise description of what the bug is.

The colorstop limits are nog always consistent between segmented arc and animations. The segmented arc stays green when percentage changes to 40% (why??), but after a browser refresh it becomes yellow. The battery percentage icon however stays green at 40%.

Both are using the same colorstop template. So this seems some calculation is going wrong to determine the current color in the segarc rendering after a refresh. Might be something about > or >= or < and <=.

Battery percentage at 40%: image

And battery percentage at 39%: image

image

To Reproduce

Steps to reproduce the behavior:

  1. Go to '...'
  2. Click on '....'
  3. Scroll down to '....'
  4. See error

YAML definition of view part:

          layout:
            template:
              name: sak_layout_fce_sensor2
              variables:
                - sak_layout_sensor_colorstops_template: colorstops_battery_level
                - sak_layout_sensor_icon_style: colorstops
                - sak_layout_sensor_segarc_style: colorstops
                - sak_layout_sensor_scale_max: 100    

The colorstops_battery_level template looks like this:

colorstops_battery_level:
  template:
    type: colorstops
    defaults:
      - thegap: 1
      - theFill: true
      - theStroke: false
  colorstops:
    gap: '[[thegap]]'
    fill: '[[theFill]]'
    stroke: '[[theStroke]]'
    colors:
      00: 'var(--brand-google-red)'
      20: 'var(--brand-google-yellow)'
      40: 'var(--brand-google-green)'

Expected behavior

A clear and concise description of what you expected to happen.

Both the icon as the segarc are using the same (of course) colorstop template, so should show the same colors. Even after a refresh!

Screenshots

If applicable, add screenshots to help explain your problem.

Desktop browser (please complete the following information):

Companion App on Smartphone/Tablet (please complete the following information):

Additional context Add any other context about the problem here.

(Optional): Suggested Solution

Any suggested solution to this bug.