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.
223 stars 19 forks source link

the ">" and ">=" operator gets ignored #246

Closed tuupos closed 3 months ago

tuupos commented 7 months ago

So make sure your problem is not related to that!

Swiss Army Knife version

v2.5.1-dev.2

Bug description

When I use the the ">" and ">=" operator in my yaml it gets ignored beacuse it thinks it's part of scripting.

- state: '2000'
  operator: >
  styles:
    icon:
      animation: spin 3s linear infinite
      fill: var(--theme-sys-color-secondary)
      opacity: 0.9

e.g. like the > sign after the next fill.

 fill: >
 [[[ if (['home', 'not_home'].includes(state)) return 'var(--theme-sys-color-primary)';
                          return 'var(--theme-sys-color-tertiary)';

Expected behavior

The > sign should be seen as "greater than" and not as the beginning of a multiline code.

image

jwaz73 commented 6 months ago

@tuupos Just in case you have not found a solution to this yet...

I had to spend some time on the animation operators to understand their behavior. I found passing the operators as text corrected the strange results I was getting (enclose the operators in single quotes).

                    - state: 'P4'
                      operator: '!='
                      styles:
                        text:
                          fill: var(--theme-sys-palette-secondary85)

In the documentation for Supported Operators Marco does call out that all values should be passed as strings. The examples on the page do not show this for the operators but I tried it and achieved the results i was looking for.

Happy New Year!

-James

tuupos commented 6 months ago

Fantastic!!! I will try it out when i get home in about a week!!

Happy New Year to you too!

tuupos commented 3 months ago

It works! I hadn't had time for some months to test it !