Open collateral87 opened 8 months ago
Hey there @home-assistant/core, mind taking a look at this issue as it has been labeled with an integration (media_player
) you are listed as a code owner for? Thanks!
(message by CodeOwnersMention)
media_player documentation media_player source (message by IssueLinks)
I can confirm this issue, happens to me as well after updating to 2024.3.0. As a result all of my automations which include this command completely abort at the respective step, and subsequent commands are not executed
Same issue here. Causes many automations to fail. I see this error with both "media_player.stop" and "media_player.pause". Running 2024.3.1.
I'm also getting this error for start or pause.
It looks similar to https://github.com/home-assistant/core/issues/112601 that has been fixed but just installed 2024.3.3 and issue is still here.
I'm running it from automation that turns on scenes
- id: '1588513643289'
name: Reglage salon audio bas
entities:
media_player.marantz:
volume_level: 0.15
source: AUX:Optical In
state: 'on'
media_player.ampli:
volume_level: 0.4
state: playing
Logs
2024-03-23 00:31:37.859 ERROR (MainThread) [homeassistant.components.websocket_api.http.connection] [547492908480] CastMediaPlayerEntity.media_play Failed: Failed to execute play.
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/components/cast/media_player.py", line 105, in wrapper
return_value = func(self, *args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/components/cast/media_player.py", line 562, in media_play
media_controller.play()
File "/usr/local/lib/python3.12/site-packages/pychromecast/controllers/media.py", line 630, in play
response_handler.wait_response()
File "/usr/local/lib/python3.12/site-packages/pychromecast/response_handler.py", line 57, in wait_response
raise RequestFailed(self._request)
pychromecast.error.RequestFailed: Failed to execute play.
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 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/scene/__init__.py", line 114, in _async_activate
await self.async_activate(**kwargs)
File "/usr/src/homeassistant/homeassistant/components/homeassistant/scene.py", line 371, in async_activate
await async_reproduce_state(
File "/usr/src/homeassistant/homeassistant/helpers/state.py", line 67, in async_reproduce_state
await asyncio.gather(
File "/usr/src/homeassistant/homeassistant/helpers/state.py", line 61, in worker
await platform.async_reproduce_states(
File "/usr/src/homeassistant/homeassistant/components/media_player/reproduce_state.py", line 144, in async_reproduce_states
await asyncio.gather(
File "/usr/src/homeassistant/homeassistant/components/media_player/reproduce_state.py", line 127, in _async_reproduce_states
await call_service(SERVICE_MEDIA_PLAY, [])
File "/usr/src/homeassistant/homeassistant/components/media_player/reproduce_state.py", line 59, in call_service
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 "/usr/src/homeassistant/homeassistant/components/media_player/__init__.py", line 820, in async_media_play
await self.hass.async_add_executor_job(self.media_play)
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 107, in wrapper
raise HomeAssistantError(
homeassistant.exceptions.HomeAssistantError: CastMediaPlayerEntity.media_play Failed: Failed to execute play.
result = self.fn(*self.args, **self.kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/components/cast/media_player.py", line 107, in wrapper
raise HomeAssistantError(
homeassistant.exceptions.HomeAssistantError: CastMediaPlayerEntity.media_play Failed: Failed to execute play.
Same here for media_player.stop 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.
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!
(message by CodeOwnersMention)
cast documentation cast source (message by IssueLinks)
Same issue here. I'm seeing this with media_player.stop
and media_player.pause
and scene.create
if that scene stores data for media players.
This causes a great many automations to fail.
The error only occurs if a media_player
is in the off
state.
For now I am using wrapper scripts as a workaround for protection.
i.e a media stop script would look like (pseudocode): "if media_player.myplayer.state != 'off' then media_player.stop(myplayer)
"
The error only occurs if a
media_player
is in theoff
state.For now I am using wrapper scripts as a workaround for protection. i.e a media stop script would look like (pseudocode): "
if media_player.myplayer.state != 'off' then media_player.stop(myplayer)
"
Found out the same after digging a bit more into this, also for me error only occurs if a media_player is in off state And I am now also using the very same workaround as you did, and only send stop/pause commands to media_players which are not in off state. By doing this my automations no longer fail at this step.
Here error also occurs sometimes if not in off state.
hello there,
I might have same issue with automations not wanting to stream camera to my google nest hub where it used to work?
HomeAssistantError: CastMediaPlayerEntity._quick_play Failed: Execution of quick play https://blablabla timed out after 30.0 s.
I have same issue too when try to pause.
@emontnemery still happens in 2024.4.3
Logger: homeassistant.components.automation.house_reset_routine_new Source: helpers/script.py:1918 integration: Automation (documentation, issues) First occurred: 08:30:17 (1 occurrences) Last logged: 08:30:17
House Reset Routine New: Error executing script. Error for call_service at pos 37: CastMediaPlayerEntity.media_stop Failed: Failed to execute stop.
I concur to have the same issue. Found out the hard way after portions of my automations were not executing following a failed call to the media player service.
@emontnemery any progress on this? Still is happening that commands not are send.
Logger: homeassistant.components.websocket_api.http.connection Source: components/websocket_api/commands.py:239 integration: Home Assistant WebSocket API (documentation, issues) First occurred: 10:18:19 (8 occurrences) Last logged: 10:19:35
[281472196396480] CastMediaPlayerEntity.turn_off Failed: Failed to execute quit app. [281472196396480] CastMediaPlayerEntity.turn_off Failed: Execution of quit app 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 548, in turn_off self._get_chromecast().quit_app() File "/usr/local/lib/python3.12/site-packages/pychromecast/init.py", line 463, in quit_app response_handler.wait_response() File "/usr/local/lib/python3.12/site-packages/pychromecast/response_handler.py", line 57, in wait_response raise RequestFailed(self._request) pychromecast.error.RequestFailed: Failed to execute quit app.
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/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 798, in async_turn_off await self.hass.async_add_executor_job(self.turn_off) 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.turn_off Failed: Failed to execute quit app.
The error only occurs if a
media_player
is in theoff
state. For now I am using wrapper scripts as a workaround for protection. i.e a media stop script would look like (pseudocode): "if media_player.myplayer.state != 'off' then media_player.stop(myplayer)
"Found out the same after digging a bit more into this, also for me error only occurs if a media_player is in off state And I am now also using the very same workaround as you did, and only send stop/pause commands to media_players which are not in off state. By doing this my automations no longer fail at this step.
"if media_player.myplayer.state != 'off' then media_player.stop(myplayer)
"
where and how do you use this in the automation?
The error only occurs if a
media_player
is in theoff
state. For now I am using wrapper scripts as a workaround for protection. i.e a media stop script would look like (pseudocode): "if media_player.myplayer.state != 'off' then media_player.stop(myplayer)
"Found out the same after digging a bit more into this, also for me error only occurs if a media_player is in off state And I am now also using the very same workaround as you did, and only send stop/pause commands to media_players which are not in off state. By doing this my automations no longer fail at this step.
"
if media_player.myplayer.state != 'off' then media_player.stop(myplayer)
" where and how do you use this in the automation?
By using an if then condition inside the action part of my automation Previously I did send the turn_off command to any media player, no matter what state it had, and now I only send it to media players which are currently playing
action:
- if:
- condition: state
entity_id: media_player.wohnzimmer
state: playing
then:
- service: media_player.turn_off
metadata: {}
data: {}
target:
entity_id: media_player.wohnzimmer
The error only occurs if a
media_player
is in theoff
state. For now I am using wrapper scripts as a workaround for protection. i.e a media stop script would look like (pseudocode): "if media_player.myplayer.state != 'off' then media_player.stop(myplayer)
"Found out the same after digging a bit more into this, also for me error only occurs if a media_player is in off state And I am now also using the very same workaround as you did, and only send stop/pause commands to media_players which are not in off state. By doing this my automations no longer fail at this step.
"
if media_player.myplayer.state != 'off' then media_player.stop(myplayer)
" where and how do you use this in the automation?By using an if then condition inside the action part of my automation Previously I did send the turn_off command to any media player, no matter what state it had, and now I only send it to media players which are currently playing
action: - if: - condition: state entity_id: media_player.wohnzimmer state: playing then: - service: media_player.turn_off metadata: {} data: {} target: entity_id: media_player.wohnzimmer
Thanks , I will try it
I also encounter this issue which blocks automation using the script with this action.
Getting this as well. Only started happening in the last couple of weeks.
Occuring with a 2nd gen Chromecast. Happens even when the state of the media player is not off (i.e playing, paused etc).
Previously, calling Media Player: Stop would result in the plex content on my phone (which I use to cast to the tv) stopping as well. However now, the TV stops playing and goes back to the Plex idle screen, but the content keeps ticking along on my phone. I can see it progressing in the Plex notification.
Very odd and persists even after a reboot of the Chromecast and my phone.
Edit: similar issue presents with a Google Nest hub. Calling Media Player: Stop causes it to return to the Plex idle screen but still returns the timeout error on Home Assistant.
Also tested with Netflix, in this case no error is surfaced in Home Assistant, however the content keeps playing on the device.
Definitely something weird happening with the cast integration, multiple services across multiple devices all showing similar issues. Stop and Pause both fail however the Turn Off call seems to work fine...
Same problem here. I used to be able to turn off my google speaker even if it was already off. Now I am getting an error. The issue is that it blocks the execution of the rest of the script. Looks like a bug to me in the Cast logic.
Error executing script. Error for call_service at pos 3: CastMediaPlayerEntity.turn_off Failed: Failed to execute quit app. Error executing script. Error for call_service at pos 3: CastMediaPlayerEntity.turn_off Failed: Execution of quit app timed out after 10.0 s.
Has anyone found a solution to this? I am able to cast from my phone to Spotify to a specific speaker. Once it does that, I am able to control Play/Pause, etc. However, if the speaker is "idle", the Play button does not work.
I'm experiencing a slightly different but seemingly related issue with my Google Home Mini, if the speaker is "idle" when I call my TTS script, I get:
CastMediaPlayerEntity._quick_play Failed: Execution of quick play http://[ip]/api/tts_proxy/f53ef203fad700895355c7b2d92a0b9a6e9abcc6_en_-_google_translate.mp3 timed out after 30.0 s.
However if the state of the speaker is "off" when I call the script, it works just fine. I have tried setting the speaker's state to off before executing the TTS portion of the script but that does not resolve the issue - which I find weird.
I have a temporary workaround that kinda sucks and will only work if you trigger whatever you're trying to do via an automation in google home: I added a custom action in the actions portion of the automation, which is just the command "Stop", before it calls the script scene. It sucks because it makes the calling of the script take way longer as the speaker spends a while "stopping". I find it weird that this works but setting the state of the speaker before doing the TTS doesn't...
My server:
Core 2024.5.5 Supervisor 2024.05.1 Operating System 12.3
Hi, similar issue here, the automation for my alarm system has an issue stopping all the potential devices that are playing alarm sounds (also for grouped google nests). I created some workarounds to be able to have the script not crash (with a guard variable set from a stop script, that is being checked in controlling the looping behaviour of the sounds).
I'm on the latest version of all the software running on HA, using google cast devices (nests mini 1st and 2nd gen and the larger nest audio)
`Logger: pychromecast.controllers Source: components/cast/media_player.py:570 First occurred: 12 June 2024 at 22:03:31 (42 occurrences) Last logged: 09:19:58
STOP command requested but no session is active.`
`Logger: homeassistant.components.script.stop_alarm Source: helpers/script.py:2001 integration: Scripts (documentation, issues) First occurred: 12 June 2024 at 22:03:31 (8 occurrences) Last logged: 09:19:58
alarm stop: Error executing script. Error for call_service at pos 4: CastMediaPlayerEntity.media_stop Failed: Failed to execute stop.`
`Logger: homeassistant.helpers.script.websocket_api_script Source: helpers/script.py:2001 First occurred: 12 June 2024 at 22:06:06 (14 occurrences) Last logged: 09:19:58
websocket_api script: Error executing script. Error for call_service at pos 1: CastMediaPlayerEntity.media_stop Failed: Failed to execute stop. websocket_api script: Error executing script. Service not found for call_service at pos 1: Service script.alarm_stop not found`
to add a workaround:
for_each:
- media_player.kitchen_nest
- media_player.tvroom_sonos
- media_player.bedroom_nest
sequence:
- if:
- condition: template
value_template: "{{is_state( repeat.item , 'playing')}}"
then:
- service: media_player.media_stop
metadata: {}
data: {}
target:
entity_id: "{{ repeat.item }}"
alias: for all media players check if playing and if so stop it
@emontnemery any progress on this?
Seeing the same error now for a few months. Same as above, even when casting local media. Workarounds are not working for me. Casting the same file to a non-google speaker working fine. Can still pause/play other media on google mini from HA but casting is not working.
homeassistant | 2024-07-05 17:42:41.248 ERROR (MainThread) [homeassistant.helpers.script.websocket_api_script] websocket_api script: Error executing script. Error for call_service at pos 1: CastMediaPlayerEntity._quick_play Failed: Execution of quick play http://172.26.0.2:8123/media/local/Alarm-Fast-A1-www.fesliyanstudios.com.mp3?authSig=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJkZDhiOGNmNTc5ZDI0NDliYTc1OGIxZmEyMjdmYTU5MiIsInBhdGgiOiIvbWVkaWEvbG9jYWwvQWxhcm0tRmFzdC1BMS13d3cuZmVzbGl5YW5zdHVkaW9zLmNvbS5tcDMiLCJwYXJhbXMiOltdLCJpYXQiOjE3MjAyMTU3MzEsImV4cCI6MTcyMDMwMjEzMX0.3_FVTmgZ_-FNSXDJyQzgKXmki_3w1BJDlPJ8XaSgWkQ timed out after 30.0 s.
homeassistant | 2024-07-05 17:42:41.250 ERROR (MainThread) [homeassistant.components.websocket_api.http.connection] [547249405616] Error handling message: CastMediaPlayerEntity._quick_play Failed: Execution of quick play http://172.26.0.2:8123/media/local/Alarm-Fast-A1-www.fesliyanstudios.com.mp3?authSig=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJkZDhiOGNmNTc5ZDI0NDliYTc1OGIxZmEyMjdmYTU5MiIsInBhdGgiOiIvbWVkaWEvbG9jYWwvQWxhcm0tRmFzdC1BMS13d3cuZmVzbGl5YW5zdHVkaW9zLmNvbS5tcDMiLCJwYXJhbXMiOltdLCJpYXQiOjE3MjAyMTU3MzEsImV4cCI6MTcyMDMwMjEzMX0.3_FVTmgZ_-FNSXDJyQzgKXmki_3w1BJDlPJ8XaSgWkQ timed out after 30.0 s. (home_assistant_error) Matt from 192.168.1.126 (Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:127.0) Gecko/20100101 Firefox/127.0)
...
homeassistant | 2024-07-05 17:44:23.236 ERROR (Thread-12) [homeassistant.components.cast.media_player] Failed to cast media http://172.26.0.2:8123/media/local/Alarm-Fast-A1-www.fesliyanstudios.com.mp3?authSig=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJkZDhiOGNmNTc5ZDI0NDliYTc1OGIxZmEyMjdmYTU5MiIsInBhdGgiOiIvbWVkaWEvbG9jYWwvQWxhcm0tRmFzdC1BMS13d3cuZmVzbGl5YW5zdHVkaW9zLmNvbS5tcDMiLCJwYXJhbXMiOltdLCJpYXQiOjE3MjAyMTU3MzEsImV4cCI6MTcyMDMwMjEzMX0.3_FVTmgZ_-FNSXDJyQzgKXmki_3w1BJDlPJ8XaSgWkQ from internal_url (http://172.26.0.2:8123). Please make sure the URL is: Reachable from the cast device and either a publicly resolvable hostname or an IP address
I have the same issue when trying to Pause or change music whilst spotify is casting on my Sonos speaker
Failed to call service media_player/media_pause. Restricted device
Same issue here with the latest HA now 2024.7. The casting sometimes work and sometimes not, I counldn't figure out a pattern. It indicates the casting stopped due to timeout when automation failed in HA. However, the destination soundbar shows it is receiving casting media (but nothing plays), therefore it could be a protocol or timing issue?
Same issue here, but only when called from code (script or automation). When i call the media_play_pause from the Services tab in the Developer interface, it works.
And it only affects my Chromecast, not my Chromecast audio (!)
Has anyone checked the Google Cast version on their devices? I wonder if some of us have had an update recently (Google docs have been behind in version updates, it's not unheard of)
My Cast version for the Nest Hub Max is 3.74.419799 whereas all of the other (working devices) is 3.73.420420
Similar issue here. I get
HomeAssistantError: CastMediaPlayerEntity._quick_play Failed: Failed to execute quick play http://[ip]:[port]/api/tts_proxy/b858cb282617fb0956d960215c8e84d1ccf909c6_it_-_tts.google_it_it.mp3.
when I try to send a message for my Google Home to pronounce. It seems that the message is always dropped when the Google Home is ‘woken up’ by the message. From then on, it reads the message. For me, the workaround of sending an empty message to ‘wake up’ the Google Home worked, then sending the actual message to be spoken, even though the error message still appears.
@gpuccio87 Thanks for this idea, its saved me pulling my hair out, when is this going to be fixed? Is it even being worked on?
Actully scratch that it doesnt work for me doing what you suggested I still get the error
Error: CastMediaPlayerEntity._quick_play Failed: Failed to execute quick play http://192.168.0.49:8123/api/tts_proxy/b858cb282617fb0956d960215c8e84d1ccf909c6_en-gb_6e8b81ac47_tts.home_assistant_cloud.mp3.
on the first blank message and then the automation stops this is so annoying!!!!
@miketarg I don't know when it will be fixed, but for now this solution works for me. I use a Node-RED flow, so the first message (the empty one) is not ‘in series’ with the second, but ‘in parallel’. This prevents the error in the first message from blocking the flow. Hope this helps
I'm now using Core 2024.9.2 Supervisor 2024.09.1 Operating System 13.1 Frontend 20240909.1
The issue is resolved I have opened a ticket for this with nabu casa as it is related to service they provide and talking to Ashton in support I will keep you all posted....
On Thu, 3 Oct 2024, 17:26 gpuccio87, @.***> wrote:
@miketarg https://github.com/miketarg I don't know when it will be fixed, but for now this solution works for me. I use a Node-RED flow, so the first message (the empty one) is not ‘in series’ with the second, but ‘in parallel’. This prevents the error in the first message from blocking the flow. Hope this helps
— Reply to this email directly, view it on GitHub https://github.com/home-assistant/core/issues/112644#issuecomment-2391835050, or unsubscribe https://github.com/notifications/unsubscribe-auth/A7YJPQ64V5LKNITUO6SLHHTZZVV4BAVCNFSM6AAAAABELUR3QOVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDGOJRHAZTKMBVGA . You are receiving this because you were mentioned.Message ID: @.***>
The problem
The service media_player.media_pause on chromecast devices doesnt work.
What version of Home Assistant Core has the issue?
2024.3.0
What was the last working version of Home Assistant Core?
2024.2.0
What type of installation are you running?
Home Assistant OS
Integration causing the issue
media_player
Link to integration documentation on our website
https://www.home-assistant.io/integrations/media_player
Diagnostics information
No response
Example YAML snippet
Anything in the logs that might be useful for us?
Additional information
No response