Skip to content

Entity discovery issues #725

@TheJulianJES

Description

@TheJulianJES

Pre-existing issues flagged by Copilot (not introduced by this PR)

_compute_primary_entity can get stuck after entity removal

Weight-election losers are set to _attr_primary = False, which permanently excludes them from future elections (filtered by _attr_primary is not False). If the winner is later removed, no remaining entity can become primary.

Fixing this requires distinguishing quirk-set _attr_primary from weight-computed values, since both use the same field. Needs a separate PR.

_discover_new_entities() in async_configure leaves entities half-added

async_configure() calls _discover_new_entities(), which runs entity.on_add() (e.g. RSSI sensor registers a global updater listener) and queues entities in _pending_entities — but never calls _add_pending_entities(). These entities are cleaned up when async_initialize() runs later, but until then they have active side effects without being finalized.

is_supported_in_list receives self in the entity list

recompute_entities passes the full entity list including the entity being evaluated. Implementations (RSSI sensor, button) already filter out self defensively. A prior commit on this branch explicitly ensured this works, but the caller could exclude self to avoid requiring defensive checks in every implementation.

Originally posted by @TheJulianJES in #517 (comment)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions