thomasloven / hass-lovelace_gen

🔹 Improve the lovelace yaml parser for Home Assistant
MIT License
221 stars 22 forks source link

Working with Multiple Dashboards #35

Closed nathanmfast closed 2 years ago

nathanmfast commented 2 years ago

Is there any way to process separate dashboard yaml files with lovelace_gen?

I understand that this plugin looks at ui-lovelace.yaml and finds all the files that are included via !include statements, and if any of those files begin with # lovelace_gen it will perform its pre-processing on them.

In my configuration.yaml I have a bunch of dashboards defined under lovelace: so the relevant portion looks like this:

lovelace_gen:

lovelace:
  mode: yaml
  dashboards:
    upstairs-mobile-dashboard:
      mode: yaml
      title: Upstairs
      icon: mdi:home-floor-3
      show_in_sidebar: true
      filename: dashboards/upstairs-mobile-dashboard.yaml  

As far as I know, this is how you have to define yaml dashboards, or at least there's not a way that I am aware of to define them in ui-lovelace.yaml (which wouldn't really make sense because ui-lovelace.yaml is really just the "main" dashboard).

Am I out of luck? Is there any way to make lovelace_gen work on multiple dashboards like I have?

nathanmfast commented 2 years ago

I figured it out!

I was very confused because documentation said it changes the way Home Assistant parses your ui-lovelace.yaml before sending the information off to the lovelace frontend in your browser. This made me think that my dashboards/upstairs-mobile-dashboard.yaml wouldn't be able to use lovelace_gen. I tried it anyways, and it didn't work. I just now realized that it didn't work because I was essentially doing the same thing as the documentation warns not to do with ui-lovelace.yaml - using it directly on the dashboard as opposed to in files referenced from that dashboard. One I put my views for dashboards/upstairs-mobile-dashboard.yaml in separate files and included them, I could then use lovelace_gen in all of the views for my various dashboards, which is exactly what I wanted.

Is it correct to say that lovelace_gen processes any file included in another yaml file via !include? That would make more sense to me in light of what I experienced, and it also clears up why you can't use lovelace_gen directly in ui-lovelace.yaml.