Skip to content

Pick up a media player renamed in Home Assistant - #8

Merged
evski merged 1 commit into
evski:mainfrom
OpenDeernet:fix-renamed-player
Nov 4, 2026
Merged

evski merged 1 commit into
evski:mainfrom
OpenDeernet:fix-renamed-player

Conversation

@OpenDeernet

Copy link
Copy Markdown
Contributor

What does this change?

When a media player is renamed in Home Assistant (say media_player.kitchen -> media_player.kitchen_speaker), it vanishes from the sidebar until the page is reloaded.

mediaPlayerIds() only re-lists the entity ids when the number of entities changes. A rename removes one id and adds another in the same update, so the count stays the same, the cache keeps the old id, hass.states[oldId] is now undefined and the new id is never seen. The fix also re-lists when one of the cached ids is no longer in hass.states. It's a quick check over the handful of cached media players, so the cheap path for large installs stays the same.

How was it tested?

  • npm test passes (added a "V3 renamed entity" check: it fails on main with Office, minis=3 and passes with the fix)
  • Tried in a real Home Assistant instance: I haven't tried this on a live instance, only with the jsdom suite.

Checklist

  • Comments explain why, especially for any sidebar DOM selectors
  • New options have a default, validation, a README row and a test (no new options)
  • CHANGELOG.md updated under Unreleased
  • No private data (real entity ids, hostnames, IPs, tokens) in code, tests or screenshots

@evski evski left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @OpenDeernet, nice catch and a clear write-up. The fix is tight and keeps the cheap path for big installs, and the new test covers it. CI is green on Node 20 and 22, so merging. I'll ship it in a patch release shortly. (Heads-up: I maintain this with an AI assistant's help.)

@evski
evski merged commit cfecf81 into evski:main Nov 4, 2026
3 checks passed
@evski

evski commented Nov 4, 2026

Copy link
Copy Markdown
Owner

Released in v1.1.1. HACS should offer the update shortly. Thanks again!

@OpenDeernet

Copy link
Copy Markdown
Contributor Author

Thanks a lot for merging this and for the kind words!
Also, great little project, it's been really nice to use.

@evski

evski commented Nov 5, 2026

Copy link
Copy Markdown
Owner

You're welcome — glad it's useful day to day. Appreciate you taking the time to dig into the rename case and send a clean fix.

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.

2 participants