custom-cards / button-card

❇️ Lovelace button-card for home assistant
MIT License
1.97k stars 242 forks source link

A question about templates and variables. #746

Closed MicJour closed 1 year ago

MicJour commented 1 year ago

Is it possible to use a variable in the following code? Example to pass an icon into variables.

  custom_fields:
    temp: >
      [[[
        return `<ha-icon
          icon="mdi:thermometer"
          style="width: 12px; height: 12px; color: yellow;">
          </ha-icon><span>${entity.state}°C</span>`
      ]]]
MicJour commented 1 year ago

I found the answer myself.


    ent01: |
      [[[
        return `<ha-icon
          icon="${variables.var_ent01_icone}"
          </ha-icon>`
      ]]]