home-assistant / core

:house_with_garden: Open source home automation that puts local control and privacy first.
https://www.home-assistant.io
Apache License 2.0
74.04k stars 31.07k forks source link

Helper group loses attribute entity_id and its members in case these are all unavailable #124055

Open Mariusthvdb opened 3 months ago

Mariusthvdb commented 3 months ago

The problem

previously raised in https://github.com/home-assistant/core/issues/77511 but closed as stale without resolution

as title: helper group entities that contain entities that are all unavailable (think light group with incidental lights not connected to power), lose their entity_id attribute, and the contained entity_ids because of that

Scherm­afbeelding 2024-08-16 om 12 02 16

even though the config_entries show the lights are configured:

"options": {
          "group_type": "light",
          "name": "Kerststerren",
          "entities": [
            "light.ster_links",
            "light.ster_rechts"
          ],
          "hide_members": false

and the helper flow also shows the lights:

Scherm­afbeelding 2024-08-16 om 11 06 06

we can not in any other way find these unavailable members via templating, because we can not expand on that now also unavailable group. use case: find any light that is not a member of a light group

{% set groepen = states.light
|selectattr('attributes.entity_id','defined')
| map(attribute='entity_id')
|list %}

{% set leden = groepen| expand | map(attribute='entity_id')| list %}

{{ states.light
    | map(attribute='entity_id')
    | reject('in', groepen +leden)
    | list}}

returns the grouped, but unavailable entity_id's

What version of Home Assistant Core has the issue?

2024.8.1

What was the last working version of Home Assistant Core?

No response

What type of installation are you running?

Home Assistant OS

Integration causing the issue

group

Link to integration documentation on our website

https://www.home-assistant.io/integrations/group

Diagnostics information

No response

Example YAML snippet

{% set groepen = states.light
|selectattr('attributes.entity_id','defined')
| map(attribute='entity_id')
|list %}

{% set leden = groepen| expand | map(attribute='entity_id')| list %}

{{ states.light
    | map(attribute='entity_id')
    | reject('in', groepen +leden)
    | list}}

Anything in the logs that might be useful for us?

No response

Additional information

using the old style grouped as an experiment:

group:
  test_kerstverlichting:
    name: Test kerstverlichting
    entities:
      - light.ster_links
      - light.ster_rechts

does contain the attribute and the member entity_id's

Scherm­afbeelding 2024-08-16 om 13 52 19

and allows to iterate these:

Scherm­afbeelding 2024-08-16 om 13 54 08
home-assistant[bot] commented 3 months ago

Hey there @home-assistant/core, mind taking a look at this issue as it has been labeled with an integration (group) you are listed as a code owner for? Thanks!

Code owner commands Code owners of `group` can trigger bot actions by commenting: - `@home-assistant close` Closes the issue. - `@home-assistant rename Awesome new title` Renames the issue. - `@home-assistant reopen` Reopen the issue. - `@home-assistant unassign group` Removes the current integration label and assignees on the issue, add the integration domain after the command. - `@home-assistant add-label needs-more-information` Add a label (needs-more-information, problem in dependency, problem in custom component) to the issue. - `@home-assistant remove-label needs-more-information` Remove a label (needs-more-information, problem in dependency, problem in custom component) on the issue.

(message by CodeOwnersMention)


group documentation group source (message by IssueLinks)

mekaneck commented 3 months ago

My $0.02 is the correct behavior should be that the group state goes to unknown when all members are unavailable. The group entity itself should continue to be available because it is well defined. It's merely that its state cannot be determined because the members are all unavailable, and therefore the state of unknown is more appropriate.

Further, if the solution instead was to retain the attributes on the group entity while has an unavailable status, it would be behavior that is not consistent with any other entity in HA.

loocd commented 3 months ago

Same issue here. In my application I am trying to expand groups to create light cards automatically. I aim to automatically display all my light entities, but want different cards for single lights and for grouped lights.

see example: dummy single light on top, dummy grouped lights on bottom. image

to do this, I need to:

my expected behaviour would be to retain full group functionality - i.e. keeps entity_id attribute even if lights become unavailable. The group is still valid and should be displayed as such, just the value is not known due to no lights being available.

issue-triage-workflows[bot] commented 1 week ago

There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates. Please make sure to update to the latest Home Assistant version and check if that solves the issue. Let us know if that works for you by adding a comment 👍 This issue has now been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.

Mariusthvdb commented 1 week ago

Keep