Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature Request] Split lovelace_gen based UI YAML file #48

Open
theone11 opened this issue Apr 13, 2023 · 0 comments
Open

[Feature Request] Split lovelace_gen based UI YAML file #48

theone11 opened this issue Apr 13, 2023 · 0 comments

Comments

@theone11
Copy link

theone11 commented Apr 13, 2023

I would like to request a feature for "simple" splitting of lovelace_gen based UI YAML file.

I think it will also solve, or give possible solution for #32

I have a ~2100 lines UI YAML file very heavily relying on lovelace_gen that includes Variable, Macros, loops, etc... (If not for lovelace_gen the code will be ~7500 lines)
https://github.com/theone11/HomeAssistantConfig/blob/master/lovelace_new_data.yaml

I want to split the YAML file into multiple YAML files but not in the "regular" HomeAssistant !include way - I don't think it is possible in my case (I have tried many ways) - And if there is a way it may need for me to repeat some of the variables and macros in each of the files.

I want to split the YAML files by cutting the files wherever I want and that lovelace_gen will concatenate the files before processing them (the cut files will keep the original identation required by YAML) - See simple example below.

The files to concatenate (include) can be listed just after the # lovelace_gen command so lovelace_gen "knows" to concatenate all files before proceeding with the processing of the code:

# lovelace_gen_include <filename.yaml>

or

# lovelace_gen_include_dir <folder_name>

For example if I have a single file:

UI.yaml

# lovelace_gen

{% set ... %}
{% set ... %}

{% macro ... -%}
{%- endmacro %}

{% macro ... -%}
{%- endmacro %}

title: Home
views:
  - 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
            ...

I would like it to be able to split it up like so:

UI.yaml

# lovelace_gen
# lovelace_gen_include UI_1.yaml
# lovelace_gen_include UI_2.yaml
# lovelace_gen_include UI_3.yaml

{% set ... %}
{% set ... %}

{% macro ... -%}
{%- endmacro %}

{% macro ... -%}
{%- endmacro %}

UI_1.yaml

title: Home
views:
  - badges: []
    icon: 'mdi:home-outline'
    panel: true
    path: floorplan
    title: FloorPlan
    cards:
      - type: picture-elements
        image: /local/images/floorplan/background_t.png
        elements:

UI_2.yaml

          - type: image
            entity: cover.cover1
            ...
          - type:image
            entity: cover.cover2
            ...
          - type: image
            entity: cover.cover3
            ...

UI_3.yaml

          - type: image
            entity: light.light1
            ...
          - type: image
            entity: light.light2
            ...
          - type: image
            entity: light.light3
            ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant