thomasloven / lovelace-state-switch

🔹Dynamically replace lovelace cards depending on occasion
MIT License
382 stars 27 forks source link

FR: templating in states based on entity #19

Closed Mariusthvdb closed 2 years ago

Mariusthvdb commented 4 years ago

currently I use:

  - type: custom:state-switch
    default: ''
    entity: sensor.alerts_counter
    states:
      '1':
        !include /config/lovelace/buttons/buttons_alerts_1.yaml
      '2':
        !include /config/lovelace/buttons/buttons_alerts_2.yaml
      '3':
        !include /config/lovelace/buttons/buttons_alerts_3.yaml
      '4':
        !include /config/lovelace/buttons/buttons_alerts_4.yaml

would you consider adding a template functionality, so we can do like:

  - type: custom:state-switch
    default: ''
    entity: sensor.alerts_counter
    states:
        !include /config/lovelace/buttons/buttons_alerts_{{entity.state}}.yaml

thanks for considering!

thomasloven commented 2 years ago

That's not how yaml works.

!include is processed by the backend, before state-switch can know anything about it.