thomasloven/lovelace-auto-entities

Add possibility to expand nested groups recursivly

momonator25 opened this issue · 1 comments

In my HA setup I have nested my sensors entities per type and area.
For example the group motion_sensors contains the different groups for the areas. To keep it simple I only take two in this example:

  • binary_sensor.motion_sensors
    • binary_sensor.motion_sensors_hallway
      • binary_sensor.motion_sensor_hallway_door
      • binary_sensor.motion_sensor_hallway_stairs
    • binary_sensor.motion_sensors_bedroom
      • binary_sensor.motion_sensor_bedroom_door
      • binary_sensor.motion_sensor_bedroom_bed

When I include

type: custom:auto-entities
card:
  type: entities
  title: Motion Sensors
filter:
  include:
    - group: binary_sensor.motion_sensors

I only see the two underlying entities:

  • binary_sensor.motion_sensors_hallway
  • binary_sensor.motion_sensors_bedroom

A possibilty to make auto-entities expand recursive groups would solve this problem.

EDIT:

Using wildcards to solve this doesn't work and gives no output

type: custom:auto-entities
card:
  type: entities
  title: Motion Sensors
filter:
  include:
    - group: "binary_sensor.motion_sensors_*"

EDIT 2:

From the docs I'm not shure if the entities option supports templating but it doesn't work for me:

type: custom:auto-entities
card:
  type: entities
  title: Motion Sensors
entities:
  template: "{{ expand('binary_sensor.motion_sensors') | map(attribute='entity_id') |  list }}"

Using a template to expand the group in the filter section this way doesn't work either for me:

type: custom:auto-entities
card:
  type: entities
  title: Motion Sensors
filter:
  include:
    - entities:
        template: |
          {{ expand('binary_sensor.motion_sensors') | map(attribute='entity_id') |  list }}

Running the template in the developer tools results in a list of the wanted entities which should work for the -entities in the include section :

[
  "binary_sensor.motion_sensor_bedroom_door",
  "binary_sensor.motion_sensor_bedroom_bed",
  "binary_sensor.motion_sensor_hallway_door",
  "binary_sensor.motion_sensor_hallway_stairs"
]

EDIT 3:

All Problems of EDIT 2 are solved by moving the template section directly under the filter and not in the include. So was my mistake. But this way I can't add options to the displayed entities:

type: custom:auto-entities
card:
  type: entities
  title: Motion Sensors
filter:
  template: "{{ expand('binary_sensor.motion_sensors') | map(attribute='entity_id') | list }}"
  include:
    options:
      secondary_info: last-changed
      state_color: true

EDIT 4:

Going the route over the domain and the attributes device_class leads to the problem that now also my groups are listed as seperate entries alongside with the sensors itself.

type: custom:auto-entities
card:
  type: entities
  title: Motion Sensors
filter:
  include:
    - domain: binary_sensor
      attributes:
        device_class: motion

I would like to see a way to solve this as well. Currently I have a group called
light.all_lights
Inside that I have
light.upstairs_lights
light.downstairs_lights

Inside light.upstairs_lights I have
light.master_bedroom_lights

Inside that I have
light.master_bedroom_mirror_lightstrip
light.master_bedroom_bed_light_strip
light.master_bedroom_fan_light
so on and so forth. Then each room upstairs has its own list within it, then the same for downstairs.

As it stands now I would need to put each group individually in auto entities, or change it to domain: light and filter out some of the groups and random things that aren't actually lights.