music-assistant / hass-music-assistant

Turn your Home Assistant instance into a jukebox, hassle free streaming of your favorite media to Home Assistant media players.
Apache License 2.0
1.35k stars 52 forks source link

mass.play_media failing on radio #2188

Closed jicka closed 5 months ago

jicka commented 5 months ago

What version of Music Assistant has the issue?

2.0.0b144

What version of the Home Assistant Integration have you got installed?

2024.4.0

Have you tried everything in the Troubleshooting FAQ and reviewed the Open and Closed Issues and Discussions to resolve this yourself?

The problem

Using the mass.play_media automation, fails when trying to start a radio. The error generated is:

Invalid command: music/radio/library_items

The error only happens when using the automation to start a radio, and starting an artist, an album, a track, or a playlist works perfectly. The radio is a TuneIn provided radio.

Already tried troubleshooting steps:

The last time I tried running this automation (successfully) is maybe 2 weeks ago. I have migrated my HA from a raspberry pi to an x86 machine since. I'm running HAOS and have followed the guide for installation.

How to reproduce

  1. Create an automation that runs the following automation (code generated from the GUI):
service: mass.play_media
metadata: {}
data:
  media_type: radio
  media_id: Radio Swiss Pop
target:
  entity_id: media_player.living_room_hifi

Run the automation.

Music Providers

TuneIn: Does not work I do not have other radio providers.

Player Providers

Snapcast: Works all the time during all my tests (except when the error is generated, but I don't think it's the issue)

Full log output

Here is the log generated by me running the automation 4 times in a row, once for an artist, an album, a playlist, and finally for a radio:

2024-05-04 09:37:56.048 INFO (MainThread) [music_assistant.streams] Start Queue Flow stream for Queue living-room-hifi - crossfade: False
2024-05-04 09:38:15.331 INFO (MainThread) [music_assistant.streams] Start Queue Flow stream for Queue living-room-hifi - crossfade: False
2024-05-04 09:38:43.204 INFO (MainThread) [music_assistant.streams] Start Queue Flow stream for Queue living-room-hifi - crossfade: False
2024-05-04 09:38:54.281 WARNING (MainThread) [music_assistant.webserver] Invalid command: music/radio/library_items

Additional information

Please let me know if I can provide any more information. I have tried looking at the problem from all the angles I can think of. If I can support in any way, please let me know.

Thank you for making this wonderful piece of software.

What version of Home Assistant Core are your running

2024.5.1

What type of installation are you running?

Home Assistant OS

On what type of hardware are you running?

Generic x86-64 (e.g. Intel NUC)

sp0ngeboobs commented 5 months ago

also got this problem after the last update b144 Music provider radio stream with URL

OzGav commented 5 months ago

@sp0ngeboobs tunein as well or radio browser?

sp0ngeboobs commented 5 months ago

sorry but i don't use tunein or radio browser. I noticed that it does not work only when automation is performed with a search by the name of the radio station added to the "Radio" section in MA Example.

service: mass.play_media data: media_type: radio media_id: 1fm Deep House target: device_id: 656ba2f11ed3b4a364413936cde9ad33

But that's how it works well. service: mass.play_media data: media_type: radio media_id: https://strm112.1.fm/deephouse_mobile_mp3 target: device_id: 656ba2f11ed3b4a364413936cde9ad33

Also, Soundcloud works well with such a request service: mass.play_media data: media_id: soundcloud://playlist/1122039865 media_type: radio enqueue: replace target: device_id: 656ba2f11ed3b4a364413936cde9ad33

OzGav commented 5 months ago

@sp0ngeboobs are you using a manually added radio station?

sp0ngeboobs commented 5 months ago

@sp0ngeboobs are you using a manually added radio station? yes, that's right! I only use manually added radio stations.

jicka commented 5 months ago

I tried it with the same radio stream URL as @sp0ngeboobs :

If I can help narrow the issue further, let me know :)

jaymunro commented 5 months ago

Same issue with me:

service: mass.play_media
target:
  entity_id: media_player.front_room_speakers_mass
data:
  media_id: More FM Canterbury
  media_type: radio
Failed to call service mass/play_media. Invalid command: music/radio/library_items
Logger: homeassistant.components.websocket_api.http.connection
Source: components/websocket_api/commands.py:239
integration: Home Assistant WebSocket API (documentation, issues)
First occurred: 7:36:21 AM (14 occurrences)
Last logged: 10:55:25 AM

[281472083526336] Unexpected exception
[281472083589952] Unexpected exception
[281472098671168] Unexpected exception
[281471966229824] Unexpected exception
[281472219492800] Unexpected exception
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/websocket_api/commands.py", line 239, in handle_call_service
    response = await hass.services.async_call(
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/core.py", line 2738, in async_call
    response_data = await coro
                    ^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/core.py", line 2779, in _execute_service
    return await target(service_call)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 975, in entity_service_call
    single_response = await _handle_entity_call(
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 1047, in _handle_entity_call
    result = await task
             ^^^^^^^^^^
  File "/config/custom_components/mass/media_player.py", line 510, in _async_play_media_advanced
    if item := await self._get_item_by_name(
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/mass/media_player.py", line 561, in _get_item_by_name
    result = await func(search=searchname)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/music_assistant/client/music.py", line 341, in get_library_radios
    await self.client.send_command(
  File "/usr/local/lib/python3.12/site-packages/music_assistant/client/client.py", line 176, in send_command
    return await future
           ^^^^^^^^^^^^
music_assistant.common.models.errors.InvalidCommand: Invalid command: music/radio/library_items

The service works in b143, but not current b144

Radio is added as a favorite from TuneIn:

Screenshot 2024-05-05 at 11 01 27 AM Screenshot 2024-05-05 at 11 02 34 AM
OzGav commented 5 months ago

Fixed in the latest integration version 2024.5.0