Change button entity based on state of another entity - Solved

TL;DR: What would be the best way to change an entity of a button based on the state of another entity?

I am automating my theater setup and integrating Harmony activities. When you visit the main control panel for the theater you are greeted with 2 buttons to select either “TV” or “Projector”. These buttons control an input_select

input_select:
  theater_media_mode:
    name: Media Mode
    options:
      - "None"
      - "TV"
      - "Projector"
    initial: None
    icon: mdi:target

Once a media mode is selected I have a conditional entity that displays a card with the source choices.

type: vertical-stack
cards:
  - type: 'custom:button-card'
    color_type: label-card
    color: 'rgb(44, 109, 214)'
    name: TV
  - type: horizontal-stack
    cards:
      - type: 'custom:button-card'
        entity: switch.tv_appletv
        color_type: card
        show_entity_picture: 'true'
        entity_picture: /local/Apple-TV.svg
        state:
          - value: 'on'
            color: 'rgb(20, 120, 220)'
        show_state: false
        show_name: false
      - type: 'custom:button-card'
        entity: switch.tv_shield
        color_type: card
        show_entity_picture: 'true'
        entity_picture: /local/Nvidia-01.svg
        state:
          - value: 'on'
            color: 'rgb(20, 120, 220)'
        show_state: false
        show_name: false
- type: 'custom:button-card'
        entity: switch.tv_raspberrypi
        color_type: card
        show_entity_picture: 'true'
        entity_picture: /local/Raspberry-PI-01.svg
        state:
          - value: 'on'
            color: 'rgb(20, 120, 220)'
        show_state: false
        show_name: false

Since you will be able to select the same sources for either TV or Projector, what would be the best way to make the entity dynamic?

If entity: input_select.theater_media_mode = projector

the button would be:

- type: 'custom:button-card'
        entity: switch.prj_raspberrypi
        color_type: card
        show_entity_picture: 'true'
        entity_picture: /local/Raspberry-PI-01.svg
        state:
          - value: 'on'
            color: 'rgb(20, 120, 220)'
        show_state: false
        show_name: false

If entity: input_select.theater_media_mode = tv

the button would be:

- type: 'custom:button-card'
        entity: switch.tv_raspberrypi
        color_type: card
        show_entity_picture: 'true'
        entity_picture: /local/Raspberry-PI-01.svg
        state:
          - value: 'on'
            color: 'rgb(20, 120, 220)'
        show_state: false
        show_name: false

The simple option is to make two conditional cards with the different buttons. One card visible for each input select state.

The other option is to template the entity using this custom card:

This does seem to be the simplest solution. I was able to keep all of the configuration close together.

Here is the working card:

type: conditional
conditions:
  - entity: input_select.theater_media_mode
    state_not: None
card:
  type: vertical-stack
  cards:
    - type: horizontal-stack
      cards:
        - type: conditional
          conditions:
            - entity: input_select.theater_media_mode
              state: TV
          card:
            type: 'custom:button-card'
            entity: switch.tv_appletv
            color_type: card
            show_entity_picture: 'true'
            entity_picture: /local/Apple-TV.svg
            state:
              - value: 'on'
                color: 'rgb(20, 120, 220)'
            show_state: false
            show_name: true
        - type: conditional
          conditions:
            - entity: input_select.theater_media_mode
              state: Projector
          card:
            type: 'custom:button-card'
            entity: switch.prj_appletv
            color_type: card
            show_entity_picture: 'true'
            entity_picture: /local/Apple-TV.svg
            state:
              - value: 'on'
                color: 'rgb(20, 120, 220)'
            show_state: false
            show_name: true
        - type: conditional
          conditions:
            - entity: input_select.theater_media_mode
              state: TV
          card:
            type: 'custom:button-card'
            entity: switch.tv_shield
            color_type: card
            show_entity_picture: 'true'
            entity_picture: /local/Nvidia-01.svg
            state:
              - value: 'on'
                color: 'rgb(20, 120, 220)'
            show_state: false
            show_name: true
        - type: conditional
          conditions:
            - entity: input_select.theater_media_mode
              state: Projector
          card:
            type: 'custom:button-card'
            entity: switch.prj_shield
            color_type: card
            show_entity_picture: 'true'
            entity_picture: /local/Nvidia-01.svg
            state:
              - value: 'on'
                color: 'rgb(20, 120, 220)'
            show_state: false
            show_name: true
        - type: conditional
          conditions:
            - entity: input_select.theater_media_mode
              state: TV
          card:
            type: 'custom:button-card'
            entity: switch.tv_raspberrypi
            color_type: card
            show_entity_picture: 'true'
            entity_picture: /local/Raspberry-PI-01.svg
            state:
              - value: 'on'
                color: 'rgb(20, 120, 220)'
            show_state: false
            show_name: true
        - type: conditional
          conditions:
            - entity: input_select.theater_media_mode
              state: Projector
          card:
            type: 'custom:button-card'
            entity: switch.prj_raspberrypi
            color_type: card
            show_entity_picture: 'true'
            entity_picture: /local/Raspberry-PI-01.svg
            state:
              - value: 'on'
                color: 'rgb(20, 120, 220)'
            show_state: false
            show_name: true
    - type: horizontal-stack
      cards:
        - type: conditional
          conditions:
            - entity: input_select.theater_media_mode
              state: TV
          card:
            type: 'custom:button-card'
            entity: switch.tv_wallhdmi
            color_type: card
            show_entity_picture: 'true'
            entity_picture: /local/Settings-input-hdmi-01.svg
            state:
              - value: 'on'
                color: 'rgb(20, 120, 220)'
            show_state: false
            show_name: true
        - type: conditional
          conditions:
            - entity: input_select.theater_media_mode
              state: Projector
          card:
            type: 'custom:button-card'
            entity: switch.prj_wallhdmi
            color_type: card
            show_entity_picture: 'true'
            entity_picture: /local/Settings-input-hdmi-01.svg
            state:
              - value: 'on'
                color: 'rgb(20, 120, 220)'
            show_state: false
            show_name: true


First, sorry my English.
Sorry to reopen this forum.
I would like some help on how to change the name of an entity automatically, using the result of an input_select.

What I have is an input_select with two options:

  • mapa
  • planta baixa

I have two entities with the same name just changing the end of the name:

  • camera.vacuum_roborock_vacuum_a15_mapa
  • camera.vacuum_roborock_vacuum_a15_planta_baixa

then I would like to create a code that would change the entity’s name according to the selection, thus changing the image.

I’ve tried a lot, but nothing works.
I’m thinking about using a condition, but it would be my last option.

The last code I tried was:

          - type: image  
            entity: '[[[ return 'camera.vacuum_roborock_vacuum_a15_' + "{{ states['input_select.tipo_mapa'].state }}"; ]]]'
            camera_image: '[[[ return 'camera.vacuum_roborock_vacuum_a15_' + "{{ states['input_select.tipo_mapa'].state }}"; ]]]'
            camera_view: '[[[ return 'camera.vacuum_roborock_vacuum_a15_' + "{{ states['input_select.tipo_mapa'].state }}"; ]]]'

Is there a way to do this, or does it have to be by condition?

Thank you for your help.