Sonos request

@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?

Sorry about that. I can only pull audio from the optical or headphone jack of my TV. I had to use a ⅛" stereo into a 2-RCA cable to get the audio into the Connect. The Connect the outputs via RCA to a LP-2020A (2 channel 20W amp) to a pair of Event 20/20 speakers.
I usually have an old turntable plugged into the Connect and it dawned on me that there is a pre-amp to compensate for the output. I think there is an impedance mismatch. That's where I got the idea of pre-amping the headphone output (already pre-amped) of the TV. I'm sure the sound quality won't be preteen, but it's just football. I don't need to hear Zak yell Omaha in 44.1kHZ sampling rate.

Update: I just ordered an optical to RCA device!

Yeah, turntables require a phono preamp, which you would then connect to the line in on the connect.
Phone cartridges don't produce anything close to a line level signal they also require RIAA equalization prior to amplification.