question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Jinja2 not recognized

See original GitHub issue

Hi ! First of all, thank you Thomas for your amazing work, your plugins are trully great. I’d like to use a basic Jinja2 template in my config, here is the begining of my ui-lovelace.yaml

# lovelace_gen
{% set v1 = switch.bin1 %}

And this is what I get when refreshing Lovelace :

while scanning for the next token found character ‘%’ that cannot start any token…

In my config I also have included views like this :

views:
  - !include lovelace/010_default.yaml

And if I had # lovelace_gen on top of those, I get this :

Unknown error

Did I do something wrong ? Also, lovelace-gen seems to be recognized by Hass, as I get this on startup :

[homeassistant.loader] Loaded lovelace_gen from custom_components.lovelace_gen

I’m using Hass v0.97.2 on Windows in a Python virtual environment Many thank’s 😃

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
thomaslovencommented, Nov 1, 2019

I’ve had some problems with using lovelace_gen on ui-lovelace.yaml itself. Try including a file and do everything there instead.

0reactions
oyvindhaugecommented, Jan 30, 2021

First of all, thanks to Thomas for all the great work you do for the community! Second, I am sorry if posting on a closed bug is the wrong way to go around.

However, I believe I have the same problem as described above. In my case it prevents HACS from starting when I restart Home Assistant. If I comment out the include below, I am able to start Home Assistant normally. And if I then uncomment the line again after the restart, the view is displayed correctly.

In my log file I have the following error message

Error setting up entry for hacs 4:12:43 PM – util/yaml/loader.py (ERROR)

This is followed by the more detailed log trace `… File “/usr/local/lib/python3.8/site-packages/yaml/scanner.py”, line 258, in fetch_more_tokens raise ScannerError(“while scanning for the next token”, None, yaml.scanner.ScannerError: while scanning for the next token found character ‘%’ that cannot start any token in “/config/lovelace/views/01_light_view.yaml”, line 8, column 8

The above exception was the direct cause of the following exception: …`

My ui-lovelace.yaml does not contain anything regarding lovelace_gen. It does however have the following include - !include lovelace/views/01_light_view.yaml

The 01_light_view_yaml contains the following relevant lines ` # lovelace_gen title: Lighting icon: mdi:lightbulb path: lighting cards:

#-------------BASEMENT------------------------------ {% set lights = [“light.basement_stairs_ceiling_dz”, “light.basement_gym_ceiling”, “light.basement_storage_ceiling_dz”, “light.basement_laundry_ceiling_dz”, “light.basement_laundry_sink”, “light.cinema_ceiling”, “light.lower_back”] %} - type: glance ` I am more than happy to provide more information, if that may help solve the problem. Thanks in advance for any suggestions.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Jinja2 code not recognised in HTML files.
I'm building a web app with Python, Flask and would like to include some Jinja code but its not recognized in any file...
Read more >
Jinja syntax is not recognised by Pycharm pro - Stack Overflow
Okay I solved the issue. The problem was that Pycharm could not recognise the jinja syntax so I went into Pycharm > Preferences...
Read more >
no detection to jinja2 code in html files · Issue #233 - GitHub
Hi, i am not sure this is expected behavior or not , when i have jinja2 code in a .html file it is...
Read more >
Template Designer Documentation - Jinja
If a variable or attribute does not exist, you will get back an undefined value. What you can do with that kind of...
Read more >
Basic Syntax of Jinja - Bloomreach Documentation
Even though it isn't a programming language, Jinja also has a specific set of words that you need to use in order to...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found