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

Hi all,

Very new to HE but a long time Squeezebox lover (several devices, LMS running on a QNAP NAS). I am mostly interested in using my Players for Text to speech devices for announcements (Garage Door is open, that kind of thing). The driver works perfectly and it detected my players (other than my SB radio but that is a long story on the SlimDevices forum) but when I am listening to a playlist and an announcement is played the current playlist gets overwritten by the MP3 TTS. Is there a way to have the playlist resume? I realize that doing a Play Next might make the announcement become less timely and less interesting, but curious if there is a way using the CLI to pause the playlist for the time to play the TTS then resume.

Thanks!

Rob

Hi @Locutus Welcome! There is a "playTextAndResume" method on the squeezebox player devices that preserves the current playlist and then resumes it after the notification. If you use that in your rules it should work.

Thanks xap! I am also very new to rules! I am not seeing how I access the methods from within the rule engine, do I have to write a rule using code? Sorry for the basic questions!

Answering my own question! I figured it out, I assume I set this method prior to running the TTS.

Thanks!

Ok, tried it but it is not working - I am now seeing the following in the logs:

[app:30]2023-02-27 11:42:03.200infoAction: Notify SM-G781W and Speak on Kitchen speaker, Squeezebox Boom(volume: 50), Squeezebox Boom (volume: 50): 'Garage door closed'

[dev:19]2023-02-27 11:42:03.185[error]org.codehaus.groovy.runtime.metaclass.MethodSelectionException: Could not find which method playTextAndResume() to invoke from this list:
public java.lang.Object user_driver_xap_Squeezebox_Player_623#playTextAndResume(java.lang.Object)
public java.lang.Object user_driver_xap_Squeezebox_Player_623#playTextAndResume(java.lang.Object, java.lang.Object) on line 6227 (method playTextAndResume)

[app:30]2023-02-27 11:42:03.165[info]Action: playTextAndResume() on Squeezebox Boom

You need to add a single String parameter with the text you want the player to say. Here's an example rule action:

Ah...got it...my structure was wrong, was still using the Notify Action

Thanks!

1 Like

So... did the following:

  • update container on Synology/Docker to "latest" (v8.3.1-1672817815) via download new image, stop container, 'reset' container, start container.
    Now the server device seems to be staying connected to LMS. No other changes. And I have restarted the container several times in various attempts to 'turn it off and back on again' to fix the problem prior without luck.

I hate unresolved but fixed.... and in this case that's what I've got. No idea if it was the 'reset' which as I understand it doesn't change any config settings, just rebuilds from the image... so likely something in the version update maybe? donno, nothing in change log seems obvious, but there it is, Thanks much for the assist @xap I'll call it fixed for the moment. and hope this helps someone else later! :person_shrugging:

1 Like

I share your dislike of "magic" fixes. However, glad that it's working for you now :slight_smile:

oh well... I was hopeful the magic fix... well hopeful it fixed it! But nope.
So I'm basically in the same spot.... squeeze server device shows 'on'. This is after a restart after yet another LMS update. It seems to stay on for a while.... no idea how long, but if I turn it 'off' and then 'on' again manually from the device page in HE it's on for a few seconds and turns itself off again.

I had debug enabled, and caught this from the logs:

dev:8882023-03-01 10:24:52.883 AMdebugIgnoring non-player message: [prefset, server, checkVersionLastTime, 1677695092.52619]

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

dev:8882023-03-01 10:24:49.409 AMdebugStart CLI subscription

dev:8882023-03-01 10:24:49.403 AMinfoSqueezebox CLI Connected: 192.168.1.22:9090

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

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

dev:8882023-03-01 10:24:44.858 AMdebugStart CLI subscription

dev:8882023-03-01 10:24:44.852 AMinfoSqueezebox CLI Connected: 192.168.1.22:9090

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

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

dev:8882023-03-01 10:24:34.822 AMdebugStart CLI subscription

dev:8882023-03-01 10:24:34.815 AMinfoSqueezebox CLI Connected: 192.168.1.22:9090

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

dev:8832023-03-01 10:24:33.722 AMdebugSqueezebox Player Received [SQ - DownLo]: [b8:27:eb:41:f2:1d, status, -, 1, tags:abclsu, player_name:DownLo, player_connected:1, player_ip:192.168.1.26:38920, power:1, signalstrength:0, mode:play, time:14.7771839866638, rate:1, duration:163.474, can_seek:1, sync_master:dc:a6:32:c7:f3:07, sync_slaves:dc:a6:32:58:19:84,dc:a6:32:53:85:10,b8:27:eb:f6:b5:9c,b8:27:eb:bf:c5:9c,b8:27:eb:dd:a5:90,b8:27:eb:41:f2:1d, mixer volume:16, playlist repeat:0, playlist shuffle:1, playlist mode:off, seq_no:0, playlist_cur_index:9, playlist_timestamp:1677693378.08754, playlist_tracks:42, digital_volume_control:1, playlist index:9, id:679459, title:We Are In Love, artist:Harry Connick Jr., album:No Album, artist_id:147248, url:file:///music/Harry%20Connick%20Jr/Unknown%20Album/Harry%20Connick%20Jr.%20-%20%20-%20We%20Are%20In%20Love.mp3]

dev:8882023-03-01 10:24:33.705 AMdebugReceived player message: [b8:27:eb:41:f2:1d, status, -, 1, tags:abclsu, player_name:DownLo, player_connected:1, player_ip:192.168.1.26:38920, power:1, signalstrength:0, mode:play, time:14.7771839866638, rate:1, duration:163.474, can_seek:1, sync_master:dc:a6:32:c7:f3:07, sync_slaves:dc:a6:32:58:19:84,dc:a6:32:53:85:10,b8:27:eb:f6:b5:9c,b8:27:eb:bf:c5:9c,b8:27:eb:dd:a5:90,b8:27:eb:41:f2:1d, mixer volume:16, playlist repeat:0, playlist shuffle:1, playlist mode:off, seq_no:0, playlist_cur_index:9, playlist_timestamp:1677693378.08754, playlist_tracks:42, digital_volume_control:1, playlist index:9, id:679459, title:We Are In Love, artist:Harry Connick Jr., album:No Album, artist_id:147248, url:file:///music/Harry%20Connick%20Jr/Unknown%20Album/Harry%20Connick%20Jr.%20-%20%20-%20We%20Are%20In%20Love.mp3]

dev:8802023-03-01 10:24:33.648 AMdebugSqueezebox Player Received [SQ - LivingPi]: [b8:27:eb:dd:a5:90, status, -, 1, tags:abclsu, player_name:LivingPi, player_connected:1, player_ip:192.168.1.51:48548, power:0, signalstrength:0, mode:stop, time:14.7771839866638, rate:1, duration:163.474, can_seek:1, sync_master:dc:a6:32:c7:f3:07, sync_slaves:dc:a6:32:58:19:84,dc:a6:32:53:85:10,b8:27:eb:f6:b5:9c,b8:27:eb:bf:c5:9c,b8:27:eb:dd:a5:90,b8:27:eb:41:f2:1d, mixer volume:100, playlist repeat:0, playlist shuffle:1, playlist mode:off, seq_no:0, playlist_cur_index:9, playlist_timestamp:1677693378.08754, playlist_tracks:42, digital_volume_control:1, playlist index:9, id:679459, title:We Are In Love, artist:Harry Connick Jr., album:No Album, artist_id:147248, url:file:///music/Harry%20Connick%20Jr/Unknown%20Album/Harry%20Connick%20Jr.%20-%20%20-%20We%20Are%20In%20Love.mp3]

Bugger, that's disappointing. Can you grab the last 500 lines from the Logitech Media Server Log File via the Information tab on the LMS Server Settings UI? Any hints there?

PS. Love the choice of tune, my wife walked into our wedding to that song.

I can PM it to you, but honestly, other than DynamicMix messages, there's litterally nothing other than this... which mostly is still DynamicMix related.:>

[23-03-01 08:15:43.8711] main::init (377) Starting Logitech Media Server (v8.3.2, 1677516824, Mon Feb 27 18:22:30 CET 2023) perl 5.032001 - x86_64-linux-gnu-thread-multi
[23-03-01 08:15:45.5504] Slim::Utils::Misc::msg (1325) Warning: [08:15:45.5499] DBIx::Class::ResultSet::update_or_create(): Query returned more than one row. SQL that returns multiple rows is DEPRECATED for ->find and ->single at /lms/Slim/Schema.pm line 1927
[23-03-01 08:15:49.9954] Plugins::DynamicMix::Plugin::commandCallback (371) DynamicMix: received command: playlist addtracks

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!