Automation: set Sonos favourite

Hello
I am new to HA, migrating from FHEM. After implementing the most important devices I am starting now to implement a few automations. One is a simple one but I am not able to find the according configuration.

Every day at 2.30 AM I would like HA to set my favourite radio station at the device sonos Bad. The trigger is easy. But how do I set a favourite without playing it?

Thanks for your help.

Br tom

What is the reason for setting it at that time without also playing it? Could you not just set it at whatever time you intend to play it?

You could also toy with the idea of an automation that sets it, sets the volume to zero and plays for a few seconds before stopping, thus leaving it on that station.

@OvalZyre Thanks for your answer.

In the morning I start the media player by pressing a push-button (enocean) in the bath (media_player.play_media). It takes approx 3 seconds to start the media player with the last chosen radio station. If I add to the automation of media_player.play_media also the favourite favorite_item_id then it takes 5-6 seconds to start the radio… I know this is not a big deal but once I know the difference I cant unsee it :wink: So whatever I listen in the evening I would like to change the favourite at 2.30 AM (at this time no more guests in my home ;). to be prepared in the morning and wait only 3 seconds :wink:

Is this understandable?

could be a solution, but more than a workaround. Is it not possible to set the favourite to sonos without playing?

Were you able to set the favorite radio station, without playing it, using FHEM?

Hey @123 , yes I was… pretty simple

*02:30 set Sonos_Bad LoadFavourite /SRF.3/

I’m guessing that FHEM is using this Sonos API call:

I don’t believe Home Assistant’s Sonos integration exposes that API call (as a service call).

You can create a Feature Request, asking to enhance the Sonos integration so it supports that feature (and hope the author of the Sonos integration, or other volunteer software developer, implements it), or you can attempt to execute loadFavorite directly via an HTTP request.

I would suggest trying to execute the loadFavorite HTTP request. Sonos API documentation includes an example using curl. In Home Assistant, you can execute HTTP requests using the RESTful Command integration.

1 Like

@123 thanks a lot. that helps. I will do both…

  • a Feature Request → Where do I have to place this request?? Github?
  • in the meantime I try the Restful Command Integration. I hope I will succeed :wink:

I may be wrong but the impression I have is that the published Sonos API is for cloud-based access to your Sonos system. That’s why there’s an authorization token required to use the API calls.

Apparently there’s an undocumented API that uses uPnP and runs locally without the need of an authorization token. I believe the Sonos integration uses that.

Anyway, I have no experience with the Sonos API (either version) so I can’t offer any tips on the best way to proceed. It’s fair to say this process will not be as easy as it was in FHEM. Hopefully jjlawren, the author of the Sonos integration, will see this topic and offer his advice.

Feature Requests are here.

@123 thanks a lot for your help and the time. I apreciate a lot .I will check if and how I will find a way.

@jjlawren since you were mentioned, do you have any advice?

@123 do you (or someone else) know if I can make a condition that asks for the favorite. My intention would be…

  • if Favorite XY is already loaded then just play
  • if Favorite XY is NOT loaded then load Favorite XY AND Play

is such kind of condition possible?

As far as I know, the Sonos integration offers an optional sensor entity that lists your favorites. Beyond that, I don’t think you can tell which one in the list is “loaded”.

I don’t believe this is currently possible with the underlying library, which uses the UPnP/SOAP API. Are you aware of a way to perform this action using a native Sonos app? This would make it easier to discover if possible.