button-card icon indicating copy to clipboard operation
button-card copied to clipboard

Is it possible to access the card's icon through JavaScript templates?

Open adabelleleiram opened this issue 2 years ago • 1 comments

Is your feature request related to a problem? Please describe. I've created a template card where each implementation sets its own icon (instead of using the entity's default icon). I would like to reuse this icon in one of the custom_fields cards but don't seem to be able to access the icon's value through JavaScript. Maybe there's another way to do it? Preferably not by adding it to the variables object.

Describe the solution you'd like To be able to access the card's icon value in JavaScript e.g.

custom_fields:

sub_card:

card:

icon: "[[[ return icon; ]]]"

adabelleleiram avatar May 08 '22 18:05 adabelleleiram

This should work.

icon: '[[[ return this._config.icon; ]]]'

Garulf avatar Aug 03 '22 00:08 Garulf

I just want to say that this really solved a big problem i was having.. I was trying to embed the entity's icon into a custom field (button within a button sort of thing) and when i embedded a button card within a button card, it would pick up the default icon for the entity 'light' and not my custom one. Your statement solved my problem .. Thank you!!!

This card has two functions.. if you click anywhere other than the embedded button on the left, it will toggle the light on and off.. if you click the embedded button, it will bring up a popup which you can adjust brightness, change colour temp etc.

image

u8915055 avatar Nov 20 '22 00:11 u8915055

This should work.

icon: '[[[ return this._config.icon; ]]]'

Sorry for taking so long to reply but this solved it! Thanks a bunch!

adabelleleiram avatar Jan 07 '23 09:01 adabelleleiram