🔹 Lovelace_gen - Add abilities to ui_lovelace.yaml

I have a floorplan completely written using lovelace_gen abilities.

The main view file is lovelace_new_data.yaml and is called by the main dashboard file lovelace_new.yaml

The file has become very long and a bit difficult to maintain. I would like to split it up into smaller files according to the sections. I have tried a few ways but couldn’t get it to see all the variables/definitions/macros.

Is there a way I can split it up into smaller files and keep the functionality?

Does it work with the latest 2022.7 HA version?
Anyone tried?

Doesn’t work for me. I get “Unknown error” until I remove it on the latest version.

1 Like

@thomasloven
Any chance of looking at this issue?

Same for me. Anyone found a workaround other than downgrading HA until the permanent fix ?

Hi Petro, do you know anyone who can advise me on installing lovelace_gen ?
I've been trying here for a few days now, but no chance of getting it to work
The problem is {% comma error

Hi all,

A question about this beautiful compoments.
I would like to replicate this piece of code:

{% set my_lights = ["light.bed_light", "light.kitchen_lights", "light.ceiling_lights"] %}
title: My view
cards:
  - type: entities
    entities:
{% for light in my_lights %}
      - {{ light }}
{% endfor %}

but instead of setting up manually the list “my_litghts” i would like to create it dinamycally.
Is it possible to for loop maybe using a group or create a list based on domain like “Light”?

something like this

title: My view
cards:
  - type: entities
    entities:
{% for light in domain.light %}
      - {{ light.entity_id }}
{% endfor %}

(that’s just an example I would like to achive)

Thanks to all

Nik

Is this still true because whenever I add it to an included ‘view’ file I get an error?

# lovelace_gen

title: Logging Settings
path: logging_settings
icon: mdi:notebook-edit

cards:

image

Still true, you most likely have an error below

I have asked this last year and still need a solution? Is there a way to split the lovelace_gen configuration ?

Yes there is, it’s covered in the documentation for lovelace_gen

This whole section is about breaking up:

I saw it but don’t think it is relevant for my configurations.

My UI is a single picture-elements with tens if not hundreds of elements on it. It is a single file (2105 lines and counting) all heavily using lovelace_gen and jinja.

The file is broken up into sections: Variables, Macros and then the elements’ implementation that is split into seperate sections for each of the element types and visual areas of the UI

Is there a simple way of splitting it into files each of these sections? Variable, Macros, Lights, Covers, Settings, Irrigations, etc…?

You can still split that way… It does not need to be a card. Just a collection of fields.

Assuming I took my lovelace_new_data.yaml file and cut it in 2 creating the following:

  • lovelace_new_data_variables.yaml
  • lovelace_new_data_rest.yaml

Each of the files has the # lovelace_gen at the beginning of course.

How should my new main lovelace file lovelace_new.yaml be?

current file is:

# lovelace_gen

kiosk_mode:
  hide_header: true

title: Home

views:
  - !include lovelace_new_data.yaml

I have no idea because I don’t know the contents of your files.

I think you should spend some time learning what includes actually do. They simply piece together information.

i.e.

foo:
- bar: Foobar

with incldues is

foo: !include something.yaml

something.yaml

- bar: Foobar

The same principle is applied here, however the yaml requires what the documents say. And then the information you pass is passed via the supplied variables. As long as you have a field, that field can be broken out like above.

field: 
  content1: value1
  content2: value2  

you can even include something like this

field: content

The syntax is no different for the include.

field: !include something.yaml

something.yaml

content

I went over how include works (again) and try to implement it but had issues with my configuration as I have macros and for loops that make it problematic.

Is there a way to “include” files as a simple concatenation? Meaning taking split files and appending them to each other without considering their content? Identation and fields will be taken care of inside each of the files as if they were already a single file.

For example taking a single file:

badges: []
icon: 'mdi:home-outline'
panel: true
path: floorplan
title: FloorPlan
cards:
  - type: picture-elements
    image: /local/images/floorplan/background_t.png
    elements:
      - type: image
        entity: cover.cover1
        ...
      - type: image
        entity: cover.cover2
        ...
      - type: image
        entity: cover.cover3
        ...
      - type: image
        entity: light.light1
        ...
      - type: image
        entity: light.light2
        ...
      - type: image
        entity: light.light3
        ...

and create the following 3 files with indentations as in the original file:

badges: []
icon: 'mdi:home-outline'
panel: true
path: floorplan
title: FloorPlan
cards:
  - type: picture-elements
    image: /local/images/floorplan/background_t.png
    elements:
      - type: image
        entity: cover.cover1
        ...
      - type:image
        entity: cover.cover2
        ...
      - type: image
        entity: cover.cover3
        ...
      - type: image
        entity: light.light1
        ...
      - type: image
        entity: light.light2
        ...
      - type: image
        entity: light.light3
        ...

Hi all.

I have follow all step to install lovelace_gen but not work for me.
This is my configuration

configuration.yaml

lovelace_gen:

lovelace:
  mode: storage
  dashboards:
    home-tablet:
      mode: yaml
      title: HomeBase
      icon: mdi:script
      show_in_sidebar: true
      filename: dashboard/home_tablet/home-tablet.yaml

This are my yaml files (I have extract only the affected code)

In home_tablet.yaml

- title: IRRIGAZIONE
    path: irrigazione
    panel: true
    cards:
      - !include view_irrigation.yaml

view_irrigation.yaml

#lovelace_gen
- type: vertical-stack
      cards:
        - type: markdown
          content: "## ZONE DI IRRIGAZIONE"
        #- !include irrigation_zone1.yaml
        - !include
            - irrigation_zone.yaml
            - entity: group.zone1_onoff
        - !include irrigation_zone2.yaml
        - !include irrigation_zone3.yaml

irrigation_zone.yaml

#lovelace_gen

        type: custom:button-card
        entity: { { entity } }
        template: irrigation_zone
        name: ORTO
        show_icon: true
        show_name: true
        icon: mdi:checkbox-blank-outline
        layout: icon_name

But not work, I reload dashboard but I receive “Unknown error”.

I thought the problem was in the configuration.yaml with multiple dashboards, but I’ve seen several people using the same configuration as me.

Can someone help me?

Regards,
Marco

Add a bit

I tried to use a simple page with only a button and it work fine.
I have retry with complete page, adding one card at a time and I found that the problem is here:

            type: custom:mushroom-template-card
            entity: light.lampada_sala
            icon: |
              {% if is_state('light.lampada_sala', 'on') %}
                mdi:stop-circle-outline
              {% else %}
                mdi:play-circle-outline
              {% endif %}

If I remove the code under icon: the page loading correctly and with passed parameters, otherwise, in the log, after a long python exception, I see this error:

jinja2.exceptions.UndefinedError: 'is_state' is undefined

Any ideas?

Unable to load HK5 Infused YI, getting he below errorUI File “/config/hki-base/base.yaml”, line 4, in top-level template code

As far as I can tell, lovelace-Gen does not provide the built in HASS extensions to work with state entities. I’m looking for a solution that does. Did you ever figure this out?