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.25k stars 45 forks source link

TTS announcments on sonos group #2081

Closed lafriks closed 3 months ago

lafriks commented 3 months ago

What version of Music Assistant has the issue?

2.0.0b129

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

2024.3.3

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

The problem

When calling TTS say service and as media player specifying sonos group created in MA UI error is shown and nothing is played on speakers

How to reproduce

Create SONOS speaker group Call TTS say service in HA and specify group media player

Music Providers

Home assistant TTS say service

Player Providers

Tried both SONOS and universal group

Full log output

2024-04-01 15:12:35.582 INFO (MainThread) [music_assistant.players] Playback announcement to player All rooms (with pre-announce: None): http://10.X.X.X:8123/api/tts_proxy/32d4d9e071d3bc1ba41d5d22e7c5cf55b631a7c7_lv-lv-everitaneural_-_edge_tts.mp3 2024-04-01 15:12:35.582 ERROR (MainThread) [music_assistant.webserver] Error handling message: players/cmd/play_announcement: 'syncgroup_c9lsrpgy' 2024-04-01 15:15:50.908 ERROR (MainThread) [music_assistant.webserver] Error handling message: players/queue/play: Player Main room can not accept play_media command, it is synced to another player.

Additional information

HA errors:

Logger: homeassistant.components.websocket_api.http.connection Source: custom_components/mass/media_player.py:485 integration: Home Assistant WebSocket API (documentation, issues) First occurred: 12:40:14 (5 occurrences) Last logged: 18:12:35 [281472395703360] Error handling message: Unknown error (unknown_error) User from 10.X.X.X (Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:124.0) Gecko/20100101 Firefox/124.0) [281472252015552] Error handling message: Unknown error (unknown_error) User from 10.X.X.X (Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:124.0) Gecko/20100101 Firefox/124.0) Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/components/websocket_api/decorators.py", line 26, in _handle_async_response await func(hass, connection, msg) File "/usr/src/homeassistant/homeassistant/components/websocket_api/commands.py", line 795, in handle_execute_script script_result = await script_obj.async_run( ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 1600, in async_run return await asyncio.shield(run.async_run()) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 435, in async_run await self._async_step(log_exceptions=False) File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 487, in _async_step self._handle_exception( File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 512, in _handle_exception raise exception File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 485, in _async_step await getattr(self, handler)() File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 723, in _async_call_service_step response_data = await self._async_run_long_action( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 685, in _async_run_long_action return long_task.result() ^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/core.py", line 2319, in async_call response_data = await coro ^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/core.py", line 2356, in _execute_service return await target(service_call) ^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/components/tts/legacy.py", line 148, in async_say_handle await hass.services.async_call( File "/usr/src/homeassistant/homeassistant/core.py", line 2319, in async_call response_data = await coro ^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/core.py", line 2356, in _execute_service return await target(service_call) ^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 905, in entity_service_call single_response = await _handle_entity_call( ^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 975, in _handle_entity_call result = await task ^^^^^^^^^^ File "/config/custom_components/mass/media_player.py", line 438, in async_play_media await self._async_play_media_advanced( File "/config/custom_components/mass/media_player.py", line 485, in _async_play_media_advanced await self.mass.players.play_announcement( File "/usr/local/lib/python3.12/site-packages/music_assistant/client/players.py", line 132, in play_announcement await self.client.send_command( File "/usr/local/lib/python3.12/site-packages/music_assistant/client/client.py", line 174, in send_command return await future ^^^^^^^^^^^^ music_assistant.common.models.errors.MusicAssistantError: 'syncgroup_j7u3aqp4'

and

Logger: homeassistant.helpers.script.websocket_api_script Source: helpers/script.py:485 First occurred: 12:40:14 (5 occurrences) Last logged: 18:12:35 websocket_api script: Error executing script. Unexpected error for call_service at pos 1: 'syncgroup_j7u3aqp4' websocket_api script: Error executing script. Unexpected error for call_service at pos 1: Player syncgroup_j7u3aqp4 is not available websocket_api script: Error executing script. Unexpected error for call_service at pos 1: 'syncgroup_c9lsrpgy' Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 485, in _async_step await getattr(self, handler)() File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 723, in _async_call_service_step response_data = await self._async_run_long_action( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 685, in _async_run_long_action return long_task.result() ^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/core.py", line 2319, in async_call response_data = await coro ^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/core.py", line 2356, in _execute_service return await target(service_call) ^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/components/tts/legacy.py", line 148, in async_say_handle await hass.services.async_call( File "/usr/src/homeassistant/homeassistant/core.py", line 2319, in async_call response_data = await coro ^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/core.py", line 2356, in _execute_service return await target(service_call) ^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 905, in entity_service_call single_response = await _handle_entity_call( ^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 975, in _handle_entity_call result = await task ^^^^^^^^^^ File "/config/custom_components/mass/media_player.py", line 438, in async_play_media await self._async_play_media_advanced( File "/config/custom_components/mass/media_player.py", line 485, in _async_play_media_advanced await self.mass.players.play_announcement( File "/usr/local/lib/python3.12/site-packages/music_assistant/client/players.py", line 132, in play_announcement await self.client.send_command( File "/usr/local/lib/python3.12/site-packages/music_assistant/client/client.py", line 174, in send_command return await future ^^^^^^^^^^^^ music_assistant.common.models.errors.MusicAssistantError: 'syncgroup_j7u3aqp4'

What version of Home Assistant Core are your running

2024.03.1

What type of installation are you running?

Home Assistant OS

On what type of hardware are you running?

ODROID

HA-TB303 commented 3 months ago

Same issue here, but for me nothing works on a sonos group created in MA.

OzGav commented 3 months ago

This should be fixed in b130. Advise if not and we can reopen

HA-TB303 commented 3 months ago

I have tried testing this, but no luck. I can not even get my sonos speakers enabled and working. They are found as an airplay device, but not as a sonos device.

CleanShot 2024-04-07 at 19 32 37

HA-TB303 commented 3 months ago

If I reboot the devices they work (most of the time) but then If I update or restart the system running HA and MASS, the same issue repeats itself.

Then tested the announcement on all downstairs speakers, of which one was offline and this did not work at all:

2024-04-07 19:50:48.194 INFO (MainThread) [music_assistant.players] Playback announcement to player Kantoor (with pre-announce: False): http://192.168.207.101:8123/api/tts_proxy/77af72a57f38ac0df3a439f13e895b6da576dad1_nl-nl_6e8b81ac47_cloud.mp3
2024-04-07 19:50:48.194 DEBUG (MainThread) [sonos_websocket.websocket] Opening websocket to wss://192.168.207.243:1443/websocket/api
2024-04-07 19:50:48.194 ERROR (MainThread) [music_assistant.webserver] Error handling message: players/cmd/play_announcement: unhandled errors in a TaskGroup (2 sub-exceptions)
2024-04-07 19:50:52.576 WARNING (MainThread) [music_assistant.players] Detected announcement request to an inactive playergroup, this will be redirected to the individual players.
2024-04-07 19:50:52.576 INFO (MainThread) [music_assistant.players] Playback announcement to player Kantoor (with pre-announce: False): http://192.168.207.101:8123/api/tts_proxy/77af72a57f38ac0df3a439f13e895b6da576dad1_nl-nl_6e8b81ac47_cloud.mp3
2024-04-07 19:50:52.576 DEBUG (MainThread) [sonos_websocket.websocket] Opening websocket to wss://192.168.207.243:1443/websocket/api
2024-04-07 19:50:52.576 ERROR (MainThread) [music_assistant.webserver] Error handling message: players/cmd/play_announcement: unhandled errors in a TaskGroup (2 sub-exceptions)
2024-04-07 19:51:01.214 WARNING (MainThread) [music_assistant.players] Detected announcement request to an inactive playergroup, this will be redirected to the individual players.
2024-04-07 19:51:01.214 INFO (MainThread) [music_assistant.players] Playback announcement to player Kantoor (with pre-announce: False): http://192.168.207.101:8123/api/tts_proxy/77af72a57f38ac0df3a439f13e895b6da576dad1_nl-nl_6e8b81ac47_cloud.mp3
2024-04-07 19:51:01.214 DEBUG (MainThread) [sonos_websocket.websocket] Opening websocket to wss://192.168.207.243:1443/websocket/api
2024-04-07 19:51:01.214 ERROR (MainThread) [music_assistant.webserver] Error handling message: players/cmd/play_announcement: unhandled errors in a TaskGroup (2 sub-exceptions)
2024-04-07 19:51:25.709 WARNING (MainThread) [music_assistant.players] Detected announcement request to an inactive playergroup, this will be redirected to the individual players.
2024-04-07 19:51:25.709 INFO (MainThread) [music_assistant.players] Playback announcement to player Kantoor (with pre-announce: False): http://192.168.207.101:8123/api/tts_proxy/aa9609a82e51cdbc0f55aee98c12f96707b8e8d5_nl-nl-coletteneural_-_edge_tts.mp3
2024-04-07 19:51:25.709 DEBUG (MainThread) [sonos_websocket.websocket] Opening websocket to wss://192.168.207.243:1443/websocket/api
2024-04-07 19:51:25.710 ERROR (MainThread) [music_assistant.webserver] Error handling message: players/cmd/play_announcement: unhandled errors in a TaskGroup (2 sub-exceptions)

I tried multiple tts services with the same result.

HA-TB303 commented 3 months ago

If I try this on a group that only contains online speakers it now works and it works well, but this is pretty much unusable as there will be no guaranty that all spreakers will be alway online ( I also have battery powered sonos devices)

OzGav commented 3 months ago

@HA-TB303 you are adding to a closed issue. It is a fluke we noticed this. Please open a Q&A discussion or an issue if you think something is actually broken. I can't tell what the problem is from what you ahve posted above, Make sure you review all our docs especially the troubleshooting page.

HA-TB303 commented 3 months ago

@OzGav you would be right, if you would have granted us time to confirm the issue is resoved.... You closed without any confirmation and then said yourself you would re-open this ticket if not resolved....

This should be fixed in b130. Advise if not and we can reopen

So what do you want me to do? You want me to open A identical new ticket, or re-open this one as the problem is not resolved yet?

lafriks commented 3 months ago

I think your issue might be a different one as for me at least announcements do work on Sonos group

HA-TB303 commented 3 months ago

I don't know. I'm not doing anything special...

Create a sonos group: CleanShot 2024-04-14 at 14 45 10

Check if it exists: CleanShot 2024-04-14 at 14 46 03

tts to it: CleanShot 2024-04-14 at 14 46 35

Result:

Logger: homeassistant.components.websocket_api.http.connection
Bron: custom_components/mass/media_player.py:485
integratie: Home Assistant WebSocket API (documentatie, problemen)
Eerst voorgekomen: 14:43:37 (2 gebeurtenissen)
Laatst gelogd: 14:46:32

[139944312487744] Error handling message: Unknown error (unknown_error) Michel from 192.168.207.5 (Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/122.0.0.0 Safari/537.36 Edg/122.0.0.0)
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/websocket_api/decorators.py", line 27, in _handle_async_response
    await func(hass, connection, msg)
  File "/usr/src/homeassistant/homeassistant/components/websocket_api/commands.py", line 794, in handle_execute_script
    script_result = await script_obj.async_run(
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 1713, in async_run
    return await asyncio.shield(create_eager_task(run.async_run()))
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 457, in async_run
    await self._async_step(log_exceptions=False)
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 509, in _async_step
    self._handle_exception(
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 539, in _handle_exception
    raise exception
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 507, in _async_step
    await getattr(self, handler)()
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 736, in _async_call_service_step
    response_data = await self._async_run_long_action(
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 699, in _async_run_long_action
    return await long_task
           ^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/core.py", line 2543, in async_call
    response_data = await coro
                    ^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/core.py", line 2580, in _execute_service
    return await target(service_call)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/tts/legacy.py", line 159, in async_say_handle
    await hass.services.async_call(
  File "/usr/src/homeassistant/homeassistant/core.py", line 2543, in async_call
    response_data = await coro
                    ^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/core.py", line 2580, in _execute_service
    return await target(service_call)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 971, in entity_service_call
    single_response = await _handle_entity_call(
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 1043, in _handle_entity_call
    result = await task
             ^^^^^^^^^^
  File "/config/custom_components/mass/media_player.py", line 438, in async_play_media
    await self._async_play_media_advanced(
  File "/config/custom_components/mass/media_player.py", line 485, in _async_play_media_advanced
    await self.mass.players.play_announcement(
  File "/usr/local/lib/python3.12/site-packages/music_assistant/client/players.py", line 132, in play_announcement
    await self.client.send_command(
  File "/usr/local/lib/python3.12/site-packages/music_assistant/client/client.py", line 174, in send_command
    return await future
           ^^^^^^^^^^^^
music_assistant.common.models.errors.MusicAssistantError: unhandled errors in a TaskGroup (1 sub-exception)
HA-TB303 commented 3 months ago

New issue: https://github.com/music-assistant/hass-music-assistant/issues/2122****