thomasloven / lovelace-auto-entities

🔹Automatically populate the entities-list of lovelace cards
MIT License
1.2k stars 111 forks source link

Strange error on template and loop #352

Open SoulRaven opened 1 year ago

SoulRaven commented 1 year ago

i use the code below to generate new cards based on the installed addons, but i get this error: any idea what i am doing wrong?

ha-card.ts:71 Uncaught Error: Invalid entity ID at position 0: {'type': at ha-card.ts:71:1 at Array.map (<anonymous>) at n (ha-card.ts:71:1) at f.value (ha-control-slider.ts:456:1) at o.setConfig (card-mod.js:5:1111) at set cardConfig [as cardConfig] (auto-entities.js:1:10237) at set entities [as entities] (auto-entities.js:1:9953) at k._getEntities (auto-entities.js:1:9695) at t.filter.t.filter.template.template (auto-entities.js:1:8356) at t.subscribeMessage.type [as callback] (auto-entities.js:1:8257)


      - type: vertical-stack
        cards:
          - type: entities
            entities:
              - type: custom:mushroom-title-card
                title: Additional components
                subtitle: >-
                  {{ integration_entities('Supervisor') | map('device_id') | unique |
                  list | length }} Installed components
            card_mod:
              style: |
                ha-card {
                  border-style: none;
                  background: none;
                  --mush-title-padding: 0px 0px 0px;
                }
                div.card-content {
                  padding-bottom: 0px
                }
          - type: custom:auto-entities
            card:
              type: entities
              card_mod:
                style: |
                  ha-card {
                    border-style: none;
                    background: none;
                    --mush-title-font-size: 20px;
                    --mush-title-padding: 0px 5px 0px;
                  }
                  h1.card-header{
                    padding: 6px 16px 0px;
                  }
                  div.card-content {
                    padding-top: 0px
                  }
            filter:
              template: |
                {%- set dev = namespace() %} {%- set dev.name = '' %}
                {%- set dev.running = '' %} {%- set dev.newest_version = '' %} 
                {%- set dev.version = '' %} {%- set dev.cpu_percent = '' %}
                {%- set dev.memory_percent = '' %} {%- set dev.update = '' %}

                {%- for devid in (integration_entities('Supervisor') | map('device_id') | unique) %}
                  {%- set dev.name = device_attr(devid, "name") %}
                  {%- for ent in device_entities(devid) %}
                    {%- if (ent.find("running") | int>=0) %}
                      {%- set dev.running = ent %}
                    {%- endif %}
                    {%- if (ent.find("newest_version") | int>=0) %}
                      {%- set dev.newest_version = ent %}
                    {%- endif %}
                    {%- if (ent.find("version") | int>=0) %}
                      {%- set dev.version = ent %}
                    {%- endif %}
                    {%- if (ent.find("cpu_percent") | int>=0) %}
                      {%- set dev.cpu_percent = ent %}
                    {%- endif %}
                    {%- if (ent.find("memory_percent") | int>=0) %}
                      {%- set dev.memory_percent = ent %}
                    {%- endif %}
                    {%- if (ent.find("update") | int>=0) %}
                      {%- set dev.update = ent %}
                    {%- endif %}
                  {%- endfor %}
                  {%- if dev.version > '' %}
                    {{- 
                      { 'type': 'section' } 
                    }}
                  {%- endif %}
                {%- endfor %}