Troubleshooting: Automations crashing when trying to pause media

Info

At some point recently (I don’t know exactly when, but the past month or two?) A ton of my automations stopped working. I’ve looked into which ones, and the common thread they all have is a Media player: Pause, or Media player: Stop action. Made a quick test automation:

Which fails to run. This only dies if there is no media playing on the device when the call is made. This is happening on Google Home Devices.

A huge number of my automatons have calls like these to ensure that these is no background noise going on when certain actions are taken, or to ensure a quiet state in a room.

I have tested, and know that I can go into each automation, and add a test to see if the device is playing before sending the stop signal. However, that will require a huge amount of work to go in and update every automation.

Question

Is there a way to have all of my automations continue to run (skipping to the next step) if they hit an error, rather than stopping when they encounter an error like this?

Errors & Logs

Error:

“Failed to call service media_player/media_play. Failed to execute play.”

Log 1:

Logger: homeassistant.components.websocket_api.http.connection
Source: components/websocket_api/connection.py:300
integration: Home Assistant WebSocket API (documentation, issues)
First occurred: 06:58:27 (1 occurrences)
Last logged: 06:58:27

[546979242688] Error handling message: CastMediaPlayerEntity.media_pause Failed: Failed to execute pause. (home_assistant_error) cwhiii from fe80::c57:da32:c744:6bd7 (Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:125.0) Gecko/20100101 Firefox/125.0)

Log 2:

Logger: homeassistant.helpers.script.websocket_api_script
Source: helpers/script.py:1805
First occurred: 06:58:27 (1 occurrences)
Last logged: 06:58:27

websocket_api script: Error executing script. Error for call_service at pos 1: CastMediaPlayerEntity.media_pause Failed: Failed to execute pause.

Log 3:

Logger: pychromecast.controllers
Source: components/cast/media_player.py:568
First occurred: 06:58:27 (1 occurrences)
Last logged: 06:58:27

PAUSE command requested but no session is active.

1 Like

I’m also experiencing this and looking for a fix. Even more frustratingly, the media DOES PAUSE! However the error stops the subsequent actions from completing.

3 Likes

Anyone find a fix for this? I’m getting the same error, but with media_stop

1 Like

There is a bug report in the Github repo: media_player.media_pause on chromecast devices doesnt work · Issue #112644 · home-assistant/core · GitHub

A workaround seems to be to wrap the calls with an if:

if media_player.myplayer.state != 'off' then media_player.stop(myplayer)
1 Like

Thanks! I appreciate the info.