iantrich / config-template-card

📝 Templatable Lovelace Configurations
MIT License
425 stars 55 forks source link

Card vanishes as soon as I try to use a variable ( ${} ) #104

Closed Dendrowen closed 2 years ago

Dendrowen commented 2 years ago

Checklist:

Release with the issue: version 1.3.6

Last working release (if known): N/A

Browser and Operating System: Google chrome on Windows 11. Edge gives the same results.

Description of problem: When I try to use a variable in the yaml configuration, the card dissapears from the preview and from the main view. I'm using the following code:

type: custom:config-template-card
variables:
  - '''RDCLAK5uy_loc3QkpRI5iaLbS_laJf0_OwzvPeAYrYc'''
entities:
  - switch.home
card:
  type: button
  entity: sensor.ytube_music_player_extra
  primary: |
    {{ state_attr('sensor.ytube_music_player_extra', 'search')[0].title }}
  tap_action:
    action: url
    url_path: https://music.youtube.com/playlist?list="${ vars[0] }"

Javascript errors shown in the web inspector (if applicable):

Uncaught (in promise) SyntaxError: Unexpected end of input
    at ConfigTemplateCard._evaluateTemplate (config-template-card.js?hacstag=172177543136:912:28)
    at config-template-card.js?hacstag=172177543136:860:40
    at Array.forEach (<anonymous>)
    at ConfigTemplateCard._evaluateConfig (config-template-card.js?hacstag=172177543136:849:32)
    at config-template-card.js?hacstag=172177543136:857:40
    at Array.forEach (<anonymous>)
    at ConfigTemplateCard._evaluateConfig (config-template-card.js?hacstag=172177543136:849:32)
    at ConfigTemplateCard.render (config-template-card.js?hacstag=172177543136:807:23)
    at ConfigTemplateCard.update (config-template-card.js?hacstag=172177543136:265:321)
    at ConfigTemplateCard.performUpdate (config-template-card.js?hacstag=172177543136:252:4796)
_evaluateTemplate @ config-template-card.js?hacstag=172177543136:912
(anonymous) @ config-template-card.js?hacstag=172177543136:860
_evaluateConfig @ config-template-card.js?hacstag=172177543136:849
(anonymous) @ config-template-card.js?hacstag=172177543136:857
_evaluateConfig @ config-template-card.js?hacstag=172177543136:849
render @ config-template-card.js?hacstag=172177543136:807
update @ config-template-card.js?hacstag=172177543136:265
performUpdate @ config-template-card.js?hacstag=172177543136:252
scheduleUpdate @ config-template-card.js?hacstag=172177543136:252
_$EC @ config-template-card.js?hacstag=172177543136:252
await in _$EC (async)
requestUpdate @ config-template-card.js?hacstag=172177543136:252
set @ config-template-card.js?hacstag=172177543136:252
value @ hui-light-card.ts:35
_$AE @ styles.ts:368
performUpdate @ styles.ts:368
scheduleUpdate @ styles.ts:368
_$EC @ styles.ts:368
await in _$EC (async)
requestUpdate @ styles.ts:368
set @ styles.ts:368
value @ 334a76c1.js:1
performUpdate @ styles.ts:368
scheduleUpdate @ styles.ts:368
_$EC @ styles.ts:368
await in _$EC (async)
requestUpdate @ styles.ts:368
set @ styles.ts:368
k @ styles.ts:368
_$AI @ styles.ts:368
m @ styles.ts:368
T @ styles.ts:368
_$AI @ styles.ts:368
S @ styles.ts:368
update @ styles.ts:368
performUpdate @ styles.ts:368
scheduleUpdate @ styles.ts:368
_$EC @ styles.ts:368
await in _$EC (async)
requestUpdate @ styles.ts:368
set @ styles.ts:368
(anonymous) @ styles.ts:368
value @ styles.ts:368
value @ home-assistant.ts:32
_$AE @ styles.ts:368
performUpdate @ styles.ts:368
scheduleUpdate @ styles.ts:368
_$EC @ styles.ts:368
await in _$EC (async)
requestUpdate @ styles.ts:368
set @ styles.ts:368
value @ styles.ts:368
(anonymous) @ styles.ts:368
s @ core.a0afd420.js:1
(anonymous) @ core.a0afd420.js:1
e.subscribeMessage.type @ core.a0afd420.js:1
_handleMessage @ core.a0afd420.js:1

Additional information:

ildar170975 commented 2 years ago

Wrong use. Try:

    url_path: ${'https://music.youtube.com/playlist?list=' + vars[0] }

These questions are better to be asked in the Community thread and use GitHub for bugs & FRs only.

Dendrowen commented 2 years ago

Wrong use. Try:

    url_path: ${'https://music.youtube.com/playlist?list=' + vars[0] }

These questions are better to be asked in the Community thread and use GitHub for bugs & FRs only.

Oh, I feel stupid... Thanks!