[advanced-camera-card] Indirectly reference entity_id for a card

I want to use an entity_id from a drop down select to have a card display the information from a specific sensor, in this case to have only one camera feed displayed on my main page and to choose which one from a drop down input select. I haven’t found a way to do the indirect reference. For example replacing:

type: custom:state-switch
entity: input_select.camera_list
states:
   East Rear:
     type: custom:advanced-camera-card
     cameras:
       - camera_entity: camera.ds_xxxx_xxx_1

with

type: custom:state-switch
entity: input_select.camera_list
    type: custom:advanced-camera-card
    cameras:
      - camera_entity: input_select.camera_list

I’ve experimented with various {} bracket and apostrophe combinations to no avail. I tried using filter: template : (properly formatted) with codes such as:

{% for state in states.camera %}
  {% if state.name == 'West Rear' %}
    {{ state.entity_id }}
    {% set ns.id_var = state.entity_id %}
  {% endif %}
{% endfor %} 

trying to use ns.my_var (various {} “” combos) and without the namespace just leaving the {{state.entity_id}}. The state resolves to the correct camera name (i.e. camera.ds_xxxx_xxx_1) but it still doesn’t work.

Maybe the card resolves before the code executes. In most cases I get:
Invalid configuration: [ “cameras[0] → camera_entity” ]
type: custom:advanced-camera-card

cameras:
  - camera_entity:
      '[object Object]': null'

The card resolves correctly if the camera.xxx… is hard coded
HA 2025.5.1
running on a Virtual Box on debian 12, HAOS

Any help or thoughts would be most appreciated. I would like to employ the solution in order to choose other sensor cards to display ( I’ve also tried auto-entities and state-switch using the above constructs)

  1. Suggest to add “advanced-camera-card” word into your thread’s title.
  2. If this particular custom card supports jinja for that particular “cameras” option - then you can generate a list of entities or a particular entity. Otherwise - try placing that custom card into a custom card-wrapper adding templates support like config-template-card.

Thanks for the suggestions Ildar_Gabdullin. I’ve seen some of your other posts and you provide very knowledgeable insights. I’m studying the two cards you suggested but am not there yet. My goal is to abstract the code from the actual camera names and count so if I add or change a camera there is no code to change. It is easy to do in visual basic or even with my rudimentary js skills. A a more detailed description of where I am:

I created a drop down text helper input_select.camera_list but did not populate the dropdown options. I then trigger an action when ha is started to populate the drop down with the camera friendly names which works fine:

alias: "set camera names on startup"
  id: set-camera-names
  triggers:
    - trigger: homeassistant
      event: start
  actions:
    - action: input_select.set_options
      target:
        entity_id: input_select.camera_list
      data:
        options: "{{ states.camera | map(attribute='name') | list }}"

Then I created a piece of code to execute when a selection is made in the drop down to compare the friendly names to the drop sown selected and get the camera entity_id (I included this snippet above without context):

{% set ns = namespace(id_var = 'test') %}
{% for state in states.camera %}
  {% if state.name == states.input_select.camera_list.state %}
    {% set ns.id_var = state.entity_id %}
  {% endif %}
{% endfor %}  

What I haven’t figured out is exactly where to place the for / if code in a card or template and how to have the camera entity_id recognize the string I stored in ns.var_id.

type: custom:advanced-camera-card
camera:
  camera_entity: ???help!???

Thanks much for your help as well as the rest of the community. I think I’m close.