Open IDmedia opened 1 year ago
I'm having the issue and commenting out some of my includes makes it work, but i cannot for the life of me see why those are causing it to fail. Doesn't seem to be anything in the breaking changes of 2022.7 that would apply to me.
The only thing I can see is that Home Assistant changed to Python 3.10 and that the jinja2 package has been updated and the integration doesn't pin the version: https://github.com/pallets/jinja/releases
Can't yet see why it should break though.
I think it has to do with "Our YAML & JSON tooling improved, using faster libraries and methods".
Other than with lovelace_gen
I also had some issues with emoji's in template strings.
But it's a strange issue: my YAML files using lovelace_gen
are working fine when included in my "desktop" dashboard, yet the exact same files are throwing an error when included in my "phone" dashboard.
Bit more digging, i found this in my log file.
File "/usr/local/lib/python3.10/site-packages/jinja2/loaders.py", line 195, in get_source
pieces = split_template_path(template)
File "/usr/local/lib/python3.10/site-packages/jinja2/loaders.py", line 36, in split_template_path
raise TemplateNotFound(template)
jinja2.exceptions.TemplateNotFound: /config/lovelace/dashboards/../views/office.yaml
Path is correct, if i remove # lovelace_gen and change to a standard card include in that file (ie no jinja2) it picks up the file in that location.
edit
Some more oddities.
icon: mdi:home-assistant
title: Room
cards:
- !include
- ../cards/heating.yaml
- entity: office
This works with multi level attributes but no # lovelace_gen at the top of the file. Something very weird is going on. add # lovelace_gen at the top and it breaks.
So dug into the changes in the core yaml loader which this imports and it seems references to SafeLineLoader have been replaced with LoaderType
I've not tested yet, but I'm guessing these two lines.
loader.SafeLineLoader.add_constructor("!include", _include_yaml)
loader.SafeLineLoader.add_constructor("!file", _uncache_file)
Need to change.
So just pored over the jinja2 loader.py file and found that split_template_path will throw a template not found if the path has a .. in it. I was doing this to keep cards, dashboards and views seperate. Soon as moved them all into the same directory its started working. Not saying the lovelace_gen doesn't need some work to follow the improvements made in the latest release as it does look like it does to me, but will leave that up to @thomasloven
@chriscolden Does it mean it then works for you on the latest version of HA? I'm still struggling to get it to work at all after upgrading
yeah im working again it would seem. i had a directory structure of config/lovelace/cards config/lovelace/dashboards config/lovelace/views
which means i had to ../ out the directory to get to my next inlcude.
Just moved to config/lovelace/dashboards config/lovelace/dashboards/views config/lovelace/dashboards/views/cards
then replaced ../ with ./
and it seems to have sprung into life.
@IDmedia do you see this in your logs when you load a dashboard?
jinja2.exceptions.TemplateNotFound: /config/lovelace/dashboards/../views/office.yaml
No, I'm not using '..' in the path. No visible errors in the logs or console except the "unknown error" message when trying to view the dashboard.
you will have to post some examples. maybe create a new dashboard for testing, or at least comment out most of it and post whats not working for you.
you will have to post some examples. maybe create a new dashboard for testing, or at least comment out most of it and post whats not working for you.
The example is in the initial post (same goes for the path). Once I comment the lovelace_gen yaml out everything works so I know it's causing the issue. Something changed in the latest version of HA, just not sure what yet.
So what's in the lovelace/xiaomi_vacuum.yaml file? just standard yaml?
Did you see this about that file.
Important: For some reason, which I can't seem to nail down, things stop working if you add # lovelace_gen to ui-lovelace.yaml. Adding it to any file included from ui-lovelace.yaml works, though.
I'm not using lovelace_gen in that file. mines still on storage mode, and i include a separate dashboards which use lovelace_gen. thats the only think i can glean here.
Anyone was able to sort it out? It still not working for me in the new 2022.7 version
It's working for me now so you will need to post your config.
Mine isn't working as well, This is my config:
configuration.yaml -
lovelace:
mode: storage
dashboards:
lovelace-floorplan-desktop:
mode: yaml
title: FloorPlan Desktop
icon: mdi:floor-plan
show_in_sidebar: true
filename: lovelace_floorplan_desktop.yaml
lovelace_floorplan_desktop.yaml -
title: FloorPlan Desktop
views:
- !include
- lovelace_floorplan_data.yaml
- floorplan_type: desktop
lovelace_floorplan_data.yaml - i'm using {% raw %} and {% endraw %} in some parts. other then that nothing special
Sounds stupid, but try adding ./lovelace_floorplan_data.yaml
Didn't work unfortunately.
If I remove both the includes only then it works (rendering an empty page)
Can you post your lovelace_floorplan_data.yaml view.
Edit: lovelace_floorplan_desktop.yaml does that have a # lovelace_gen at the top?
Yes it has "# lovelace_gen" on top, and so does the lovelace_floorplan_data.yaml file
This is the lovelace_floorplan_data.yaml file, A bit long but pretty well structured I think: https://pastebin.com/ShcN5VcJ
so i just dumped your pastebin into a view and included it in mine. it doesn't render properly but i did get this.
That's interesting, seems like if you had the entities\images it would work, i just get an "unknown error". Can you please share the "view" code you used and the configuration code regarding the lovelace_gen?
Sure. I've just had to pop out so will do that later today.
Thanks @chriscolden, I really appreciate it.
Hey, sorry ran out of time yesterday. I've included all the way down to one of my most complex cards but haven't included all the cards the view includes. Nothing is out there. I dont use macros but everything else is pretty much the same as what you have.
Thanks a lot @chriscolden! I will try to debug it and check the differences
I find out that it's the variables that causing it to not work for some reason.
Doesn't work:
views:
- !include
- lovelace_floorplan_data.yaml
- floorplan_type: mobile
Works:
views:
- !include lovelace_floorplan_data.yaml
Anyone knows why or how to solve it?
I cannot make work the yaml with includes function. I want to make optimization of ui-lovelace.yaml, but for me, the folder structure, does not work. Logs do not tell me what is wrong.
My configuration.yaml has:
lovelace-irrigation:
mode: yaml
title: test
show_in_sidebar: true
filename: test.yaml
In the left menu, I see the button name "Test", but when I click on it it shows only yaml cards that are in it, but not what is included. My code of test.yaml:
# lovelace_gen
title: Test
views:
- ! includes lovelace\test.yaml
lovelace\test.yaml has code:
title: My view
cards:
- entities:
- entity: automation.gate_auto_open_when_i_arrive_to_home
- entity: cover.main_gate
- entity: sensor.main_gate_status
show_header_toggle: false
title: Main gate
type: entities
Can somebody help to debug this issue?
Thank you in advance!
You have a space after your ! And an s on the end. It should be.
!include lovelace\test.yaml
You have a space after your ! And an s on the end. It should be.
!include lovelace\test.yaml
Thank you! It works! I had the wrong guide.
I just put up a PR that should fix this in #42. It undoes the performance improvement (using the C Loader for YAML) from Home Assistant 2022.7, but that seems to be an acceptable trade off.
I just put up a PR that should fix this in #42. It undoes the performance improvement (using the C Loader for YAML) from Home Assistant 2022.7, but that seems to be an acceptable trade off.
Thank you, this solved my problem!!!! now i'm runing 2022.10 without a problem..
Tried upgrading HA to 2022.7 and I'm getting "Unknown error" without any errors in the console or logs. Can't get the UI to show until I comment out my lovelace_gen include. Anyone else having this issue?
Example from my UI-lovelace.yaml file causing the error: