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?
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.
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 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
Is this understandable?
could be a solution, but more than a workaround. Is it not possible to set the favourite to sonos without playing?
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.
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.
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.