iantrich / config-template-card

📝 Templatable Lovelace Configurations
MIT License
434 stars 56 forks source link

named vars? #46

Closed OmgImAlexis closed 3 years ago

OmgImAlexis commented 3 years ago

Is your feature request related to a problem? Please describe. I'd like to see named vars.

Describe the solution you'd like This is the example from the readme with the changes.

type: 'custom:config-template-card'
variables:
  bed_light: states['light.bed_light'].state
  garage_door: states['cover.garage_door'].state
entities:
  - light.bed_light
  - cover.garage_door
  - alarm_control_panel.alarm
  - climate.ecobee
card:
  type: "${vars.bed_light === 'on' ? 'glance' : 'entities'}"
  entities:
    - entity: alarm_control_panel.alarm
      name: "${vars.garage_door === 'open' && states['alarm_control_panel.alarm'].state === 'armed_home' ? 'Close the garage!' : ''}"
    - entity: binary_sensor.basement_floor_wet
    - entity: climate.ecobee
      name: "${states['climate.ecobee'].attributes.current_temperature > 22 ? 'Cozy' : 'Too Hot/Cold'}"
    - entity: cover.garage_door
    - entity: "${vars[0] === 'on' ? 'light.bed_light' : 'climate.ecobee'}"
      icon: "${vars.garage_door === 'open' ? 'mdi:hotel' : '' }"
iantrich commented 3 years ago

1.2.1