home-assistant / core

:house_with_garden: Open source home automation that puts local control and privacy first.
https://www.home-assistant.io
Apache License 2.0
73.16k stars 30.57k forks source link

Timeout on commands issued #113918

Open Ties42 opened 7 months ago

Ties42 commented 7 months ago

The problem

I call the media_player.media_play_pause service on a chromecast media player as part of a script. The commands return as timed out. The media_player does complete the first command (media_play_pause) but the rest of the script (seek + media_play_pause again to resume) does not complete. The media stays in pause status.

What version of Home Assistant Core has the issue?

core-2024.3.1

What was the last working version of Home Assistant Core?

core-2024.2.5

What type of installation are you running?

Home Assistant Container

Integration causing the issue

Home Assistant WebSocket API

Link to integration documentation on our website

https://www.home-assistant.io/integrations/websocket_api

Diagnostics information

No response

Example YAML snippet

alias: Chromecast Seek
fields:
  seek_amount:
    name: Seek Amount
    description: In seconds. Can be negative.
    selector:
      text: null
sequence:
  - service: media_player.media_play_pause
    data: {}
    target:
      entity_id:
        - media_player.salon_tv
    enabled: true
  - delay:
      hours: 0
      minutes: 0
      seconds: 0
      milliseconds: 500
    enabled: true
  - service: media_player.media_seek
    data:
      seek_position: >-
        {{ state_attr("media_player.salon_tv", "media_position")|int +
        (seek_amount|default(80)|int(80)) }}
    target:
      entity_id: media_player.salon_tv
  - delay:
      hours: 0
      minutes: 0
      seconds: 0
      milliseconds: 500
  - service: media_player.media_play_pause
    data: {}
    target:
      entity_id: media_player.salon_tv
    enabled: true
mode: single
icon: mdi:fast-forward

Anything in the logs that might be useful for us?

Logger: homeassistant.components.websocket_api.http.connection
Source: components/websocket_api/commands.py:239
integration: Home Assistant WebSocket API (documentation, issues)
First occurred: 19:44:27 (3 occurrences)
Last logged: 19:44:42

[140643780336192] Execution of pause timed out after 10.0 s.
[140643780336192] Execution of play timed out after 10.0 s.
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 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/script/__init__.py", line 611, in _service_handler
    response = await self._async_start_run(
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/script/__init__.py", line 569, in _async_start_run
    script_result = await coro
                    ^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/script/__init__.py", line 600, in _async_run
    return await self.script.async_run(script_vars, context)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  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/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 "/usr/src/homeassistant/homeassistant/components/media_player/__init__.py", line 1061, in async_media_play_pause
    await self.async_media_pause()
  File "/usr/src/homeassistant/homeassistant/components/media_player/__init__.py", line 828, in async_media_pause
    await self.hass.async_add_executor_job(self.media_pause)
  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 518, in media_pause
    media_controller.pause()
  File "/usr/local/lib/python3.12/site-packages/pychromecast/controllers/media.py", line 636, in pause
    response_handler.wait_response()
  File "/usr/local/lib/python3.12/site-packages/pychromecast/response_handler.py", line 51, in wait_response
    raise RequestTimeout(self._request, self._timeout)
pychromecast.error.RequestTimeout: Execution of pause timed out after 10.0 s.

Additional information

When I encountered the error on core-2024.3.1 I reverted to core-2024.2.5 to confirm the behavior. I have no issues with the script under 2024.2.5. Went back again to core-2024.3.1 and the problem is there again.

home-assistant[bot] commented 7 months ago

Hey there @home-assistant/core, mind taking a look at this issue as it has been labeled with an integration (websocket_api) you are listed as a code owner for? Thanks!

Code owner commands Code owners of `websocket_api` can trigger bot actions by commenting: - `@home-assistant close` Closes the issue. - `@home-assistant rename Awesome new title` Renames the issue. - `@home-assistant reopen` Reopen the issue. - `@home-assistant unassign websocket_api` Removes the current integration label and assignees on the issue, add the integration domain after the command. - `@home-assistant add-label needs-more-information` Add a label (needs-more-information, problem in dependency, problem in custom component) to the issue. - `@home-assistant remove-label needs-more-information` Remove a label (needs-more-information, problem in dependency, problem in custom component) on the issue.

(message by CodeOwnersMention)


websocket_api documentation websocket_api source (message by IssueLinks)

Tahutipai commented 7 months ago

I'm seeing the same issue when calling media_player.stop service on a chromecast device

Ties42 commented 7 months ago

Found fix #113839 when checking the release notes for 2024.3.1 which seemed to fix API calls to chromecast devices. Updated my container to 2024.3.2 and unfortunately fix #113839 does not fix this issue also.

I found Issue #112644 which is similar to this problem but opened on another integration. They also report that fix #113839 does not fix their exact problem.

smarthomefamilyverrips commented 7 months ago

I'm seeing the same issue when calling media_player.stop service on a chromecast device

I also get error if I do a service call for media_player.stop from the developer dashboard for chromecast devices.

The below error show in log, I am on HA 2024.3.2

Logger: homeassistant.components.websocket_api.http.connection Source: components/websocket_api/connection.py:300 integration: Home Assistant WebSocket API (documentation, issues) First occurred: 17:39:50 (4 occurrences) Last logged: 17:42:58

[281467347526336] Error handling message: CastMediaPlayerEntity.media_stop Failed: Failed to execute stop. (home_assistant_error) Marco from 127.0.0.1 (Mozilla/5.0 (Linux; Android 14; SM-F946B Build/UP1A.231005.007; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/122.0.6261.119 Mobile Safari/537.36 Home Assistant/2024.1.5-12102 (Android 14; SM-F946B))

AND

Logger: homeassistant.helpers.script.websocket_api_script Source: helpers/script.py:1805 First occurred: 17:39:50 (4 occurrences) Last logged: 17:42:58

websocket_api script: Error executing script. Error for call_service at pos 1: CastMediaPlayerEntity.media_stop Failed: Failed to execute stop.

Tahutipai commented 7 months ago

Do you find that you no longer get the error, if you make sure the Chromecast is playing media at the same time you call stop?

On Sun, 24 Mar 2024, 11:49 sesame_madness, @.***> wrote:

I'm seeing the same issue when calling media_player.stop service on a chromecast device

I also get error if I do a service call for media_player.stop from the developer dashboard for chromecast devices.

The below error show in log, I am on HA 2024.3.2

Logger: homeassistant.components.websocket_api.http.connection Source: components/websocket_api/connection.py:300 integration: Home Assistant WebSocket API (documentation, issues) First occurred: 17:39:50 (4 occurrences) Last logged: 17:42:58

[281467347526336] Error handling message: CastMediaPlayerEntity.media_stop Failed: Failed to execute stop. (home_assistant_error) Marco from 127.0.0.1 (Mozilla/5.0 (Linux; Android 14; SM-F946B Build/UP1A.231005.007; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/122.0.6261.119 Mobile Safari/537.36 Home Assistant/2024.1.5-12102 (Android 14; SM-F946B))

AND

Logger: homeassistant.helpers.script.websocket_api_script Source: helpers/script.py:1805 First occurred: 17:39:50 (4 occurrences) Last logged: 17:42:58

websocket_api script: Error executing script. Error for call_service at pos 1: CastMediaPlayerEntity.media_stop Failed: Failed to execute stop.

— Reply to this email directly, view it on GitHub https://github.com/home-assistant/core/issues/113918#issuecomment-2016850469, or unsubscribe https://github.com/notifications/unsubscribe-auth/AFZNA4OXVTO43PRE324RGFTYZ3Y2BAVCNFSM6AAAAABFAONFBSVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDAMJWHA2TANBWHE . You are receiving this because you commented.Message ID: @.***>

smarthomefamilyverrips commented 7 months ago

Do you find that you no longer get the error, if you make sure the Chromecast is playing media at the same time you call stop? On Sun, 24 Mar 2024, 11:49 sesame_madness, @.> wrote: I'm seeing the same issue when calling media_player.stop service on a chromecast device I also get error if I do a service call for media_player.stop from the developer dashboard for chromecast devices. The below error show in log, I am on HA 2024.3.2 Logger: homeassistant.components.websocket_api.http.connection Source: components/websocket_api/connection.py:300 integration: Home Assistant WebSocket API (documentation, issues) First occurred: 17:39:50 (4 occurrences) Last logged: 17:42:58 [281467347526336] Error handling message: CastMediaPlayerEntity.media_stop Failed: Failed to execute stop. (home_assistant_error) Marco from 127.0.0.1 (Mozilla/5.0 (Linux; Android 14; SM-F946B Build/UP1A.231005.007; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/122.0.6261.119 Mobile Safari/537.36 Home Assistant/2024.1.5-12102 (Android 14; SM-F946B)) AND Logger: homeassistant.helpers.script.websocket_api_script Source: helpers/script.py:1805 First occurred: 17:39:50 (4 occurrences) Last logged: 17:42:58 websocket_api script: Error executing script. Error for call_service at pos 1: CastMediaPlayerEntity.media_stop Failed: Failed to execute stop. — Reply to this email directly, view it on GitHub <#113918 (comment)>, or unsubscribe https://github.com/notifications/unsubscribe-auth/AFZNA4OXVTO43PRE324RGFTYZ3Y2BAVCNFSM6AAAAABFAONFBSVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDAMJWHA2TANBWHE . You are receiving this because you commented.Message ID: @.>

@Tahutipai yes indeed that is exactly the behavior, if the chromecast device I make the service call media_player.stop for is playing any media (internet radio during test) I not get the error. If nothing actually is playing it throws the error I mentioned.

home-assistant[bot] commented 7 months ago

Hey there @emontnemery, mind taking a look at this issue as it has been labeled with an integration (cast) you are listed as a code owner for? Thanks!

Code owner commands Code owners of `cast` can trigger bot actions by commenting: - `@home-assistant close` Closes the issue. - `@home-assistant rename Awesome new title` Renames the issue. - `@home-assistant reopen` Reopen the issue. - `@home-assistant unassign cast` Removes the current integration label and assignees on the issue, add the integration domain after the command. - `@home-assistant add-label needs-more-information` Add a label (needs-more-information, problem in dependency, problem in custom component) to the issue. - `@home-assistant remove-label needs-more-information` Remove a label (needs-more-information, problem in dependency, problem in custom component) on the issue.

(message by CodeOwnersMention)


cast documentation cast source (message by IssueLinks)

issue-triage-workflows[bot] commented 4 months ago

There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates. Please make sure to update to the latest Home Assistant version and check if that solves the issue. Let us know if that works for you by adding a comment 👍 This issue has now been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.

smarthomefamilyverrips commented 4 months ago

Is not solved, and are several other issues with similar problems. Also no response so far from code owner(s) so no idea if the issue even is being looked at.

issue-triage-workflows[bot] commented 1 month ago

There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates. Please make sure to update to the latest Home Assistant version and check if that solves the issue. Let us know if that works for you by adding a comment 👍 This issue has now been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.

smarthomefamilyverrips commented 1 month ago

Not solved on 2024.9.2 still wide spreaded issues with media player commands but not much movement on any solutions.