thomasloven / lovelace-fold-entity-row

🔹 A foldable row for entities card, containing other rows
MIT License
587 stars 38 forks source link

Can't include head: options when using inside a auto-entities group filter #230

Open ajma opened 2 years ago

ajma commented 2 years ago

My Home Assistant version: 2021.09.7

Fold-entity-row version (FROM BROWSER CONSOLE): 20.0.12

What I am doing: Trying to set head inside a auto-entities group filter

What I expected to happen: entity shows up with secondary-info in the head

What happened instead: secondary-info isn't showing up. the entities inside the group are showing up with the right state but without the secondary info

Minimal steps to reproduce:

# The least amount of code possible to reproduce my error

type: custom:auto-entities
card:
  type: entities
filter:
  include:
    - group: light.downstairs
      or:
        - state: 'on'
      options:
        type: custom:fold-entity-row
        head:
          entity: light.downstairs
          secondary_info: last-changed
        group_config:
          secondary_info: last-changed

# End of code

Error messages from the browser console:


By putting an X in the boxes ([X]) below, I indicate that I:

ildar170975 commented 2 years ago

The code is wrong. A proper code is clearly described in the docs.

type: entities
entities:
  - type: custom:auto-entities
    filter:
      include:
        - group: # add group sensor
          # add whatever you want
    card:
      type: custom:fold-entity-row
      head:
        entity: # add your entity
        secondary_info: last-changed
      group_config:
        secondary_info: last-changed
ajma commented 2 years ago

But doesn't that make everything in the auto-entities list a fold-entity-row? I only want that single group to be a fold-entity-row. My code almost works, it does everything except show secondary-info in the head

ildar170975 commented 2 years ago

My code almost works, it does everything except show secondary-info in the head

It cannot work. Check your code:

      options:
        type: custom:fold-entity-row
        head:
          entity: light.downstairs

which means - each row in the Entities card is fold-entity-row with some head and undefined folded entities.

You may do this:

type: custom:auto-entities
filter:
  include:
    - group: group.demo_lights
card:
  type: entities

which creates just a list of entities, w/o fold-entity-row.

I only want that single group to be a fold-entity-row

then just add these entities after your auto generated fold-entity-row image

ajma commented 2 years ago

Here's what I have: image

groups.lock is just there to show that I'm using auto-entities to expand other groups into normal entities but light.downstairs is expanded into the three rooms which are each fold-entity-row where the children have the secondary-info but I can't figure out the yaml to make the head also show secondary-info

ajma commented 2 years ago

The last example in the readmd has this:

type: custom:auto-entities
card:
  type: entities
  title: All groups
filter:
  include:
    - domain: group
      options:
        type: custom:fold-entity-row

I'm basically trying to use this but also set the secondary-info in the head but it looks like head is getting completely dropped. Even if I do

head:
  type: section
  label: test

it doesn't keep label. I'm starting to wonder if this is an auto-entities issue.

ajma commented 2 years ago

Ok, so I looked at the code and my current hypothesis is that it's because of https://github.com/thomasloven/lovelace-fold-entity-row/blob/master/src/main.ts#L54 which is let head = ensureObject(this._config.entity || this._config.head);. My hypothesis is that auto-entities is setting _config.entity, so the head is getting ignored. I'll see if I can setup a dev environment and test it out.

ajma commented 2 years ago

Ok, I tested it and it turned out to be right. I submitted a PR.