TheFes / Google-Home-Resume

Google Home Resume package for Home Assistant
38 stars 2 forks source link

Failed to cast media #10

Closed Jaykurb closed 6 months ago

Jaykurb commented 6 months ago

Hi Fes.

I have an issue where it no longer resumes after the announcement. I tried updating to the latest HA OS and Core, but the issue remains.

This appeared in my logs after using the script and listening to TuneIn radio:

Logger: homeassistant.components.cast.media_player
Source: components/cast/media_player.py:411
integration: Google Cast (documentation, issues)
First occurred: 18:22:45 (2 occurrences)
Last logged: 18:22:45

Failed to cast media https://tunein-ondemand.cdnstream1.com/bump_sonic_pre.mp3/;?aw_0_1st.playerid=NVok3txQ&aw_0_1st.skey=1713201760&aw_0_1st.bundleId=tunein.player&aw_0_1st.abtest=&partnerId=NVok3txQ&aw_0_1st.stationId=s7622&aw_0_1st.premium=false&source=TuneIn&aw_0_1st.platform=tunein&aw_0_1st.genre_id=g4150&aw_0_1st.class=music&aw_0_1st.ads_partner_alias=ce.GoogleHome&aw_0_azn.planguage=en. Please make sure the URL is: Reachable from the cast device and either a pu
[trace script.google_home_resume 2024-04-15T17_19_01.683505+00_00.json](https://github.com/TheFes/Google-Home-Resume/files/14982459/trace.script.google_home_resume.2024-04-15T17_19_01.683505%2B00_00.json)
[trace script.google_home_resume_helper 2024-04-15T17_19_03.846669+00_00.json](https://github.com/TheFes/Google-Home-Resume/files/14982460/trace.script.google_home_resume_helper.2024-04-15T17_19_03.846669%2B00_00.json)
blicly resolvable hostname or an IP address

and this error appeared when using the script and listening to spotify:

Logger: homeassistant.components.websocket_api.http.connection
Source: components/websocket_api/commands.py:239
integration: Home Assistant WebSocket API (documentation, issues)
First occurred: 18:29:49 (2 occurrences)
Last logged: 18:33:07

[140271158148416] CastMediaPlayerEntity.media_stop Failed: Execution of stop timed out after 10.0 s.
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/cast/media_player.py", line 106, in wrapper
    return_value = func(self, *args, **kwargs)
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/cast/media_player.py", line 576, in media_stop
    media_controller.stop()
  File "/usr/local/lib/python3.12/site-packages/pychromecast/controllers/media.py", line 642, in stop
    response_handler.wait_response()
  File "/usr/local/lib/python3.12/site-packages/pychromecast/response_handler.py", line 54, in wait_response
    raise RequestTimeout(self._request, self._timeout)
pychromecast.error.RequestTimeout: Execution of stop timed out after 10.0 s.

The above exception was the direct cause of the following 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 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/script/__init__.py", line 672, in _service_handler
    response = await self._async_start_run(
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/script/__init__.py", line 630, in _async_start_run
    script_result = await coro
                    ^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/script/__init__.py", line 661, in _async_run
    return await self.script.async_run(script_vars, context)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  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/script/__init__.py", line 672, in _service_handler
    response = await self._async_start_run(
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/script/__init__.py", line 630, in _async_start_run
    script_result = await coro
                    ^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/script/__init__.py", line 661, in _async_run
    return await self.script.async_run(script_vars, context)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  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/trace.py", line 284, in async_wrapper
    await func(*args)
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 906, in _async_repeat_step
    await async_run_sequence(iteration, extra_msg)
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 857, in async_run_sequence
    await self._async_run_script(script)
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 1202, in _async_run_script
    result = 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/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/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 "/usr/src/homeassistant/homeassistant/components/media_player/__init__.py", line 838, in async_media_stop
    await self.hass.async_add_executor_job(self.media_stop)
  File "/usr/local/lib/python3.12/concurrent/futures/thread.py", line 58, in run
    result = self.fn(*self.args, **self.kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/cast/media_player.py", line 108, in wrapper
    raise HomeAssistantError(
homeassistant.exceptions.HomeAssistantError: CastMediaPlayerEntity.media_stop Failed: Execution of stop timed out after 10.0 s.

Strangely, the announcement does not work at all while Spotify is playing, but it does while TuneIn is playing or no music.

I have attached my traces; if you could take a look, please

Jaykurb commented 6 months ago

trace script.google_home_resume 2024-04-15T17_19_01.683505+00_00.json trace script.google_home_resume_helper 2024-04-15T17_19_03.846669+00_00.json

TheFes commented 6 months ago

Duplicate of #8

Jaykurb commented 6 months ago

Hi, I used the workaround from https://github.com/TheFes/Google-Home-Resume/issues/8#issuecomment-2048201567 and that has removed the error posted above but it still isn't working for me.

The errors I get now are these two:

Error executing service: <ServiceCall media_player.play_media (c:01HVNNEDJCXCJNKAE7FDF34EVM): entity_id=['media_player.main_bedroom_speaker', 'media_player.kitchen_display', 'media_player.grace_bedroom_speaker', 'media_player.living_room_speaker'], extra=, media_type=music, media_id=media-source://tts/cloud?message=Jake,+you+have+0+unread+mail> Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/core.py", line 2559, in _run_service_call_catch_exceptions await coro_or_task 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 996, in entity_service_call raise result from None File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1580, in async_request_call return await coro ^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 1043, in _handle_entity_call result = await task ^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/components/cast/media_player.py", line 783, in async_play_media await self.hass.async_add_executor_job( File "/usr/local/lib/python3.12/concurrent/futures/thread.py", line 58, in run result = self.fn(*self.args, **self.kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/components/cast/media_player.py", line 108, in wrapper raise HomeAssistantError( homeassistant.exceptions.HomeAssistantError: CastMediaPlayerEntity._quick_play Failed: Execution of quick play https://9k674cjhyf6ekjmurine9y95rl4i0mfi.ui.nabu.casa/api/tts_proxy/f6dd826adec46a4e87d43a0c72db6410cf1ee96b_en-ie_6e8b81ac47_cloud.mp3 timed out after 30.0 s.

- Error 2 - 

Logger: homeassistant.components.cast.media_player Source: components/cast/media_player.py:411 integration: Google Cast (documentation, issues) First occurred: 10:14:32 (2 occurrences) Last logged: 10:14:32

Failed to cast media https://tunein-ondemand.cdnstream1.com/bump_sonic_pre.mp3/;?aw_0_1st.playerid=NVok3txQ&aw_0_1st.skey=1713345267&aw_0_1st.bundleId=tunein.player&aw_0_1st.abtest=&partnerId=NVok3txQ&aw_0_1st.stationId=s17569&aw_0_1st.premium=false&source=TuneIn&aw_0_1st.platform=tunein&aw_0_1st.genre_id=g3125&aw_0_1st.class=talk&aw_0_1st.ads_partner_alias=ce.GoogleHome&aw_0_azn.planguage=en. Please make sure the URL is: Reachable from the cast device and either a publicly resolvable hostname or an IP address



I don't know if this is script related or a media player integration like issue [#8](https://github.com/TheFes/Google-Home-Resume/issues/8). Appologies if it is not script related.