#Change entity ID with input_text

1 messages · Page 1 of 1 (latest)

outer birch
#
- type: custom:button-card
    template:
      - circle
      - light
    entity: |
      [[[
        const controlValue = states['input_text.room_select'].state;
        switch (controlValue) {
          case 'Reception': return 'switch.reception_on';
          case 'Kitchen': return 'switch.kitchen_on';
          default: return 'switch.bathroom_on';
        }
      ]]]
    name: Fan Light
    icon: mdi:lightbulb
    size: 75%
    show_state: true
    aspect_ratio: 1/1

I am trying to change the entity_id based on the name like I'm doing page navigation. However, it won't actually refresh and will only refresh if I leave and enter the dashboard again. Does anyone know of a way to update an entity while it still exists?

calm yoke
#

I could be mistaken but I want to say that the entity: field is the only one that will not accept a template. You could work around that by not defining an entity, but then template each of the other appropriate fields (like the state to handle icon and coloring and then the actions.) You could even define it at the variable: level and just reference the variable rather than evaluating the whole template at each field.