Attempting to switch to YAML mode and lovelace_gen

I’m a few days into my first HA instance. I’ve gotten the hang of adding dashboards, views, and cards in UI mode, but would like to try more advanced cards like this ( Integrating your Tesla with Home Assistant (synapselabs.io)).

I followed the instructions here ( thomasloven/hass-lovelace_gen: :small_blue_diamond: Improve the lovelace yaml parser for Home Assistant (github.com)), but cannot make sense of my next steps.

For now, I think I have two questions:

  1. After adding the lines to configuration.yaml to convert to YAML mode, I thought all of my cards would convert over. Instead, they’re all in a red error state. How do I get them back since it seems switching to YAML mode is a global setting?

  2. After switching to YAML mode and restarting, I expected to see a ui-lovelace.yaml file that I could start editing, but it’s not in the config folder. Is it somewhere else?

Maybe too little, too late.

Never perform substantial work on Home Assistant without making a full snapshot (backup). This way if you hose it, you can simply restore the snapshot and your Home Assistant will be as if you never touched it. (I speak from experience).

I spent several painful days getting rid of my ui-lovelace.yaml- Why do you want to go backwards? Note that lovelace_gen that you linked to is more than a year old.

Have you looked at the Tesla integration in HACS?

1 Like

I took a recent snapshot, but also haven’t done anything irreversible (so far :wink:).

I have the Tesla Custom Integration. This is about graphically depicting those sensors and switches as shown in the first link above.

I don’t want to go backwards (especially if this would be a global change precluding any further use of UI cards), but I do want the layout and functionality it seems is only achievable via YAML (at least for the Tesla card/panel. If there’s a better approach here in 2022, I’m open to that as well.

Thank you.

Lovelace_gen is definitely not for beginners. You need to have a firm undertanding of yaml, dashboards, and jinja.

The reason everything is red on your system is most likely because when you switch to yaml mode, you need move your resources from ui into yaml. I’m not 100% sure if this is still a requirement, but it was last I remember.

And still works perfect and is still maintained by Thomas and others (like myself).

There is nothing “backwards” about yaml configurations.

It’s just a different way of doing things.

If anything using the UI is a more simplistic way of doing things and yaml is more advanced. So that negates your “backwards” comment.

Yes, using yaml mode the resources need to be configured under the “lovelace:” section in the configuration.

Yes, once you enable yaml mode for lovelace the UI is disabled.

But it’s not really that big of a deal. Yaml really isn’t as hard as some try to portray. And you can do the same things in yaml mode (or maybe more?) than you can thru the UI. especially if the card you want doesn’t support the UI editor.

The answers to my original questions are toward the end of this post…
Multi-line Jinja template configuration error on Picture Elements card - Configuration / Frontend - Home Assistant Community (home-assistant.io) and in @petro’s original response above (I needed to add the resources in configuration.yaml to simply point to the directories where HACS installed them…no moving files required). For my second question, after reading this ( ui_lovelace.yaml vs ui-lovelace.yaml · Issue #17 · thomasloven/hass-lovelace_gen (github.com)), I’m not sure if ui-lovelace.yaml or ui_lovelace.yaml is required at all to get lovelace_gen to work.

In any case, I’m still not able to get lovelace_gen working after carefully following the instructions provided here ( thomasloven/hass-lovelace_gen: :small_blue_diamond: Improve the lovelace yaml parser for Home Assistant (github.com)). I’m getting this error:

while scanning for the next token found character ‘%’ that cannot start any token in “/config/Test.yaml”, line 12, column 10.

Here is the relevant section of my configuration.yaml:

Here is the beginning of the Test.yaml file

I’d appreciate any pointers to get lovelace_gen going. Thank you.

You have #lovelace_gen in your main file, you can’t do that. It can only go in included files. Look at the important note in the docs.

I thought that only applied to ui-lovelace/ui_lovelace.yaml and since I wasn’t using that, it didn’t apply.

So, I should simply remove #lovelace_gen from Test.yaml, but then what?

It specifically says “#lovelace_gen” only works in lovelace_gen included files. It has to be !included via the documented ways to include files.

FYI this is my main view file

OK, so it’s ui**(dash)**lovelace.yaml and it is required to get lovelace_gen to work (simply as a place to !include the actual .yaml files). That’s two less things I can stop researching :wink:

I did previously try that, but didn’t include the "views: " Here’s what I’ve got now in ui-lovelace.yaml:
image

I’ve kept the # lovelace_gen at the top of Test.yaml, restarted HA, and cleared my browser cache and I’m still getting the token error.

verify that your syntax for lovelace is correct. I.e. test.yaml does not have views because you’re specifying it in the main area.

Also, ddi you install lovelace_gen or did you simply add the line to your config?

To check my syntax (since I’m still learning), I just created a new UI dashboard, added a Picture Elements card, and opened the Raw configuration editor. The only line I added to it was the type: panel line since that’s how I’d like the Test dashboard to render. It looks like this and it works.

To rule out possible issues, I removed the theme and badge lines from Test.yaml and restarted HA. Same issue.

To configure for using lovelace_gen, I followed the Installation Instructions here ( thomasloven/hass-lovelace_gen: :small_blue_diamond: Improve the lovelace yaml parser for Home Assistant (github.com)). I just looked and I see it in HACS. I’ll try deleting the two files from my manual configuration and try to install that.

image

EDIT: maybe you dont understand what I’m saying: Delete views: from your test.yaml file.

OK, I installed lovelace_gen via HACS using the master branch (correct?).

I deleted views: and outdented the remaining lines:

Same error.

You have to restart after installing lovelace_gen

I did…and again after making these changes to Test.yaml

Master branch, right?

Then, based on what I’ve seen (bar syntax errors in jina) it should work.

Do you have a simple lovelace_gen enabled .yaml you could share with me to check basic functionality?