Resolved: Lovelace_gen throwing errors in templates

I’m on a new install of HASS and am using lovelace_gen to build up my dashboards.

When I include any special jinja capabilities, I get the following error:

while scanning for the next token found character '%' that cannot start any token ...

here’s the code from my file climate.yaml:

# lovelace_gen

{% set acs = [
    "climate.bedroom_air_conditioner",
    "climate.daikin_192_168_1_202",
    "climate.office_air_conditioner",
    "climate.pool_house_air_conditioner",
    "climate.theatre_air_conditioner"
  ]
%}

- type: custom:muto-layout-card
  columns:
    - !include ./_alert-column.yaml

    - flex: 2 2 40%
      cards:
        - type: custom:muto-layout-column-card
          cards:
            - type: custom:mini-media-player
              artwork: full-cover
              hide:
                icon: true
                power: true
                source: true
                sound_mode: true
                volume: true
              entity: media_player.lounge

    - flex: 2 2 40%
      cards:
        - type: custom:muto-layout-column-card
          cards:
            {% for entity in acs %}
              - type: custom:muto-slider-control-card
                status_entity: {{entity}}
                action:
                  type: toggle
                  entity: {{entity}}
                sensor_entity: {{entity}}
            {% endfor %}

If I remove all the {%...%} related code, the dashboard works fine.

I’ve used lovelace_gen before without this issue, and have checked on my other HASS both are running the same version of HASS and lovelace_gen.
Different entities/devices/etc, but same setup.

Any ideas?

Please update your post to format your code correctly using the </> button. You’ll probably need to re-paste it to get rid of the “smart quotes”.

Argh, apologies.
Fixed the formatting of the post.

Marking as resolved.

Turns out the configuration.yaml file had the lovelace_gen: line far too indented.

1 Like

Can you paste the relevant configuration.yaml lines? I’m following the github readme and it looks like it should have no indentation at all. I’m having the same issue BTW


lovelace_gen:

lovelace:
  mode: yaml
  resources:
    - url: /local/mushroom.js
      type: module