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

2.4.5 somehow added .hidden class to usersvg. #224

Closed stinobook closed 1 year ago

stinobook commented 1 year ago

Bug description

Since the 2.4.5 update i have one card where the usersvg somehow gets the .hidden class. Nothing of the code has been changed since 2.4.4.

To Reproduce

Card code:


              - type: 'custom:swiss-army-knife-card'
                aspectratio: 1/1
                entities:
                  - entity: input_select.person_status_maddie
                  - entity: input_text.person_status_maddie
                layout:
                  styles:
                    card:
                      overflow: visible
                      background: transparent
                      border: none
                      box-shadow: none
                  toolsets:
                    - toolset: card
                      position:
                       cx: 50
                       cy: 50
                      tools:
                        - type: usersvg
                          position:
                            cx: 50
                            cy: 50
                            height: 100
                            width: 100
                          style: 'images'
                          images:
                            - default: /a....
                          clip_path:
                            position:
                              cx: 50
                              cy: 50
                              height: 100
                              width: 100
                              radius:
                                all: 5

Screenshots

image

Same card/code on 2.4.4 version: image

stinobook commented 1 year ago

PS: not all usersvg, only those 2 for some reason.. all others work fine.

AmoebeLabs commented 1 year ago

Weird stuff.

These two are not injected, hence should not be hidden.

What type of images are these? Png, jpg, svg?

stinobook commented 1 year ago

no idea, its the profile picture of the users from HA itself. they dont have an extension.

AmoebeLabs commented 1 year ago

no idea, its the profile picture of the users from HA itself. they dont have an extension.

Ok. Then I know how this can be fixed.

You can try to disable injection by setting

  entities:
  options:
    svginjection: false

and see if that already helps.

stinobook commented 1 year ago

image class hidden is still applied i also tried to set classes: hidden: false

but that didnt work either.

AmoebeLabs commented 1 year ago

image class hidden is still applied i also tried to set classes: hidden: false

but that didnt work either.

You did refresh the yaml files and/or clear caches?

The hidden class is only added if svginjection is set to true. So that should not happen if set to false.

stinobook commented 1 year ago

i still have the disable cache option enabled you told me about last time. image and of course reloaded the page/browser.

AmoebeLabs commented 1 year ago

i still have the disable cache option enabled you told me about last time. image and of course reloaded the page/browser.

Ok. Sometimes Lovelace does not see changes in sub-files, and HA does not reload the views as a result. I still need to change the main dashboard file for a reload to occur. In that case HA shows a message saying that it is changed, and need to reload the view.

Change some text for the view to make sure the latest config is loaded…

stinobook commented 1 year ago

image image

still the same.

AmoebeLabs commented 1 year ago

Ok. I will change the logic.

The api as image is not a real image, it returns an image. The svg injector tries to treat this as an svg. Fails but did already set the hidden class. I will change some checks to prevent this from happening (I hope 😄 )

AmoebeLabs commented 1 year ago

I can replicate the problem:

image

The HA API returns an image/jpeg. So at least I know that now 😄

Besides the fact that this image is treated as an SVG (which it isn't), the additional uncaught error, causes the hidden class NOT to be removed.

However, If I catch the error, and set options.svginjection : false in the handler, and fire the renderer once again, the api picture is displayed (Ricky). The person cards from 1 to 3 have:

image

I keep this at least as a fallback: if an SVG can't be injected, it is displayed as an external image. If that fails too, well, then I'm out of options and the user specified an illegal image that can't be displayed by an image object.