Help with dynamic template card and input select

or you could try this

  entities:
    - >
      ${
        if (vars[1] === 'Jamie Office')
          return 'sensor.average_temp_jamie_office';
        else if (vars[1] === 'Airing Cupboard')
          return 'sensor.average_temp_airing_cupboard';
        else if (vars[1] === 'Bar')
          return 'sensor.average_temp_bar';
        else if (vars[1] === 'Bathroom')
          return 'sensor.average_temp_bathroom';
        else
          return 'sensor.average_temp_jamie_office';
      }

Either way, the return and the value in the quotes HAVE TO BE on the same line. No way around that syntax.

thanks for trying, so not getting there however.

when i load that in, it changes the “>” to a pipe.
also, for other cards that work, I have this before it "- entity: " is that not needed?

  type: 'custom:mini-graph-card'
  entities:
    - entity: 
type: 'custom:config-template-card'
variables:
  - 'states[''input_select.hours_to_show''].state'
  - 'states[''input_select.room_temp_display2''].state'
entities:
  - input_select.hours_to_show
  - input_select.room_temp_display2
card:
  type: 'custom:mini-graph-card'
  entities:
    - |
      ${
        if (vars[1] === 'Jamie Office')
          return 'sensor.average_temp_jamie_office';
        else if (vars[1] === 'Airing Cupboard')
          return 'sensor.average_temp_airing_cupboard';
        else if (vars[1] === 'Bar')
          return 'sensor.average_temp_bar';
        else if (vars[1] === 'Bathroom')
          return 'sensor.average_temp_bathroom';
        else
          return 'sensor.average_temp_jamie_office';
      }
  hours_to_show: '${vars[0]}'
  points_per_hour: 1
  line_width: 3
  show:
    points: hover
    labels: true
    average: true
    extrema: true
  color_thresholds:
    - color: '#121df3'
      value: 11
    - color: '#c0ac2b'
      value: 17
    - color: '#c0392b'
      value: 25

if the mini graph card needs the word entity, then you need it as well.

still nothing :frowning:

type: vertical-stack
cards:
  - type: entities
    entities:
      - entity: input_select.hours_to_show
        name: Select Hours to Show
    show_header_toggle: false
  - type: entities
    entities:
      - entity: input_select.room_temp_display2
        name: Select Sensor
    show_header_toggle: false
  - type: 'custom:config-template-card'
    variables:
      - 'states[''input_select.hours_to_show''].state'
      - 'states[''input_select.room_temp_display2''].state'
    entities:
      - input_select.hours_to_show
      - input_select.room_temp_display2
    card:
      type: 'custom:mini-graph-card'
      entities:
        - entity: sensor.average_temp_jamie_office
      hours_to_show: '${vars[0]}'
      points_per_hour: 1
      line_width: 3
      show:
        points: hover
        labels: true
        average: true
        extrema: true
      color_thresholds:
        - color: '#121df3'
          value: 11
        - color: '#c0ac2b'
          value: 17
        - color: '#c0392b'
          value: 25
  - type: 'custom:config-template-card'
    variables:
      - 'states[''input_select.hours_to_show''].state'
      - 'states[''input_select.room_temp_display2''].state'
    entities:
      - input_select.hours_to_show
      - input_select.room_temp_display2
    card:
      type: 'custom:mini-graph-card'
      entities:
        - entity: >-
            ${
              if (vars[1] === 'Jamie Office')
                return 'sensor.average_temp_jamie_office';
              else if (vars[1] === 'Airing Cupboard')
                return 'sensor.average_temp_airing_cupboard';
              else if (vars[1] === 'Bar')
                return 'sensor.average_temp_bar';
              else if (vars[1] === 'Bathroom')
                return 'sensor.average_temp_bathroom';
              else
                return 'sensor.average_temp_jamie_office';
            }
      hours_to_show: '${vars[0]}'
      points_per_hour: 1
      line_width: 3
      show:
        points: hover
        labels: true
        average: true
        extrema: true
      color_thresholds:
        - color: '#121df3'
          value: 11
        - color: '#c0ac2b'
          value: 17
        - color: '#c0392b'
          value: 25


are you refreshing the cache and reloading the page? If that’s done, are you using chrome?

EDIT: I’m asking about chrome because you can take debug screenshots if you’re using chrome which will speed up this process.

yes to chrome and refresh

what can i provide to help

hit F12, find exceptions that appear in the lower section of the developer tools that appeared

Try and capture the whole section if possible.

type: vertical-stack
cards:
  - type: entities
    entities:
      - entity: input_select.hours_to_show
        name: Select Hours to Show
    show_header_toggle: false
  - type: entities
    entities:
      - entity: input_select.room_temp_display2
        name: Select Sensor
    show_header_toggle: false
  - type: 'custom:config-template-card'
    variables:
      - 'states[''input_select.hours_to_show''].state'
      - 'states[''input_select.room_temp_display2''].state'
    entities:
      - input_select.hours_to_show
      - input_select.room_temp_display2
    card:
      type: 'custom:mini-graph-card'
      entities:
        - entity: sensor.average_temp_jamie_office
      hours_to_show: '${vars[0]}'
      points_per_hour: 1
      line_width: 3
      show:
        points: hover
        labels: true
        average: true
        extrema: true
      color_thresholds:
        - color: '#121df3'
          value: 11
        - color: '#c0ac2b'
          value: 17
        - color: '#c0392b'
          value: 25
  - type: 'custom:config-template-card'
    variables:
      - 'states[''input_select.hours_to_show''].state'
      - 'states[''input_select.room_temp_display2''].state'
    entities:
      - input_select.hours_to_show
      - input_select.room_temp_display2
    card:
      type: 'custom:mini-graph-card'
      entities:
        - entity: |-
            ${
              if (vars[1] === 'Jamie Office')
                return 'sensor.average_temp_jamie_office';
              else if (vars[1] === 'Airing Cupboard')
                return 'sensor.average_temp_airing_cupboard';
              else if (vars[1] === 'Bar')
                return 'sensor.average_temp_bar';
              else if (vars[1] === 'Bathroom')
                return 'sensor.average_temp_bathroom';
              else
                return 'sensor.average_temp_jamie_office';
            }
      hours_to_show: '${vars[0]}'
      points_per_hour: 1
      line_width: 3
      show:
        points: hover
        labels: true
        average: true
        extrema: true
      color_thresholds:
        - color: '#121df3'
          value: 11
        - color: '#c0ac2b'
          value: 17
        - color: '#c0392b'
          value: 25

MINI-GRAPH-CARD 0.10.0
utils.ts:3 BATTERY-STATE-CARD 1.6.2
auto-entities.js:2 AUTO-ENTITIES 1.7.0 IS INSTALLED
card-tools.js:90 CARD-TOOLS 2.1.2 IS INSTALLED DeviceID: ed666fa9-ee57ddef
canary.js:1 CANARY 0.3.1
card-mod.js:5 CARD-MOD 2.0.3 IS INSTALLED
fold-entity-row.js:46 FOLD-ENTITY-ROW 19.0.0 IS INSTALLED
slider-entity-row.js:68 SLIDER-ENTITY-ROW 1.0.0 IS INSTALLED
time-picker-card.js:430 TIME-PICKER-CARD Version 1.1.1
config-template-card.js:3254 CONFIG-TEMPLATE-CARD Version 1.3.0
harmony-card.js:445 HARMONY-CARD Version 0.14.0
mini-climate-card-bundle.js:1 MINI-CLIMATE-CARD v1.2.7
light-entity-card.js:9160 LIGHT-ENTITY-CARD Version 4.2.2
template-entity-row.js:32 TEMPLATE-ENTITY-ROW 1.1.1 IS INSTALLED
entities.js:28 SPOTIFY-CARD Version 2.3.6
multiple-entity-row.js:1 MULTIPLE-ENTITY-ROW 4.1.1
card.js:219
RGB Light Card v1.7.1
scheduler-card.js:1626 SCHEDULER-CARD Version: v2.0.4
vertical-stack-in-card.js:1 vertical-stack-in-cardVersion: 0.4.0
hui-element.js:1 HUI-ELEMENT 1.0.1 IS INSTALLED
numberbox-card.js:3 NUMBERBOX_CARD 1.8
lovelace-card-templater.js:8 CARD-TEMPLATER Version 0.0.9
VM5163 test:1 Autofocus processing was blocked because a document already has a focused element.
2chunk.455e79b014618741a716.js:2837 card sensor Error: Specify an entity from within the sensor domain
at HTMLElement.value (chunk.9d6cfa32196f20fd6f2e.js:3400)
at s (chunk.455e79b014618741a716.js:2837)
at d (chunk.455e79b014618741a716.js:2837)
at c (chunk.455e79b014618741a716.js:2837)
at a (chunk.455e79b014618741a716.js:2837)
at HTMLElement.value (chunk.9d6cfa32196f20fd6f2e.js:3702)
at chunk.9d6cfa32196f20fd6f2e.js:3400
at Array.map ()
at HTMLElement.value (chunk.9d6cfa32196f20fd6f2e.js:3400)
at HTMLElement.value (chunk.72df0e2934b88fac4ebc.js:1)
c @ chunk.455e79b014618741a716.js:2837
VM5163 test:3 Uncaught (in promise) SyntaxError: Illegal return statement
at HTMLElement._evaluateTemplate (config-template-card.js:3401)
at config-template-card.js:3349
at Array.forEach ()
at HTMLElement._evaluateConfig (config-template-card.js:3338)
at HTMLElement._evaluateArray (config-template-card.js:3363)
at config-template-card.js:3343
at Array.forEach ()
at HTMLElement._evaluateConfig (config-template-card.js:3338)
at HTMLElement.render (config-template-card.js:3313)
at HTMLElement.update (config-template-card.js:3179)
chunk.455e79b014618741a716.js:2837 card sensor Error: Specify an entity from within the sensor domain
at HTMLElement.value (chunk.9d6cfa32196f20fd6f2e.js:3400)
at s (chunk.455e79b014618741a716.js:2837)
at d (chunk.455e79b014618741a716.js:2837)
at c (chunk.455e79b014618741a716.js:2837)
at a (chunk.455e79b014618741a716.js:2837)
at HTMLElement.value (chunk.9d6cfa32196f20fd6f2e.js:3702)
at chunk.9d6cfa32196f20fd6f2e.js:3400
at Array.map ()
at HTMLElement.value (chunk.9d6cfa32196f20fd6f2e.js:3400)
at HTMLElement.value (chunk.72df0e2934b88fac4ebc.js:1)
c @ chunk.455e79b014618741a716.js:2837
VM5163 test:3 Uncaught (in promise) SyntaxError: Illegal return statement
at HTMLElement._evaluateTemplate (config-template-card.js:3401)
at config-template-card.js:3349
at Array.forEach ()
at HTMLElement._evaluateConfig (config-template-card.js:3338)
at HTMLElement._evaluateArray (config-template-card.js:3363)
at config-template-card.js:3343
at Array.forEach ()
at HTMLElement._evaluateConfig (config-template-card.js:3338)
at HTMLElement.render (config-template-card.js:3313)
at HTMLElement.update (config-template-card.js:3179)
chunk.455e79b014618741a716.js:2837 card sensor Error: Specify an entity from within the sensor domain
at HTMLElement.value (chunk.9d6cfa32196f20fd6f2e.js:3400)
at s (chunk.455e79b014618741a716.js:2837)
at d (chunk.455e79b014618741a716.js:2837)
at c (chunk.455e79b014618741a716.js:2837)
at a (chunk.455e79b014618741a716.js:2837)
at HTMLElement.value (chunk.9d6cfa32196f20fd6f2e.js:3702)
at chunk.9d6cfa32196f20fd6f2e.js:3400
at Array.map ()
at HTMLElement.value (chunk.9d6cfa32196f20fd6f2e.js:3400)
at HTMLElement.value (chunk.72df0e2934b88fac4ebc.js:1)
c @ chunk.455e79b014618741a716.js:2837
VM5163 test:3 Uncaught (in promise) SyntaxError: Illegal return statement
at HTMLElement._evaluateTemplate (config-template-card.js:3401)
at config-template-card.js:3349
at Array.forEach ()
at HTMLElement._evaluateConfig (config-template-card.js:3338)
at HTMLElement._evaluateArray (config-template-card.js:3363)
at config-template-card.js:3343
at Array.forEach ()
at HTMLElement._evaluateConfig (config-template-card.js:3338)
at HTMLElement.render (config-template-card.js:3313)
at HTMLElement.update (config-template-card.js:3179)
2chunk.455e79b014618741a716.js:2837 card sensor Error: Specify an entity from within the sensor domain
at HTMLElement.value (chunk.9d6cfa32196f20fd6f2e.js:3400)
at s (chunk.455e79b014618741a716.js:2837)
at d (chunk.455e79b014618741a716.js:2837)
at c (chunk.455e79b014618741a716.js:2837)
at a (chunk.455e79b014618741a716.js:2837)
at HTMLElement.value (chunk.9d6cfa32196f20fd6f2e.js:3702)
at chunk.9d6cfa32196f20fd6f2e.js:3400
at Array.map ()
at HTMLElement.value (chunk.9d6cfa32196f20fd6f2e.js:3400)
at HTMLElement.value (chunk.72df0e2934b88fac4ebc.js:1)
c @ chunk.455e79b014618741a716.js:2837
VM5163 test:3 Uncaught (in promise) SyntaxError: Illegal return statement
at HTMLElement._evaluateTemplate (config-template-card.js:3401)
at config-template-card.js:3349
at Array.forEach ()
at HTMLElement._evaluateConfig (config-template-card.js:3338)
at HTMLElement._evaluateArray (config-template-card.js:3363)
at config-template-card.js:3343
at Array.forEach ()
at HTMLElement._evaluateConfig (config-template-card.js:3338)
at HTMLElement.render (config-template-card.js:3313)
at HTMLElement.update (config-template-card.js:3179)
chunk.455e79b014618741a716.js:2837 card sensor Error: Specify an entity from within the sensor domain
at HTMLElement.value (chunk.9d6cfa32196f20fd6f2e.js:3400)
at s (chunk.455e79b014618741a716.js:2837)
at d (chunk.455e79b014618741a716.js:2837)
at c (chunk.455e79b014618741a716.js:2837)
at a (chunk.455e79b014618741a716.js:2837)
at HTMLElement.value (chunk.9d6cfa32196f20fd6f2e.js:3702)
at chunk.9d6cfa32196f20fd6f2e.js:3400
at Array.map ()
at HTMLElement.value (chunk.9d6cfa32196f20fd6f2e.js:3400)
at HTMLElement.value (chunk.72df0e2934b88fac4ebc.js:1)
c @ chunk.455e79b014618741a716.js:2837
VM5163 test:3 Uncaught (in promise) SyntaxError: Illegal return statement
at HTMLElement._evaluateTemplate (config-template-card.js:3401)
at config-template-card.js:3349
at Array.forEach ()
at HTMLElement._evaluateConfig (config-template-card.js:3338)
at HTMLElement._evaluateArray (config-template-card.js:3363)
at config-template-card.js:3343
at Array.forEach ()
at HTMLElement._evaluateConfig (config-template-card.js:3338)
at HTMLElement.render (config-template-card.js:3313)
at HTMLElement.update (config-template-card.js:3179)
chunk.455e79b014618741a716.js:2837 card sensor Error: Specify an entity from within the sensor domain
at HTMLElement.value (chunk.9d6cfa32196f20fd6f2e.js:3400)
at s (chunk.455e79b014618741a716.js:2837)
at d (chunk.455e79b014618741a716.js:2837)
at c (chunk.455e79b014618741a716.js:2837)
at a (chunk.455e79b014618741a716.js:2837)
at HTMLElement.value (chunk.9d6cfa32196f20fd6f2e.js:3702)
at chunk.9d6cfa32196f20fd6f2e.js:3400
at Array.map ()
at HTMLElement.value (chunk.9d6cfa32196f20fd6f2e.js:3400)
at HTMLElement.value (chunk.72df0e2934b88fac4ebc.js:1)
c @ chunk.455e79b014618741a716.js:2837
VM5163 test:3 Uncaught (in promise) SyntaxError: Illegal return statement
at HTMLElement._evaluateTemplate (config-template-card.js:3401)
at config-template-card.js:3349
at Array.forEach ()
at HTMLElement._evaluateConfig (config-template-card.js:3338)
at HTMLElement._evaluateArray (config-template-card.js:3363)
at config-template-card.js:3343
at Array.forEach ()
at HTMLElement._evaluateConfig (config-template-card.js:3338)
at HTMLElement.render (config-template-card.js:3313)
at HTMLElement.update (config-template-card.js:3179)
chunk.455e79b014618741a716.js:2837 card sensor Error: Specify an entity from within the sensor domain
at HTMLElement.value (chunk.9d6cfa32196f20fd6f2e.js:3400)
at s (chunk.455e79b014618741a716.js:2837)
at d (chunk.455e79b014618741a716.js:2837)
at c (chunk.455e79b014618741a716.js:2837)
at a (chunk.455e79b014618741a716.js:2837)
at HTMLElement.value (chunk.9d6cfa32196f20fd6f2e.js:3702)
at chunk.9d6cfa32196f20fd6f2e.js:3400
at Array.map ()
at HTMLElement.value (chunk.9d6cfa32196f20fd6f2e.js:3400)
at HTMLElement.value (chunk.72df0e2934b88fac4ebc.js:1)
c @ chunk.455e79b014618741a716.js:2837
VM5163 test:3 Uncaught (in promise) SyntaxError: Illegal return statement
at HTMLElement._evaluateTemplate (config-template-card.js:3401)
at config-template-card.js:3349
at Array.forEach ()
at HTMLElement._evaluateConfig (config-template-card.js:3338)
at HTMLElement._evaluateArray (config-template-card.js:3363)
at config-template-card.js:3343
at Array.forEach ()
at HTMLElement._evaluateConfig (config-template-card.js:3338)
at HTMLElement.render (config-template-card.js:3313)
at HTMLElement.update (config-template-card.js:3179)
2chunk.455e79b014618741a716.js:2837 card sensor Error: Specify an entity from within the sensor domain
at HTMLElement.value (chunk.9d6cfa32196f20fd6f2e.js:3400)
at s (chunk.455e79b014618741a716.js:2837)
at d (chunk.455e79b014618741a716.js:2837)
at c (chunk.455e79b014618741a716.js:2837)
at a (chunk.455e79b014618741a716.js:2837)
at HTMLElement.value (chunk.9d6cfa32196f20fd6f2e.js:3702)
at chunk.9d6cfa32196f20fd6f2e.js:3400
at Array.map ()
at HTMLElement.value (chunk.9d6cfa32196f20fd6f2e.js:3400)
at HTMLElement.value (chunk.72df0e2934b88fac4ebc.js:1)
c @ chunk.455e79b014618741a716.js:2837
2VM5163 test:3 Uncaught (in promise) SyntaxError: Illegal return statement
at HTMLElement._evaluateTemplate (config-template-card.js:3401)
at config-template-card.js:3349
at Array.forEach ()
at HTMLElement._evaluateConfig (config-template-card.js:3338)
at HTMLElement._evaluateArray (config-template-card.js:3363)
at config-template-card.js:3343
at Array.forEach ()
at HTMLElement._evaluateConfig (config-template-card.js:3338)
at HTMLElement.render (config-template-card.js:3313)
at HTMLElement.update (config-template-card.js:3179)
VM5163 test:1 Uncaught (in promise) SyntaxError: Illegal return statement
at HTMLElement._evaluateTemplate (config-template-card.js:3401)
at HTMLElement._evaluateArray (config-template-card.js:3366)
at config-template-card.js:3343
at Array.forEach ()
at HTMLElement._evaluateConfig (config-template-card.js:3338)
at HTMLElement.render (config-template-card.js:3313)
at HTMLElement.update (config-template-card.js:3179)
at HTMLElement.performUpdate (config-template-card.js:2416)
at HTMLElement._enqueueUpdate (config-template-card.js:2369)
_evaluateTemplate @ config-template-card.js:3401
_evaluateArray @ config-template-card.js:3366
(anonymous) @ config-template-card.js:3343
_evaluateConfig @ config-template-card.js:3338
render @ config-template-card.js:3313
update @ config-template-card.js:3179
performUpdate @ config-template-card.js:2416
_enqueueUpdate @ config-template-card.js:2369
testing:3 Uncaught (in promise) SyntaxError: Illegal return statement
at HTMLElement._evaluateTemplate (config-template-card.js:3401)
at config-template-card.js:3349
at Array.forEach ()
at HTMLElement._evaluateConfig (config-template-card.js:3338)
at HTMLElement._evaluateArray (config-template-card.js:3363)
at config-template-card.js:3343
at Array.forEach ()
at HTMLElement._evaluateConfig (config-template-card.js:3338)
at HTMLElement.render (config-template-card.js:3313)
at HTMLElement.update (config-template-card.js:3179)

with F12 open, it CTRL+F5 and copy the errors again. There’s too much left over junk in that.

VM5664:3 Uncaught (in promise) SyntaxError: Illegal return statement
at HTMLElement._evaluateTemplate (config-template-card.js:3401)
at config-template-card.js:3349
at Array.forEach ()
at HTMLElement._evaluateConfig (config-template-card.js:3338)
at HTMLElement._evaluateArray (config-template-card.js:3363)
at config-template-card.js:3343
at Array.forEach ()
at HTMLElement._evaluateConfig (config-template-card.js:3338)
at HTMLElement.render (config-template-card.js:3313)
at HTMLElement.update (config-template-card.js:3179)

Did you ever solved the issue, i.e

entities:
        - entity: |-
            ${
              if (vars[1] === 'Jamie Office')

etc.

afraid not :frowning:

What is the code which does not work?
Also, the topic is marked as solved, is it really solved?

Is there any way you can help me. I have a bunch of chromecasts and would ove to be able to switch between them.
I created a select template with the values of my remotes.

type: vertical-stack
cards:
  - type: entities
    entities:
      - entity: select.chromecast_devices
        name: Select Chromecast
    show_header_toggle: false
  - type: custom:config-template-card
    variables:
      - states['select.chromecast_devices'].state
    entities:
      - select.chromecast_devices
    card:
      type: entities
      entities:
        - entity: ${"select.chromecast_devices"} 

How do I get it to make the entity the value of the select?