I have a few Sonos players and automations to play specific media files. The automation depends on the state of the media player entity for a condition and in the action section as a wait/delay step. The media plays and the snapshot/restore services work. Sometimes the media player updates correctly and the automation completes. Other times the media player entity will immediately go to a paused state briefly then to playing. Due to a 1 second hard coded delay, this is not always an issue. However, sometimes the media player entity gets stuck in this initial paused state and never updates to playing. Then because the wait template is looking for this paused state it thinks everything has completed, but the media player is really in a stuck state. I have to manually toggle the media player to playing or call the update entity service to get it un-stuck.
Appears to have been fixed in 2021.1 or 2021.2. I’m currently on 2021.2.3 and do not have this issue anymore. I’ve even removed the update entity service call and things are working normally.
Hey is anyone having this issue anymore? I have a very similar automation to the above that has a dynamic wait until media_player reports “paused” again. I’ve been having a lot of troubles getting this to work since updating from 2021.8 to 2021.9. Sometimes the state will update if I add a long enough hardcoated delay between start of TTS service and the wait template, but today even 5s is not enough. I can find no errors related to this in the log, and the automation seems to execute successfully. The state of my Sonos media_player just doesn’t update from “paused”.
Restarts of Sonos, Home Assistant don’t solve the issue. I’ll see if I can figure out a workaround with the above mentioned update entity service.
I’m on 2021.9.7 with little or no issues. I do still occasionally get the failure to update state of the Sonos media player entity, but it’s rare now. I cannot attribute it to any one thing that causes it but it happens usually after I create a playlist in the Sonos app, play it on one speaker, group a second speaker with the first and let it play. then on the next trigger of my above clock automation, if the speaker is now paused, it fails to update the state from paused of the second speaker (the one the automation plays to). If I repeatedly manually run the automation actions, after about the 5th time the state starts updating properly again.
Good to see it’s mostly reliable elsewhere. I think I managed to solve my issue by reloading the integration (state changes happening faster than 2 seconds and reliably for a few days now). It seems that something different happens on integration reload than when restarting the home assistant server. My automations with dynamic delay all started working immediately following Sonos integration reload.
After a few days working reliably, my Sonos media_player state stopped updating again. I also tried using a ‘homeassistant.update_entity’ service call but peering into the logs reveals that’s only helping sporadically too.
Next step is to check if this is something to do with my home wifi connection reliability to Sonos. My Sonos AMP is too far away from an ethernet socket for practical use of a wired connection, but maybe that will reveal something. I still don’t really understand why reloading the Sonos integration yielded an immediate improvement, but I suppose it could just be a coincidence.
15-10-2021 update:
Bought a new router which enabled a huge signal reliability/strength boost throughout the house, as confirmed with the signal strength, transfer speeds seen at the adjacent Android TV to my Sonos Amp, and ping monitoring of the Sonos Amp itself. Unfortunately, this has yielded no obvious improvement to the reliability of state updates from the Sonos integration, and my dynamic "wait until"s are working perhaps only 50% of the time. When the state doesn’t update for a long period (many hours), the below seems to help, but I still don’t have a reliable workaround or other solution. For now I’m using “resume on timeout” in these dynamic waits so that at least Sonos will return to what it was doing previously after a TTS message, even if it takes much longer than the message itself. Where possible I’ve switched these dynamic waits over to look for a state change at the connected Anrdoid TV and this works much more reliably. Unfortunately the Android TV is only part of the equation some of the time.
I’m having literally the same issue. I either get a playing or paused state, it never switches to idle. And from what I can tell, there isn’t a stop state for Sonos either.
Has anyone found a resolution? Attempting the update_entity service also does nothing for me.
this used to work for me - I had a condition card on my dashboard and only showed the sonos media player when it was not idle. But that seemed to have broken a few months ago.