Squeezebox (Logitech Media Server) Control for Smartthings

Version 2.0 has been upload to GIthub. This is the change to the LMS JSON interface. Both the Server and Player Device Handlers are updated. No changes to the Button manager smartapp.

There is no need to reinstall devices, just update and publish the new versions.

If you are using the preset buttons, they need to be changed to the JSON format. Documentation has been updated to reflect this. For example, p0=playlist&p1=play&p2=Morning%20Mix, is now “playlist”,“play”,“Morning Mix”.

The new interface removes the requirement that LMS be set to English.

Power button and on() and off() commands have been added to players.

Volume reports full range of 0-100.

Temporary playlist saved used for announcements is now deleted after the announcement completes.

Additional voices to support additional languages for speech have been added to the player settings. I have not tested all of them.

This was a big rewrite, and I have attempted to test, but expect you may still find issues. Feedback is encouraged.

I now consider this project fairly complete, unless I decide to try to write a player install helper smartapp. Additional functionality will be based on finding new needs, and requests that sound interesting.

For those of you that do coding, this code is parent-child device handlers that receive responses back from the server using Hubaction with a JSON body. I also had to put together two different methods to handle sequential server commands, the difference being how responses are handled. While it made my head hurt, it’s been fun.

Hope you find this useful.

Thanks for the great DHs for Logitech Media Server. I’m totally new to LM so it took me a bit running around to figure it out and the plugins. The chromecast plugins is what sold me to use the google home/mini for voice announcements.

Not working yet but unfortunately but I’m trying to figure it out. When entering the MAC, do you need to separate with ‘:’ or just the number all together?

The LM server does show my google home devices however it is not found in smartthings squeezebox server device I created. still debugging

Include the colons in MAC addresses. Good luck with your setup.

Your google devices will show up as separate devices in Smartthings once installed, and the server you created will show the number of players installed in Smartthings.

Thanks! I’ll try it again. What triggers it to install new players? Only when you modify the network id? Or when you modify the preferences and MAC IDs?

I’m trying to figure out if I did the steps wrong or if I need to start from scratch and delete the device and create a new one.

Ok, found my bug. fat fingers and a typo on one of the addresses. Fixed it and created a new device, looks like this:

currentActivity: Logitech Media Server at 192.168.86.31:9000 C0A8561F:2328
buildingPlayer: 1

No devices yet but I’m hoping it just takes time? I can see the devices on Logitech Media Server page though.

Player install is triggered by saving the server device settings/preferences. Any MAC addresses entered will attempt to be installed. Live logging will show activity. Buildplayer(I think, sorry away from computer) attribute, viewable in IDE, should be at 5 once complete, otherwise you have a communication failure with LMS, usually bad network address or port/firewall issues.

Hope this helps, unfortunately I’m going to be unreachable for the rest of today.

Yes! finally got it to work. Rookie LM mistake. I was using the actual MAC addresses of the devices and not the Player MAC Address found on the LM Server :frowning:

Now they are all found. Thanks so much and enjoy your time off?

anybody got a hosted mp3 to play with the Squeezebox Logitech Media Server through something like BigTalk or WebCore?

I’ll answer myself. It’s not an issue with Squeezebox(LM). It’s a weird issue when you set the volume in BigTalk or WebCore. Setting the volume will make it fail in some cases. Thought it was a Sonos only problem but apparently it fails with this too. Best to leave no value in the volume for WebCore or BigTalk I guess for now. (or set it separately)

I have used this with Big Talker 2, as both speech synthesis and a music player, but am providing a phrase, not a file.

What commands are you using in Webcore? The play with resume and restore commands allow you to pass a volume to the server, see README.

I don’t use Sonos, but the LMS Chromecast plugin, by default, only changes volume if LMS is controlling play. You can change this behavior on LMS.

I use the play track command in webCore with a mp3 URL link. Works great as long as you don’t set a volume value with it. Not just Sonos but other devices such as an android with Squeeze player. Not sure why setting a value in the volume breaks it but I’ll keep messing around with it.

If you are using playTrack(track, volume), the command is not set up to accept the volume parameter. Maybe it should be. Right now a separate setLevel(volume) is needed. In looking around there is a new capability that has that definition. I will look into next time I work on an update.

1 Like

Ah ok, makes sense. The setLevel works. Avoiding the adjustLevel since that doesn’t work.

HI,

This is really awesome! Is there a way to call a spotify playlist from a Preset? I’ve tried various combinations without success.

“playlist”,“play”,“spotify://code from spotify playlist”

“playlist”,“play”,“https://open.spotify.com/user/?si=code from spotify playlist"

“playlist”,“play”,“spotify:user:codes from spotify playlist:playlist:spotify playlist code")

Thanks,
Rod

Not a Spotify user, so can’t help with specifics there, but here are some suggestions.

First, I am assuming you have the Spotify plugin enabled and can navigate to the desired playlist through the web interface or other LMS control. If not, you are going to need it to do the heavy lifting for you, but, since I don’t use it, can’t help you with it.

The method you were trying “playlist”,“play”,“path”, requires the path to be something LMS can navigate to. Spotify probably uses an API that makes creating the address tricky, thus the plugin.

Good news, there is a plugin command. I’ll explain it at the end, but since it is based on a potentially changing menu structure, I don’t use it for a preset.

Instead, my solution was to manually start playing the desired station/playlist, then save it as a LMS playlist with a meaningful “playlistname”. Then I have something stable to use, so I can then use this in a preset

"playlist",“play”,"playlistname"

Here’s the plugin command explanation. I’ve tried it for Pandora, so it should work for Spotify. Example:

"pandora","playlist","play","item_id:0.4"

The item_id is the tricky part. It is a menu tree hierarchy. In the example the zero means the first choice (numbering begins with 0, so always uses (n-1)) inside Pandora, in this case, “Your Stations”. The “.4” means the 5th item on the “Your Stations” menu.

This isn’t too hard to figure out, but because it is menu driven, it can change as other stations/playlists are added, but this is probably targeted to something that is going build and select stations, not grab a specific item, so I went the saved playlist route.

Thanks for the reply. I finally figured out the issue. I needed to upgrade to LMS 7.9.1. Now the following command works with the preset.

“playlist”,“play”,“spotify:user:spotifyuserid:playlist:playlist#”

This is sooooooo freakin awesome!

Thanks,
Rod

1 Like

the spotify capability is pretty awesome. I’ll need to figure that out later with my spotify account.

Quick question for the voices, Polly just added some more so I manually added them in until the next release which hopefully adds them (specifically the first Mandarin one). I know you can set the default voice for each device with LM however is there a way to change it with WebCore when speaking text? That way a LM speaker can speak bi-lingual or different voices for example.

I agree about the Spotify integration, awesome. Now you can have a Spotify playlist start as part of your Good Morning, Return Home, or other routines, and in WebCore. I appreciate Ron sharing his solution with everyone.

Note on WebCore and smartapps, if you want to send a command, but don’t want to waste a preset button, the custom(command) is available. It accepts the exact same format as the presets, so if you have something that you only use through WebCore/smartapp, it’s an option that will expand the number of things you can access in LMS and save your presets.

Thanks for letting me know about the new voices. I will make a note to include them when I make updates, and am glad you figured out how to add them yourself.

As to a bi-lingual speaker, it’s a creative idea. Right now, it isn’t possible. Preferences can’t be changed in the code. The speak command will need to be modified to accept a voice, and the code then modified to recognize and give priority to that voice. Not terribly difficult, so will add it to the list of ideas that I’m collecting.

By the way, I added Mandarin voice into Big Talker2 (both using Video RSS and ST’s Amazon Polly interface). One note is ST’s SpeechToText does not work if the input message string only consists of UTF-8 Mandarin characters. You have to pad it at the beginning with something like “!!!” to get it to work. Just a workaround if you are testing and run into this. Video RSS is great but of course you need a free key from their website and 350 a day max limit. Works great though (better accent)!

Since ST TTS is working fine, I have no plans to add an additional TTS source. This thing is already much bigger than I originally thought it would be, so additional complexity isn’t on my list. Feel free to take it on.

Thanks for the tip about the Mandarin. Some of the voices will translate inputted English into the selected language. Anyway I assume that is what is happening, since I don’t speak them. Haven’t tried them all.