Squeezebox (Logitech Media Server) Control for Smartthings

UPDATE 8/11/2021

I am no longer updating or supporting this code. The unknowns of of the new developer’s platform made this too much to pursue further. Use this at your own risk. The last time I checked a few months ago, the future of LAN devices was unknown. I’ve since given up on the Smartthings ecosystem.

UPDATE - Version 2.0 has been uploaded See below post.

There have been several discussions and attempts at controlling Squeezebox (Logictech Media Server) in Smartthings. Here is my solution. It only requires two device handlers and no bridge program. Multiple players can be controlled individually with one server. Player status information is updated from the server. (See Readme)

This is mainly a “because I want to see if I can” effort, but I wanted to share my results. This is definitely a first rough start. I’m sure there will be bugs and I welcome help, feedback and suggestions. I have a wish list of items I hope to tackle. Suggest additional items and if any one item should be tackled first.

Finally, thanks to all those in the community that have helped me realize that something like this was even possible. Keep being creative!!

4 Likes

A couple of screenshots of the server and player.

1 Like

Many thanks to @LeeC77 for help in testing. The first bug has been found, so the server device handler has been updated.

Also, it appears that the communication method I have been using is no longer supported in LMS version 7.9. It works fine in 7.7.5. I am going to investigate other options.

Well done on developing this. Been on my list of home projects forever and just not found the time. Would be interested in your patch for 7.9. Will report back whether it works on 7.8 shortly

The code has been updated to support 7.9. Hopefully in fixing this I didn’t break anything else. Code isn’t pretty, I’m hoping for a better long term solution still, but that will take more time. I’m investigating JSON, which I have zero experience with.

Shuffle now has 3 states, “Off”, “Song”, and “Album”. That was the plus of the switch.
Volume is now less discrete. It only reports from server levels 1- 11, so that means volume is in increments of 9 for reporting. Hoping this won’t be an issue if I can figure out a better solution.

Also, if you install the LMS plugin for Chromecast, you have control of those devices, including Google Home. I’ve done much of my testing using my Google mini. Works fairly well. Only thing I’ve noticed so far is turning on shuffle after the playlist starts ends playback with the current song. I’m hoping that once I get speak to work, I can use my Google home for announcements.

New Version Available

Just finished uploading new version of the code. This version includes new functionality and a smartapp for voice/routine control. As usual, there will probably be issues, since my testing is limited to me. Installation method has not changed.

New functions include -

  • Speech synthesis. The speak(msg) command has been implemented using Smartthings text to speech. You can pick the voice you want to use. I’ve tested this a bit with Big Talker 2. Report back if you find issues with it or other apps, I’ll be curious to see what happens. It seems to work fine as either a music player or speech synthesis device. The speak command will attempt to restore the player to it’s state before the speech event is sent. Shuffle may result in a different song, since saving a playlist is shuffle order isn’t supported in the API being use. There are some other quirks, see below.

  • Three new preset buttons. These are to allow starting music within Smartthings. You will need to load a LMS HTTP API command into the settings. See documentation on Git on how to do this. With this you should be able to automate music. New commands associated with this are button1(), button2(), and button3().

  • Repeat control has been implemented.

  • Several new player settings to customize player action, see Git documentation.

I have been testing this with a Boom, a piCorePlayer, a Google Home, and a Google Home Mini. All play music fine, but speech presented a few issues to overcome.

Speech, in general, produces a short track to play. For most players, this is not an issue. However, the SqueezeLite implementation has a known problem with very short tracks, under 5 seconds seems to be the limit I found. The player will appear to be playing, but produce no sound, and the timer will continue to increase or loop. The solution is more verbose speech, usually adding a phrase to get beyond 11-12 words is enough. To help prevent this, there is an option on the player handler to mark it as a SqueezeLite, and a warning message will be generated if the resulting speech track is too short. I can’t test for this if you are using BIg Talker 2 as a music player, since it is already padding duration information beyond the minimum. So, if you see this problem, add more words to your announcement. My piCorePlayer is SqueezeLite. Even though Chromecast devices report as SqueezeLite, they do not appear to have this issue, I think due to different connection methods.

However, if you implement Phllipe’s Chromecast plugin in LMS, please read his documentation. I cannot help with issues there. Things that do matter, volume is set by default to only update while actively connected. It can be changed. Second, the server has to reconnect if the connection has been terminated or interrupted. Sometimes this manifests as a speech event not playing on the first attempt. I’ve added a longer delay before resetting the player to try to minimize this. So, your Chromecast for speech experience my not be 100%. Feedback is appreciated, you will probably think of something I missed.

Hope you have fun with this.

Wow, I love the idea of this. However is not working for me. I’m using Logitech Media Server Versie: 7.9.1 on Windows 8.1.
In smartthings I’m getting this error:
Socket is unhealty
Registered with Client Connect

In LMS:
18-07-05 21:58:31.6113] Slim::Utils::OS::Win32::getPriorityClass (752) Error: Slim::Utils::LogCan’t get process handle (The handle is invalid) [Wrong number of parameters: expected 0, got 1.

You have me stumped. Errors I’ve not seen. I’m using LMS 7.9.1 but on Windows 10.

Off the top of my head, are you using a password on LMS? I haven’t incorporated that into the calls. I don’t, since I don’t expose ports, so didn’t even think about it.

From what little I can find with a internet search, looks like a bad network connection. Could be firewall issues or port forwarding issues. This is set up to use internal LAN ip addressing. Sorry I"m not more help.

I am happy to see somebody working on this.
I’ve been using a Squeezebox for 10 years now, and would like to automate the process.
Up to this point I have been powering on the stereo and SB from ST and then manually starting the Media Server on my PC.
I’ll look into this a little more closely when I have more time.

Hi Melinda,

I’ve just installed Windows 10 and LMS 7.9.1 - 1522157629 with no firewall, no passwords or whatsoever. Everything is on the same network 192.168.40.x (ST, LMS and Squeeze devices). Removed the Squeezesever and Squeezeplayer (device and drivers). Still nothing. Is there a way I can debug this?

Well, good to know we can eliminate passwords. If you are still receiving the same error messages, we know that Smartthings is sending a LAN call, so IP address is correct, because LMS is receiving it and rejecting it.

As to debugging, you can use live logging on the IDE to watch the debug messages that generate live when you save your settings on the server. That should kick out a copy of the LAN calls being sent. If you can grab that, it might shed some light on something.

From what I’ve looked at, this is most likely a port problem. So, either you have the wrong port, unlikely I know, it is most probably 9000, which you can check under the information tab in LMS settings, look for HTTP port number (just below IP address), or you have port forwarding turned on in your router. This behavior is usually from port forwarding.

If the likely second option is the issue, none of the changes you made fix that. It is something in your router, and I can’t help you there. Go into your router and make sure forwarding on port 9000 is turned off.

Sorry I am not able to help more.

In a bit of fun, I remembered I had installed Squeeze Play on my desktop computer. Had an old version, so needed to update it, but it hooked up to Smartthings just fine. Now, I can make my computer talk to me. Kind of redundant for music, but I’m adding it to my startup so it’s always there, and I’ll let my computer be my announcement speaker in my office.

Finally I had times to sort things out. It turns out that I had some problems with my VMware server where LMS is hosted.

Furthermore your great DH only support English and not Dutch:
550676c5-f009-481a-8b03-1ab99db1f837 11:19:41: error java.lang.ArrayIndexOutOfBoundsException
550676c5-f009-481a-8b03-1ab99db1f837 11:19:41: debug Player Status Unknown
550676c5-f009-481a-8b03-1ab99db1f837 11:19:41: debug Player Name: Salon
550676c5-f009-481a-8b03-1ab99db1f837 11:19:41: debug PLAYER??? : b8:27:eb:97:e7:d0
550676c5-f009-481a-8b03-1ab99db1f837 11:19:40: debug [delay 200, GET /status.html?player=b8:27:eb:97:e7:d0 HTTP/1.1

So I had to turn the LMS GUI to English

Thanks for all the good work and for all your efforts.

So glad to year you got your problem sorted out. Also, thanks for the feedback on the language issue. It hadn’t occurred to me that when I had to switch to a human readable response, language would make a difference, but obviously it does.

I’ll use this as an excuse for an update. When my original server communication was removed from the newest versions of LMS, I had to move to the status.html method to still get a response back from the server, and it is in the form of a readable webpage, so of course language would matter.

Good news, I have always preferred to use the CLI interface to LMS, but it is through a telnet session, so no responses back to Smartthings. I also was not happy with the current method. Too many ways for things to go wrong, and very messy code to pick apart the html code. About the time I published the current version, I found the newer, and now preferred JSON method.

I am currently working on rewriting in JSON. This allows me to wrap the richer CLI command set in JSON and sent it as an HTTP hubaction, so I can get responses. Very little documentation exists, so it has been slow going. I now have the communication working, and am in the process converting the code and cleaning up the sloppy mess that is the current version. This should also eliminate the language issue, and you can set the LMS GUI to your preferred language, or at least that is my hope.

Hopefully another week or two should do it, if my schedule calms down and I can get back to working on it.

Thanks again for the feedback. It helps me immensely.

1 Like

I was able to finally get it it work by updating/reinstalling LMS. Looking forward to any updates in the future! Thanks again.

Glad you were able to get things working. The feedback is much appreciated.

I use the Chromecast Bridge plugin, which expands my players to more than 5; however, I was able to modify the code from the Squeeze Music Server device handler.

I love the Bridge too. Nice to have announcements coming from the Google Home in my kitchen. Glad you are comfortable enough to change the code. Thanks for the feedback, it tells me my instructions are not clear enough.

If you want to add more than 5 players, you simply enter the first 5, save them, and make sure they were built properly. Then you simply replace the first group of MAC addresses with new ones. The DH will build any of that batch that are not already set up. It is setup so that duplicates should not be created. So, if you need 15 players, you simply go through the process 3 times. The DH doesn’t delete any players and doesn’t use that list for anything other than building players. The list is not used at all in the operation of players. That is all handled in the player DH.

Someday I may get around to building a helper smartapp to build players, but it hasn’t been a priority yet, since I’m still getting the basic operation working well.

I’m glad you are finding this useful. Thanks again for the feedback.

Hi,

I’m a little stumped on how to get this going.
You write:
“2. Create a device using the squeeze-music-server handler.”
How do I go about this?
I have Squeeze Music Player and Squeeze Music Server published and listed in My Device Handlers.
Where do I go to Enter the ip and port address for the server in preferences.?

Any assistance would be greatly appreciated.
Thanks!

Creating a device is also done in the IDE, but under the My Devices tab instead of the My Device Handlers tab. You will see the the choice to add a device in the top right. Fill out the form, select the Squeeze Music Server for the type. This is the same form where you will add the hex version IP and port referenced in step 3 for the Device Network ID. Once created, you can enter IP, port and player MACs in the IDE or in your mobile app.

Hope this helps. Search this forum. There are many much better written tutorials on adding devices out there.