iantrich / config-template-card

πŸ“ Templatable Lovelace Configurations
MIT License
434 stars 56 forks source link

Issues with entity templating #74

Closed sresam89 closed 2 years ago

sresam89 commented 3 years ago

Checklist:

Release with the issue:

Last working release (if known):

Browser and Operating System: Lastest Chrome

Attempting to use https://github.com/iantrich/config-template-card#templated-entities-example with slightest mods as below `type: custom:config-template-card variables:

**

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

Additional information: developers state image

sresam89 commented 3 years ago

if I Change my config as below image

iantrich commented 3 years ago

You're putting the full state and attributes of the sensor into the entity field. So unless you are planning on using the state object later on, I would change it to:

variables:
  - sensor.user_10

If you are planning on using the state object later, you want to use the entity_id i.e.

'${vars[0].entity_id}'
sresam89 commented 3 years ago

That still did not help Could you help with the full config?

image

ildar170975 commented 2 years ago
  1. This is not an issue for Github. This question is supposed to be asked in the Community forum first since there are errors in the code.

  2. Whenever you post a code, use special tags - then people can copy-paste your example for testing, and in the 1st post you pasted the code without these tags, it is formatted in a wrong way. Also, do not post a code as a picture. Next time people will simply ignore these issues.

  3. There are examples below with working code:

    type: vertical-stack
    cards:
    - type: custom:config-template-card
    variables:
      - states['sun.sun']
    entities:
      - ${vars[0].entity_id}
    card:
      type: entity
      entity: ${vars[0].entity_id}
    - type: custom:config-template-card
    variables:
      - '''sun.sun'''
    entities:
      - ${vars[0]}
    card:
      type: entity
      entity: ${vars[0]}
    - type: custom:config-template-card
    variables:
      - '"sun.sun"'
    entities:
      - ${vars[0]}
    card:
      type: entity
      entity: ${vars[0]}

    ΠΈΠ·ΠΎΠ±Ρ€Π°ΠΆΠ΅Π½ΠΈΠ΅