Skip to content

Fix asking Music Assistant for music searching only radio - #177674

Merged
zweckj merged 1 commit into
music-assistant-artist-search-filter-testfrom
music-assistant-music-class-search
Jul 31, 2026
Merged

zweckj merged 1 commit into
music-assistant-artist-search-filter-testfrom
music-assistant-music-class-search

Conversation

@marcelveldt

Copy link
Copy Markdown
Member

Proposed change

Asking a voice assistant to "play some music" or "play songs by " did nothing on Music Assistant, while the assistant still said it was playing.

HA has no media class for radio, so we hand radio stations back under the music class. That same class was then read back as radio when searching, and a voice assistant picks music for any plain play request, so those searches only ever looked at radio stations and came back empty.

Music now means music, and radio keeps the class it is shown with.

  • Search artists, albums, tracks and playlists when asked for music
  • Allow a media class to stand for more than one kind of media

Stacked on #177673, which touches the same mapping. Only the last commit belongs to this one.

Type of change

  • Dependency upgrade
  • Bugfix (non-breaking change which fixes an issue)
  • New integration (thank you!)
  • New feature (which adds functionality to an existing integration)
  • Deprecation (breaking change to happen in the future)
  • Breaking change (fix/feature causing existing functionality to break)
  • Code quality improvements to existing code or addition of tests

Additional information

Checklist

  • I understand the code I am submitting and can explain how it works.
  • The code change is tested and works locally.
  • Local tests pass. Your PR cannot be merged unless tests pass
  • There is no commented out code in this PR.
  • I have followed the development checklist
  • I have followed the perfect PR recommendations
  • The code has been formatted using Ruff (ruff format homeassistant tests)
  • Tests have been added to verify that the new code works.
  • Any generated code has been carefully reviewed for correctness and compliance with project standards.

If user exposed functionality or configuration variables are added/changed:

If the code communicates with devices, web services, or third-party tools:

  • The manifest file has all fields filled out correctly.
    Updated and included derived files by running: python3 -m script.hassfest.
  • New or updated dependencies have been added to requirements_all.txt.
    Updated by running python3 -m script.gen_requirements_all.
  • For the updated dependencies a diff between library versions and ideally a link to the changelog/release notes is added to the PR description.

To help with the load of incoming pull requests:

We hand radio stations to HA as the music class because HA has none for
radio, and that same class was read back as radio when searching. A voice
assistant picks music for any plain play request, so those searched radio
only and silently found nothing.
@home-assistant home-assistant Bot added bugfix cla-signed has-tests integration: music_assistant small-pr PRs with less than 30 lines. Top 100 Integration is ranked within the top 100 by usage Top 200 Integration is ranked within the top 200 by usage labels Jul 30, 2026
@home-assistant

Copy link
Copy Markdown
Contributor

Hey there @music-assistant, @arturpragacz, mind taking a look at this pull request as it has been labeled with an integration (music_assistant) you are listed as a code owner for? Thanks!

Code owner commands

Code owners of music_assistant can trigger bot actions by commenting:

  • @home-assistant close Closes the pull request.
  • @home-assistant mark-draft Mark the pull request as draft.
  • @home-assistant ready-for-review Remove the draft status from the pull request.
  • @home-assistant rename Awesome new title Renames the pull request.
  • @home-assistant reopen Reopen the pull request.
  • @home-assistant unassign music_assistant Removes the current integration label and assignees on the pull request, add the integration domain after the command.
  • @home-assistant update-branch Update the pull request branch with the base branch.
  • @home-assistant add-label needs-more-information Add a label (needs-more-information, problem in dependency, problem in custom component, problem in config, problem in device, feature-request) to the pull request.
  • @home-assistant remove-label needs-more-information Remove a label (needs-more-information, problem in dependency, problem in custom component, problem in config, problem in device, feature-request) on the pull request.

@zweckj zweckj added this to the 2026.8.0 milestone Jul 31, 2026
@zweckj
zweckj merged commit 3571d9b into dev Jul 31, 2026
33 checks passed
@zweckj
zweckj deleted the music-assistant-music-class-search branch July 31, 2026 04:23
Comment on lines +91 to +93
# music is the class a voice assistant picks for a plain "play something"
# request, so it has to mean music rather than the radio stations we
# happen to hand back to HA under the same class

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
# music is the class a voice assistant picks for a plain "play something"
# request, so it has to mean music rather than the radio stations we
# happen to hand back to HA under the same class

This comment isn't true.

Our own Assist for example never does it. Maybe some overzealous LLMs incorrectly add it?

Also as a sidenote: we could consider mapping radio channels to MediaClass.CHANNEL instead.

Comment on lines +575 to +578

A voice assistant sends this class for a plain "play something" request,
and we hand radio stations back to HA under the same class, which is why
it used to end up searching radio only.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
A voice assistant sends this class for a plain "play something" request,
and we hand radio stations back to HA under the same class, which is why
it used to end up searching radio only.

Same as above.

@github-actions github-actions Bot locked and limited conversation to collaborators Aug 1, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

bugfix cherry-picked cla-signed has-tests integration: music_assistant Quality Scale: bronze small-pr PRs with less than 30 lines. Top 100 Integration is ranked within the top 100 by usage Top 200 Integration is ranked within the top 200 by usage

Projects

None yet

Development

Successfully merging this pull request may close these issues.

HassMediaSearchAndPlay with media_class: music plays nothing - Music Assistant maps MediaClass.MUSIC to RADIO

4 participants