thomasloven / hass-lovelace_gen

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

Iterating over an array throws unknown error #31

Closed mrpharderwijk closed 2 years ago

mrpharderwijk commented 2 years ago

I have the following setup:

# global_config.yaml
...
- type: 'light'
   entity: 'light.hue_gu10_spots'
   name: 'Frontyard Spots'
   template:
     - 'icon_hue_bulb_spot1'
     - 'icon_hue_bulb_spot2'
     - 'icon_hue_bulb_spot3'
...
# view lovelace_gen file
...
- !include
  - includes/widgets/default_widget.yaml
  - widget_entity: {{ widget.entity }}
    widget_name: {{ widget.name }}
    widget_lock: {{ widget.lock }}
    widget_type: {{ widget.type }}
    widget_template: {{ widget.template }} <- the templates are passed
...
# default_widget.yaml
...
type: custom:button-card
entity: {{ widget_entity }}
name: |
  {% for whatever in widget_template %}
  {% endfor %}

  # this code alone says yes!
  {% if widget_template is sequence %}
    YES!!!
  {% else %}
    NO!!!
  {% endif %}
...

When placing the for loop it will result in an unknown error. It just doesn't let me iterate over the widget_template variable. Outputting the widget_template results in ['icon_hue_bulb_spot1', 'icon_hue_bulb_spot2', 'icon_hue_bulb_spot3']

What am I doing wrong?

mrpharderwijk commented 2 years ago

Nvm, appearantely somewhere further down the global_config I didn't define the template property and that was the reason for the unknown error...