Logitech Media Server TTS Notify Queue

I seem to have the same problem as Jerome_Arnould a few posts back.

I cant get the music to play again after a TTS. The TTS is announced and the playlist is created with the previously queued songs but it wont play. I can manually play the playlist unlike Jerome however.

Debug doesn’t show anything strange, it looks successful from what I can interpret.

This is how my configuration is done:

notify:
    - platform: lms_tts_notify
      name: Uterum
      tts_service: tts.google_say
      media_player: media_player.uterum
      device_group: group.all_persons
      volume: 0.7

I’m kind of stuck with this now, any suggestions?

When a playlist is loaded it starts to play automatic that’s why when the player is paused the playlist is not loaded

I assume the alert_sound option also does not work
Did you load the saved playlist from within LMS?, did you try with HA service: squeezebox.call_method? ( this integration is also using that service, strange is that it is used for saving and restoring the playlist and save works)
Are you using the latest LMS version? I am using 8.2 Docker Hub

Thanks for taking your time!

I’m using the home assistant community add-on of LMS version 8.2.0.

Yes, I did load the playlist from within LMS. We’re on to something now tho, I noticed the logs in fact do throw an error:

 Error: Could't open /media/Save-media_player.uterum.m3u for writing.

I can’t manage to start a local playlist with the call_method. I think mainly becouse I don’t know how to point to the correct playlist directory. I can use the call_method to call a Spotify playlist however. My LMS playlist folder is /media/ , could anyone point me in a direction how the call_method parameter pointing to my playlist would look?

If I use the call_method to launch a faulty playlist it gives me an empty play queue in LMS in the same way as when I try to use the TTS so it feels like the problem lies here. It feels strange however that LMS TTS notify manages to save the playlist but not play it again if it uses the same service as you say.

Do you have the playlist directory defined in LMS as mentioned in the readme of the integration?

Yes, I defined the playlist directory to the folder “/media”.

Since it’s a home assistant add-on of LMS I don’t understand if it’s a relative directory or how to verify the playlist file is stored there. I’ve been unable to locate the folder.

I had the same problem and for me, the playlist directory didn’t have a ‘write’ permission when created through the addon. What I did was ssh into my home assistant server and ‘chmod 777 playlist_directory’. The /media folder might be somewhere else depending on how you have Home Assistant installed, but on many it’s located at ‘/usr/share/hassio/media’.

Thank you! This solved my problem.

The playlist file was created but without write permission so a chmod on the file solved it!

I’ve noticed that if you have shuffle play on when it resumes from the TTS it plays a different song. I think this is because the order that the information is saved and restored. Say you have 5 songs in a list:

Song 1
Song 2
Song 3
Song 4
Song 5

and shuffle the playlist

Song 2
Song 4
Song 3
Song 5
Song 1

When the status is saved it know that the “second song” is playing which in this case is Song 4. When it’s restored the list is randomized again.

Song 4
Song 5
Song 2
Song 1
Song 3

It resumes playing the “second song” which is now Song 5.

What needs to happen is shuffle needs to be turned off. Then the status saved. On restore it needs to resume playing then shuffle turned back on. Or I just may be missing something super simple.

Unfortunately my skills are very limited. I’ve tried to see how this is all done but I can’t trace it out. Can anyone point to where these things happen and how to move them around?

Thanks for your help.

Hi , have a question , in my case the tts message goes ok, the playlist folder file is created but only with the tts message , the sound alarm does not play , and the playing list is not created on the folder . the message is write permissions , im running on HassOS , and I don’t get how to CHMOD into that folder . im using LMS add-on for the server side , and the client is a separate lms. thank you!

Hi, I tried to set this up and everything seems to be fine. I had some trouble at first as the media player I wanted to use for testing had a “duplicate” as it is seen as chromecast device as well. But after I changed it to correct player I successfully tested it by calling the service from developer tools. The problem is. When I immediately after tried another sentence, nothing happened. After that I’ve tried everything from restarting HA to restarting lms (clearing the queues etc.) but nothing comes out anymore. Is it something obvious I am missing? I should probably mention that I can make the speaker announce notification with tts.google_say service so issue does not seem to be there.

My config:

tts:
  - platform: google_translate
    service_name: google_say
    language: "fi"

notify:
  - platform: lms_tts_notify
    name: JBL
    tts_service: tts.google_say
    media_player: media_player.audiocast
    volume: 0.4
    device_group: person.xxx

Calling the service (example):

service: lms_tts_notify.queue
data:
  entity_id: media_player.audiocast
  message: This is a test
  volume: 0.2
  force_play: true

From the first successful run I can see the playlist file to resume to be created. I removed it but the new tries do not create it anymore.

As a comparison, this works for the same player:

service: tts.google_say
data:
  entity_id: media_player.audiocast
  message: This is test two
  cache: false
  language: en

Hi There,
I also try to implement this notification with Max2Play, however I don’t understand how to implement. How can I call the notify.jbl Or notify.lms_tts_notify within an automation or action?
SOLVED:: it wasn’t correctly installed, I installed again, and after I could use the service: lms_tts_notify.queue.

Unfortunately another problem raises
In my LMS I see in Save-media_player.living, that the correct previous song (radio) is stored. However, it seems that below function:

self._hass.services.call('squeezebox', 'call_query',
            {'entity_id': list(self.queue_listener), 'command': 'playerpref', 'parameters': [ 'plugin.dontstopthemusic:provider' , dstm ] })

gives me following error:

2023-01-24 20:52:20.866 ERROR (Coordinator) [root] Uncaught thread exception
Traceback (most recent call last):
File "/usr/local/lib/python3.10/threading.py", line 1016, in _bootstrap_inner
self.run()
File "/config/custom_components/lms_tts_notify/__init__.py", line 151, in run
if self.check_done():
File "/config/custom_components/lms_tts_notify/__init__.py", line 165, in check_done
self.restore_state(player)
File "/config/custom_components/lms_tts_notify/__init__.py", line 348, in restore_state
self._hass.services.call('squeezebox', 'call_query',
File "/usr/src/homeassistant/homeassistant/core.py", line 1666, in call
).result()
File "/usr/local/lib/python3.10/concurrent/futures/_base.py", line 458, in result
return self.__get_result()

Did you find out what went wrong with first install and how did you reinstall it @ELRO? Just remove the config, restart, and add it again or did you also delete all the files in custom_components?

I will have another go at this later today…

edit: removed it from config → restart HA → add to config → restart HA …and now it work consistently :slight_smile:

@odelma, I just removed the single custom component (I installed it through HACS). To be honest, I think I forgot to reload/restart my system before the component was loaded.

I tried a few hours today to solve my problem regarding playing/resuming a playlist… It seems that the query call to Squeezebox for starting a playlist is not working: the script is creating a playlist (‘Save-’ + player), but it fails both “resume” requests, one for this script (line 218)

service_data = {
  'entity_id': player,
  'command': 'playlist',
  'parameters': ['resume', 'Save-' + player],
 }

and this one:

service_data = {
  'entity_id': self._media_player,
   'command': 'playlist',
  'parameters': ['resume', self._alert_sound],
}
self._hass.services.call('squeezebox', 'call_method', service_data)

If I change the call with the ID of the playlist (Which is uncommented in the script), than it’s working as it should be:

 service_data = { 
  'entity_id': self._media_player,
  'media_content_id': '432',
  'media_content_type': 'playlist' 
}
  • Make sure you can save en load playlists in the Logitech Media Server interface ( playlist location must be defined in the settings standard tab and the location must have write permissions )

  • make sure you can play TTS messages in HA on the LMS players with the standard HA service : tts.xxxxx

Thank you for your quick response @floris-b. Both seems right: HA can play TTS messages through any of my music players, and it also generates the “current playing” playlist. Maybe it is because I have Max2Play integration which has Squeezebox Lite?

I will try to change your script by searching for the playlist id by the playlist name (Get all playlists in dict and search by name), and activate the playlist by playlist_id. If I can manage, I will post script here… If you have any suggestions, please let me know :slight_smile:

What I also want to do is adding an extra field to the service: “Audio Path”, so in stead of playing a playlist, it plays a audio file (like doorbell). In my opinion it has 2 advantages; I don’t need to have a playlist for every notification sound (doorbell / alarm / etc), it doesn’t show up in my LMS playlists, and it’s also some work to create a playlist in LMS.

All LMS players should work, I am using Squuezeplay and also tried picoreplayer that also uses Squeezebox Lite

Get all playlists in dict and search by name
don’t understand why or what it adds

What I also want to do is adding an extra field to the service: “Audio Path”
I use saved playlists for that because they start playing quicker to minimize the silence in-between and if I remember problems with players in sync and with short alert sounds

Did you set debug for the integration? you see a lot what is happening

service_data = { 'entity_id': self._media_player, 'media_content_id': '432', 'media_content_type': 'playlist'  }
self._hass.services.call( 'media_player', 'play_media' , service_data)

I replaced above script, for below script and that works (432 is the ID of my playlist).

service_data = { 'entity_id': self._media_player,'command': 'playlist','parameters': ['resume',self._alert_sound],}
self._hass.services.call('squeezebox', 'call_method', service_data)

So for me (in my system) it seems that there is issue by calling a playlist by it’s name, also because it’s not starting the “created playlist for continuing music”, which it creates. That’s the reason why I wanted to do a look-up for the Playlists’ IDs.

I will try to enable debugging.

Hi, I can still report a bit similar problems as @ELRO. For while the notofications for player “Audiocast” worked fine. Now I added another player and the first notification I tested player, but it did not resume playback. After this it has not player any notification, not for the Audiocast or the other player. I assume after a restart it would play again. I can see, though, playlist created for both players:
image

I will enable debugging and come back with how it shows in the log after that…

I am sorry, was to quick, did not read that the id was a working solution :grimacing:
maybe playlist name is case sensitive
are you running the latest release of LMS , I am using Logitech Media Server: 8.3.1

For me it is running fine and don’t know if I can be of more assistance, happy debugging