Custom:config-template-card and variable problem

  - type: horizontal-stack
    cards:
      - type: custom:config-template-card
        variables:
          USER: user.name.toLowerCase()
          STATIONS: >-
            states['input_text.' + user.name.toLowerCase() +
            '_radiostations'].state.split(',')
          ROOM: '''wachtzaal'''
        entities:
          - ${'input_text.' + USER + '_radiostations'}
        card:
          type: custom:stack-in-card
          cards:
            - type: custom:mushroom-template-card
              primary: |-
                {% if state_attr('media_player.'~ ROOM, 'source') == 'Spotify Connect' and not is_state('media_player.'~ ROOM, 'paused') %}
                  Spotify-Lijst ({{ state_attr("media_player."~ ROOM, 'media_artist') }} - {{ state_attr('media_player.'~ ROOM, 'media_title') }})
                {% elif state_attr('media_player.${ ROOM ~', 'source') == 'Spotify Connect' and is_state('media_player.'~ ROOM, 'paused') %}
                  Muziek
                {% elif state_attr('media_player.'~ ROOM, 'media_content_id') == 'media-source://radio_browser/7bfe222c-6b98-4aec-8550-93c491bb2d1f' and not is_state('media_player.'~ ROOM, 'paused') %}  
                  Radio Willy
                {% elif state_attr('media_player.'~ ROOM, 'media_content_id') == 'media-source://radio_browser/960ef35c-0601-11e8-ae97-52543be04c81' and not is_state('media_player.'~ ROOM, 'paused') %}
                  Radio 1
                {% elif state_attr('media_player.'~ ROOM, 'media_content_id') == 'media-source://radio_browser/9619dbe5-0601-11e8-ae97-52543be04c81' and not is_state('media_player.'~ ROOM, 'paused') %}
                  Radio 2
                {% elif state_attr('media_player.'~ ROOM, 'media_content_id') == 'media-source://radio_browser/550f4b47-a545-4b1d-8c08-3b520c4db329' and not is_state('media_player.'~ ROOM, 'paused') %}
                  Stu Bru
                {% elif state_attr('media_player.'~ ROOM, 'media_content_id') == 'media-source://radio_browser/da8a07d1-f82c-4a3b-81d9-48fada438aef' and not is_state('media_player.'~ ROOM, 'paused') %}
                  Top Radio
                {% elif state_attr('media_player.'~ ROOM, 'media_content_id') == 'media-source://radio_browser/00dc2e9a-578c-430b-bdc2-244b71444dfc' and not is_state('media_player.'~ ROOM, 'paused') %}
                  Q music
                {% elif state_attr('media_player.'~ ROOM, 'media_content_id') == 'media-source://radio_browser/451491bd-624e-41e8-ab4c-71816f10611e' and not is_state('media_player.'~ ROOM, 'paused') %}  
                  Nostalgie
                {% endif %}

I want al my media_player.wachtzaal changed, so I can re use the code very easy, but I get “room is undefined”. what am I doing wrong ?

I am not using mushrooms but this is obviously wrong - you are trying to use a variable from config-template-card (CTC) inside a jinja template which makes no sense. If your custom card supports jinja - there is no need to use CTC.
Suggest you to ask all CTC-related questions in the dedicated thread.

1 Like