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)
Pre-existing issues flagged by Copilot (not introduced by this PR)
_compute_primary_entitycan get stuck after entity removalWeight-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_primaryfrom weight-computed values, since both use the same field. Needs a separate PR._discover_new_entities()inasync_configureleaves entities half-addedasync_configure()calls_discover_new_entities(), which runsentity.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 whenasync_initialize()runs later, but until then they have active side effects without being finalized.is_supported_in_listreceivesselfin the entity listrecompute_entitiespasses the full entity list including the entity being evaluated. Implementations (RSSI sensor, button) already filter outselfdefensively. A prior commit on this branch explicitly ensured this works, but the caller could excludeselfto avoid requiring defensive checks in every implementation.Originally posted by @TheJulianJES in #517 (comment)