Skip to content

Subscribe to rating changes only for an administrator - #43

Merged
cayossarian merged 4 commits into
mainfrom
fix/ratings-subscription-admin
Nov 18, 2026
Merged

cayossarian merged 4 commits into
mainfrom
fix/ratings-subscription-admin

Conversation

@cayossarian

Copy link
Copy Markdown
Member

The card and the sidebar dashboard now subscribe to span_panel_package_ratings_changed only for an administrator. Part of the unreleased 0.12.0.

The integration is opening span_panel/panel_topology to every logged-in user. Before, it was admin-only, which left the sidebar's By Panel, By Activity and By Area views showing "Unauthorized" for non-admins. With the topology open, a non-admin's card would reach its subscription to that event. Home Assistant refuses the subscription, since the event isn't on Core's subscribe allow-list, and logs an ERROR each time.

  • One shared check, canHearRatingChanges(hass) (hass.user.is_admin === true), decides for both the card and the sidebar. While the user is still unknown, nothing subscribes; an admin subscribes once the frontend names them.
  • When a user stops being an administrator, the subscription is dropped, so later reconnects don't repeat the refusal. Becoming an admin again resubscribes once.
  • Non-admins pick up rating changes on the next re-render or reload, as the sidebar already did.
  • Comments that assumed the topology was admin-only now describe it as open. The entity-discovery fallback stays for an older integration and for a failed read.

82 files and 1540 tests pass, and dist/ is rebuilt.

The integration now lets every logged-in user read panel_topology. The
card subscribed to span_panel_package_ratings_changed whenever its
topology came from there, so it now did so for a user who is not an
administrator too, and Core, whose allow-list of events anyone may
subscribe to leaves this one out, refused each time the card attached,
logging an error.

canHearRatingChanges() says who may hear the event: an administrator,
and only once the frontend says so. The card and the sidebar both ask
it, so anyone else's view takes a changed copy as it next reads the
topology. The card asks again on every change of Home Assistant, as the
sidebar already did, so either subscribes once the frontend says the
user is an administrator; the sidebar no longer subscribes before it
says so, where a user it then names as no administrator would have been
refused.

The comments that took panel_topology to be an administrator's alone,
and the entity fallback to be how anyone else's card works, now say
what holds: the fallback serves an integration that still keeps
panel_topology to administrators, and a read that fails.
…istrator

A user whose administrator rights went, as a reconnect can find, kept the
card's and the sidebar's rating subscriptions, which Core would refuse on
each later reconnect, logging an error each time. Once Home Assistant says
the user may not hear the event, both now drop them, and subscribe again,
once, as it says the user is an administrator.
@cayossarian
cayossarian merged commit 17e9bce into main Nov 18, 2026
2 checks passed
@cayossarian
cayossarian deleted the fix/ratings-subscription-admin branch November 18, 2026 07:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant