thomasloven / hass-lovelace_gen

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

Entity is not reconized in macro for picture-entity #20

Open jmgiaever opened 4 years ago

jmgiaever commented 4 years ago

This is my yaml (which is included!)

# lovelace_gen
{% macro user_photo(entity, ws) -%}
{{"  "*ws}}- type: picture-entity
{{"  "*ws}}  entity: {{ entity }}
{{"  "*ws}}  image: "/local/img.jpg"
{%- endmacro %}
title: Example
cards:
  - type: vertical-stack
    cards:
      - type: horizontal-stack
        cards:
          {{ user_photo('person.joachim_m_giaever', 3) }}
      - type: glance
        entities: 
          - entity: lock.entrance_door_lock
            name: "Entrance door"
            tap_action: 
              action: toggle
          - entity: binary_sensor.office_door_state
            name: "Office"
          - entity: binary_sensor.bedroom_window_state
            name: "Bedroom window"

The frontend is giving me the error:

Invalid Configuration: 'entity' required
type: picture-entity

I've tested that «the person» exists and tried to look for indentation errors. I'm wondering why I need to set 3xIndent in my method, but when I'm counting, I'll count 5.

I'm using HA 0.115.6. and latest version available of lovelace_gen in HACS.

lmamakos commented 3 years ago

You can use JSON-style syntax within YAML files to avoid indentation issues like this. See my post https://community.home-assistant.io/t/fun-with-lovelace-gen-and-jinja2-macros-to-avoid-whitespace-indentation-problems/236427 for an example.