Sonos request

It’s supported on webcore and would be a great custom command.

Track request in Sonos that returns all the track data and URI.

You can then use this data to build out playlists that operate within RM.

Is it possible to display cover artwork in Dashboard, and if not would this help ?

So within Sonos, there used to be a way to access the track data URI by logging into the SONOS through the local ip at port 1400.

Sonos removed this access towards the end of last year... however, WEBCORE had a way to return track URI as a variable so you could, for instance, queue up your favorite Songs Playlist, Pandora Station or Apple Playlist and it would display as a URI.

This would allow a user to develop an automation to say, play classical music radio when motion detected. This seems simplistic but if you have announcements through Sonos you need a method to get back to your playlist. So currently...

  1. You create a songs rule to play music on motion (you set the station through the SOnos app);
  2. You also have an automation that plays TTS "Door Open" when a door is opened. Once this automation triggers, your music station is effectively replaced.
  3. Next time you have motion in the room TTS will play and not your station.

HOWEVER

If your automation permitted you to run a custom command playTrack() with the track URI you would always have music on motion and the TTS would effectively be pushed out of queue (yes I've used queue twice in the same post).

@JDogg016
Have you tried our sonos integration?, TTS sent via speak or playTextAndRestore automatically do this, also in the latest release I enabled trackData events.

Unfortunatly the track metadata from sonos is only a query string parameter to the artwork, not a full url.

While resume works, let’s use a different example. Play classical radio on Motion. I set the station in Sonos and leave it alone but then I change the music for a party. Now I have to remember to change it back.

I don't understand the issue, are you having a problem with our sonos implementation?, is there something you're expecting it to do that it isn't?
What commands are you expecting this driver to have, and via what use case are you expecting to use them?

Even using the sonos app itself you have have to remember to change the source back, and how much fun was ST's implementation?

If you're poking the url of your classical radio station into play track from rm or core, why do you need to change anything back?

I can't tell if you're explaining or complaining.

Explaining.

There is a command in webcore that returns the uri of the playlist/station/track playing on the Sonos.

I just want to know whether it is possible to enable that custom command within the HE Sonos integration.

See this link

You don't need a custom command to fetch this, trackData is an event that any app can subscribe to.
It's part of the media player capability, so an app can subscribe to trackData, just like it would subscribe to switch...
Our integration provides this, why ST removed this is unknown.

Ok.

  1. Where do I subscribe to it because I do not see it.

  2. After subscribing and assuming I can grab the URI. How do I use this as a command to set the track?

I don't use core, so I'm not aware of how and or what options it has available for Music Player devices.
If it was changed to support some sort of custom command as a workaround for ST removing the trackData event from the sonos driver, then core will need to be modified to properly support capability Music Player

in general, you would take selected Media Player devices from a list, then subscribe as such:
subscribe(mediaPlayers,"trackData",myTrackDataHandler)
then:
def myTrackDataHandler(evt){
def cvs = new JsonSlurper().parseText(evt.value)
log.info "uri: ${cvs.uri}"
}

You can get the track data From the variables under the device while the track or station is playing. I use that string to set the track in RM play a specific station or tune to television.

For some reason in this example, the track data is actually listing Taylor Swift incorrectly and doesn't appear to be updating. However, the station information is correct and is updating which is what I use to control sonos on HE.

Then I use the track data in RM:

2 Likes

I should have thought about the logs the entire time, but ST didn't really offer this.

Because of this, one can easily obtain a radio station, playlist, song, album (or whatever) and trigger it to an automation.

This includes Apple Music stuff.

It works great for stations, songs etc. I think there may have been an issue on the sonos side yesterday when I responded to you. Today, all my sonos logs are working perfectly and I didn't touch anything on Hubitat. It's been bugging me it was showing the wonky log info, but I can't get it to replicate problem today so that's a good thing.

@mike.maxwell , I recently decided to give up using Echo Speak and other third party TTS drivers / apps due to their inherent instability and got a couple sonos, which work great with the built-in app.

A great feature in Echo Speak was the ability to search for music based on keywords in, for example, Apple Music.

Is there a way to automate this in the same way with sonos integration? Thanks in advance.

UPDATE: Actually, I don't even know where to play music on this device from hubitat... lol IF any good soul wishes to help, I'm all ears! :slight_smile:

This is not directly related to HE, but it was a really cool-guy moment for me. I went to Sonos from the Echos due the integration with HE. Today I was settling down to watch football and it dawn on me that the Connect has an audio input. 10 minutes later, I had the TV connected to the Connect and I now I'm able to stream football audio through out the entire house (7 other Sonos devices).

Now I'm trying to figure out how to set up the API so I can use a virtual button to access the Line-in.

3 Likes

I think with something plugged into line in, there is then an autoplay feature in the sonos app for the connect, not tried it but I'm thinking when this detects audio it then auto switches to line in, worth checking out anyway

Waiting for the morning games to finish before I start testing.

1 Like

Well, it’s a mixed bag. The autoplay feature works great. It will auto shift to the line in. The drag is that I can only pull audio from either an optical or a headphone jack.

It works really well for the TV if I set the sound output at fixed or pass-through. If I keep it at variable, then I can’t match the output of the TV with the streaming output. My guess is a preamp to try and boost the headphone output?

Not following this...
How is the connect wired to your equipment?