[No Longer Maintained] Squeezebox Integration (Logitech Media Server)

And it seems now to be bouncing back and forth between disconnected and connected... no idea why.>

dev:8882023-03-01 11:24:24.356 AMdebugReceived player message: [b8:27:eb:41:f2:1d, prefset, server, currentSong, 7]

dev:8882023-03-01 11:24:24.330 AMdebugReceived player message: [b8:27:eb:dd:a5:90, prefset, server, currentSong, 7]

dev:8882023-03-01 11:24:24.307 AMdebugReceived player message: [b8:27:eb:bf:c5:9c, prefset, server, currentSong, 7]

dev:8882023-03-01 11:24:24.285 AMdebugReceived player message: [b8:27:eb:f6:b5:9c, prefset, server, currentSong, 7]

dev:8882023-03-01 11:24:24.263 AMdebugReceived player message: [dc:a6:32:c7:f3:07, prefset, server, currentSong, 7]

dev:8882023-03-01 11:24:24.241 AMdebugReceived player message: [dc:a6:32:53:85:10, prefset, server, currentSong, 7]

dev:8882023-03-01 11:24:24.219 AMdebugReceived player message: [dc:a6:32:58:19:84, prefset, server, currentSong, 7]

dev:8882023-03-01 11:24:24.194 AMdebugReceived player message: [b8:27:eb:41:f2:1d, playlist, open, file:///music/Artie%20Shaw%20&%20His%20Orchestra/Artie%20Shaw%20&%20His%20Orchestra%20-%20G.I.%20Jukebox%20-%20What%20Is%20This%20Thing%20Called%20Love.mp3]

dev:8882023-03-01 11:24:24.169 AMdebugReceived player message: [b8:27:eb:41:f2:1d, playlist, open, file:///music/Artie%20Shaw%20&%20His%20Orchestra/Artie%20Shaw%20&%20His%20Orchestra%20-%20G.I.%20Jukebox%20-%20What%20Is%20This%20Thing%20Called%20Love.mp3]

dev:8882023-03-01 11:24:20.826 AMdebugIgnoring non-player message: [subscribe, playlist,prefset,sync,newmetadata]

dev:8882023-03-01 11:24:20.813 AMdebugStart CLI subscription

dev:8882023-03-01 11:24:20.806 AMinfoSqueezebox CLI Connected: 192.168.1.22:9090

dev:8882023-03-01 11:24:20.795 AMerrorCLI Connection Failure (attempting to reconnect): receive error: Stream is closed

dev:8882023-03-01 11:24:10.785 AMdebugIgnoring non-player message: [subscribe, playlist,prefset,sync,newmetadata]

dev:8882023-03-01 11:24:10.774 AMdebugStart CLI subscription

dev:8882023-03-01 11:24:10.766 AMinfoSqueezebox CLI Connected: 192.168.1.22:9090

dev:8882023-03-01 11:24:10.754 AMerrorCLI Connection Failure (attempting to reconnect): receive error: Stream is closed

dev:8882023-03-01 11:24:07.427 AMdebugReceived player message: [7c:b2:7d:e0:be:4c, playlist, newsong, Chor(Sopran I/II, Alt), 14]

dev:8882023-03-01 11:24:00.749 AMdebugIgnoring non-player message: [subscribe, playlist,prefset,sync,newmetadata]

dev:8882023-03-01 11:24:00.735 AMdebugStart CLI subscription

dev:8882023-03-01 11:24:00.729 AMinfoSqueezebox CLI Connected: 192.168.1.22:9090

dev:8882023-03-01 11:24:00.719 AMerrorCLI Connection Failure (attempting to reconnect): receive error: Stream is closed

dev:8882023-03-01 11:23:57.266 AMdebugReceived player message: [7c:b2:7d:e0:be:4c, prefset, server, currentSong, 13]

dev:8882023-03-01 11:23:57.253 AMdebugReceived player message: [7c:b2:7d:e0:be:4c, playlist, open, file:///music/Ulla/Sucepit%20Israel/Bach-Cantate%20BWV140/Sucepit%20Israel%20-%20Bach-Cantate%20BWV140%20-%20Chor(Sopran%20III,%20Alt).mp3]

dev:8882023-03-01 11:23:57.239 AMdebugReceived player message: [7c:b2:7d:e0:be:4c, playlist, open, file:///music/Ulla/Sucepit%20Israel/Bach-Cantate%20BWV140/Sucepit%20Israel%20-%20Bach-Cantate%20BWV140%20-%20Chor(Sopran%20III,%20Alt).mp3]

dev:8882023-03-01 11:23:50.712 AMdebugIgnoring non-player message: [subscribe, playlist,prefset,sync,newmetadata]

dev:8882023-03-01 11:23:50.698 AMdebugStart CLI subscription

dev:8882023-03-01 11:23:50.692 AMinfoSqueezebox CLI Connected: 192.168.1.22:9090

dev:8882023-03-01 11:23:50.681 AMerrorCLI Connection Failure (attempting to reconnect): receive error: Stream is closed

dev:8882023-03-01 11:23:40.672 AMdebugIgnoring non-player message: [subscribe, playlist,prefset,sync,newmetadata]

dev:8882023-03-01 11:23:40.656 AMdebugStart CLI subscription

dev:8882023-03-01 11:23:40.650 AMinfoSqueezebox CLI Connected: 192.168.1.22:9090

dev:8882023-03-01 11:23:40.642 AMerrorCLI Connection Failure (attempting to reconnect): receive error: Stream is closed

dev:8882023-03-01 11:23:30.641 AMdebugIgnoring non-player message: [subscribe, playlist,prefset,sync,newmetadata]

dev:8882023-03-01 11:23:30.621 AMdebugStart CLI subscription

dev:8882023-03-01 11:23:30.614 AMinfoSqueezebox CLI Connected: 192.168.1.22:9090

dev:8882023-03-01 11:23:30.605 AMerrorCLI Connection Failure (attempting to reconnect): receive error: Stream is closed

Ok, so I tried switching my Squeezebox Server device off() and on() a couple of times and I can also see something not quite right. There's an issue there which can cause connection bouncing. So I've pushed a fix for that. I'm not 100% certain that's what's causing your issue but if you update via HPM and give it a try, it might :slight_smile:

I have released v2.2.3 of the Squeezebox Server device. This release prevents connection bouncing if the Server device is switched off().

I'm reluctant to say it's fixed again... cause last time it was fixed it wasn't fixed at all, but this time it seems fixed (again) after the update. I can now turn it off and on without it turning itself off.
Thanks yet again for the time, effort, amazed at your willingness to help. Wanted to get first impression feedback to you asap, but I'll post back if it turns out to be (not) fixed again, otherwise solved!... (again). :beers:

2 Likes

Thanks for making this integration. I just installed it yesterday. It is working well, except that it threw an error in Hubitat that I think is related to an LMS plug-in called Group Players (allows for dynamic creation of sync groups that appear to be players in LMS).

Looks like Group Players reports the volume level as a decimal instead of an integer. This caused the following error in Hubitat on line 304 of the squeezebox-player driver:

Hubitat received this from LMS when I clicked refresh in a Group Players device:

Squeezebox Player Received [LMS_G xyz]: ..., mixer volume:39.4285714285714, ...]

Then threw this error:

java.lang.NumberFormatException: For input string: "39.4285714285714" on line 304 (method processMessage)

I was able to have it stop throwing the error by changing line 304 in the squeezebox-player driver to allow for a double to be sent instead of an integer as follows:

String absVolume = Math.abs(Double.valueOf(volume)).toString()

Not sure if this will have any other side effects, but the Squeezebox Integration seems to be working without errors now on both the Group Players devices, and the actual physical squeezebox players.

Perhaps consider integrating this simple change into the code?

Also is there a guide anywhere as to what all the commands are that show up in the Hubitat device? I see in the ReadMe, there is a list for some of what the commands do, but not all. For example

PlayText

I clicked on that and it seemed to generate an endless amount of logs in Hubitat requiring me to restart the LMS... Would be good to understand all the options.

Thanks Again, this integration is a big help!!

Another thing that might be interesting to do is to adjust the driver code to deal with how Rule Machine strips SSML Tags. This allows text with SSML Tags entered within Rule Machine rules to be read appropriately.

SSML Tags are used to provide additional control over how Amazon Polly generates speech from the text to do things like whisper or emphasize the text when read as described here:

Normal SSML tags work as expected in the Hubitat squeezebox-player devices when the SSML Tags are entered by hand into the text field of the "Speak" button within the squeezebox-player Device screen.

However, Rule Machine strips the required <SSML> text to read </SSML> tags from the Rule Machine text boxes to prevent control characters from being used to run malicious code via Rule Machine as indicated here:

This limitation within Rule Machine can be overcome by having the squeezebox-player driver convert alternate characters entered via the Rule Machine text box into the "<" and ">" that is required for the TTS engine.

For example, this can be accomplished by replacing the "{" and "}" characters received by the squeezebox-player driver with the "<" and ">" within the driver. Then in the Rule Machine text box, the following can entered which Rule Machine doesn't strip:

{amazon:effect name="whispered"}Text to read in a whisper{/amazon:effect}

and the squeezebox-player driver, behind the scenes, converts the string into the following for the TTS engine to read:

<amazon:effect name="whispered">Text to read in a whisper</amazon:effect>

This works, and the text is then whispered when played via the squeezebox player.

To do this this, add the following code within the getTts() function in the squeezebox-player driver code:

...
//--- Speech
private getTts(text, voice=null) {
  if (text) {
    text = text.replace("&", "and")
// Start: Added replace { with < and } with > as Rule Machine strips off Special Characters for security reasons, and Amazon Polly SSML tags require these characters to change speech patterns   
    text = text.replace("{", "<")
    text = text.replace("}", ">")
// Replace Special Characters for SSML tags
    // always add a break to the end of the generated file, prevents text being repeated if LMS decides to loop
    def result = textToSpeech("${ttsDelay ? "<break time='2s'/>" : ""}${text}<break time='2s'/>", voice)
    // reduce the duration to account for the added break
    if (result) {
      result.duration -= 2
      result
    } else {
      log.error "textToSpeech returned null"
    }
  } else {
    log.error "No text provided for speak() method"
  }
}
...

This is working well for me.

Thanks for the input. I think that this may be nicer in that it doesn't add decimals to the value which is expected to be an integer in the Hubitat device spec:

int intVolume = Math.round(Double.valueOf(volume)).intValue()
String absVolume = Math.abs(intVolume).toString()

Great description of the issue! I am very happy to consider pull requests :smiley:

Thanks for the updated code to turn volume back into an Integer.

I implemented it and it's working fine.

I'm not really a coder, and not that familiar with GIT, or would make a pull request. If you see fit, would be great if you wanted to implement or improve on the suggestions in the code!

I've been trying to get a TTS message to play on a given player while a LMS stream is playing and have that stream pause, play the TTS message and have the LMS stream resume after the message completes.

'haven't been able to figure out how to do it.
The closest I can get is to also install VLCThing on the playe and play the TTS message via that integration. It doesn't pause the LMS stream but the TTS message mixes in with the strram.

Does anyone know if this is possible?

Heya. Have you tried the "Play Text and Resume" command on the player device?

Yes, that was the first thing I tried. The LMS stream stops, the text message plays but the LMS stream does not resume. I tried it with and without setting a volume

That's odd. It should do exactly what you want. What is the stream that you're playing that won't resume?

The stream I was listening to at the time was: https://nebcoradio.com:8443/WXRV . However, it behaves the same way when I place music from my LMS library. The version of LMS I'm using is: 8.2.0 The versions of the app and drivers on Hubitat are:

  • Squeezebox Connect v2.3 (app)
  • Squeezebox Player v2.5 (driver)
  • Squeezebox Player Child Switch v2.0 (driver)
  • Squeezebox Server v2.2.3 (driver)

'just checked the log. Perhaps this is a clue to what's happening:

dev:5222023-10-27 09:16:29.933 AMdebugIgnored playlist command: [b8:27:eb:a8:f2:29, playlist, resume, tempplaylist_b827eba8f229, wipePlaylist:1]
dev:5222023-10-27 09:16:29.929 AMdebugSqueezebox Player Received [SB_Office]: [b8:27:eb:a8:f2:29, playlist, resume, tempplaylist_b827eba8f229, wipePlaylist:1]
dev:4932023-10-27 09:16:29.913 AMdebugReceived player message: [b8:27:eb:a8:f2:29, playlist, resume, tempplaylist_b827eba8f229, wipePlaylist:1]

I figured it out.
I checked the LMS log and the found that temp playlist for the pre-message content was unable to be written by the LMS process.
I changed ownership of the playlist folder and it works just as I hoped.

Now I can get rid of VLCThing!

1 Like

Good stuff! And a useful tip to check for anyone else experiencing the same problem.

1 Like

Is there a simple way to replace a player without having to update all the apps which use the original player? My initial thought was to change the MAC address in the Device settings but I was greeted with a stern warning in the UI when I attempted to do so.

I don't think there is. The ID of a device is fixed so you don't have a lot of options there.

Thanks. I would have guessed that changing the MAC address would take care of it but, alas, it didn't.
I'm planning to replace several of my failed Squeezebox players so it looks like I have a bit of App editing ahead of me.

As an aside, some of my replacements will be based upon this project: The Tivoli Squeezebox Radio – Penguin Loves Music
Instead of adding a BT module, I'm adding a Raspberry Zero and a mini HiFiBerry DAC running PiCorePlayer. The Tivoli radios are still available on eBay for a reasonable price and still sound great.