Squeezebox Audio Alert Script

I have solved my issue.

It was a permission problem on the _Playlist directory inside LMS!
After fixing it I can now trigger an alarm and it will resume exactly where it was before it

This script is perfect for me. Thanks @pkozul and @smazman for that script.

2 Likes

@ppmt Great to hear Philippe. Can you just temporarily use the original script (post #65) just to see whether that script successfully resumes the playlist exactly where it was paused?

I just want to see whether my new version actually makes a difference (for someone else other than myself!).

So I tried the said script and at the beginning I thought that it was working the same as yours. It was restarting at the same time it was interrupted but then I realised that it was not the same song.
After triggering the script a few time it seems that it restart at the same time but using the next song in the playlist.
Very strange

1 Like

I found a great plugin for lms called lmsannounce. It give you an api to do announcements to your squeezebox-player.
Your announcement can be a playlist, a file (mp3, flac ect.) or a TTS. The cool thing is it saves whatever your playing en resumes after the announcement is done!
I’ve used it to extend my doorbell which triggers a shell command doorbell.

doorbell: 'curl -k "http://192.168.1.1:9000/plugins/LMSannounce/js.html?cmd=announcePlaylist&playlist=Doorbell&playerid=b1%3a21%3aeb%3acf%3a33%3a47"'

Works great for me!

june 17th 2022:
I now use this intergration by floris-b wich is even better!

3 Likes

Thank you very much for this finding!

1 Like

Awesome find!

I’ve combined it with my earlier efforts to make a easy (or easier) to deploy TTS addon… (using the other method in this topic earlier)
Also because I don’t like the TTS options lmsannouce gives if made it so that you can use whatever TTS home assistant uses.

I’m not much of a programmer so lots of BETA flags and <insert i have no idea what i’m doing dog in lab image here>

Add the repo, install addon, configure the lmsserver:port (without http://) and use.

Using call service → hassio.addon_stdin

input:
  alert_volume: 100
  mac: '00:00:00:00:00:00'
  base_dir: '/volume1/apps/tts/'
  tts_message: 'Hi, i am a TTS notification. May i interrupt?'

where base dir is where the tts cache directory is mounted.
Did I mention you need to mount the home assistant tts cache on your LMS server?

Well this was easier in my head… Also I just realized i did not implement playing existing files quite yet.
Look, I wanted TTS, got all excited it worked and wanted to post! Will update later with a better guide and update to addon to include playing non TTS.

3 Likes

Hi PhiAX,

Wanting to use your script, but have not got it working yet. Can you share me details/examples on the call service? And the mounting done on the LMS server?

Thanks!

Sorry it took awhile but here it is:

First install and enable LMSannounce on your LMS server.
Then make sure the Samba add-on is installed and configured on your Home Assistant.

Mount the TTS cache folder from your home assistant config share on your LMS server. Mine is a synology.


image

Install my add-on and configure it with the url to LMS with the portnumber included.(like: mediaserver.local:9002, or 192.168.1.100:9000)

Then try to call the service in the developer tools or a automation like this:

The addon part is the slugs name for the addon. I don’t know if this is the same for everyone or anything but you can look it up by looking at the url when you’ve selected the addon in the addon store.

Where base_dir is the path to the mounted folder from earlier, as seen by your LMS server. The others are self explanatory.

That should be it.

Hi PHiAX,

Thanks for the details guide. I have everything set-up (samba, sharing etc) but the sound file in the tts folder is not created when calling the service. And hence nothing happens on my squeezebox.

[00:36:50] INFO: Raw input: {“alert_volume”:25,“mac”:“XX”,“base_dir”:"/volume1/hass/config/tts/",“tts_message”:“This is a test”,“platform”:“microsoft”}
[00:36:50] INFO: Using base_dir: /volume1/hass/config/tts/
[00:36:50] INFO: Using mac: XX
[00:36:50] INFO: Using alert_mp3: null
[00:36:50] INFO: Using tts_message: This is a test
[00:36:50] INFO: Using alert_volume: 25
[00:36:50] INFO: Using platform: microsoft
[00:36:50] INFO: Player lock exists…exiting.

Anything I am missing in the set-up?

Cheers

I tried the LMS Announce plugin, but it didn’t really work out in my setup. I have 6 Squeezebox players around the house, and using this plugin, some of them were unable to resume playback after the announcement was played. The players were left in a weird state where their playlists were empty. I might try again in the near future.

Anyone else got it working nicely with multiple players?

For now, I am sticking to the solution I posted earlier. It’s been working for months without any issues (in my setup anyway).

Try it with

platform:google_translate

TTS should already be setup like this:

But this sound not really good (especially in German!). I am using ReversoTTS installed via HACS and that sounds really good!

then change the platform to that: :slight_smile:

It just needs to match, so if your tts is set to reversotts in HA, also use platform: reversotts for LMS announce.
It should work with all but amazon_polly but i have only tried google and microsoft myself.

I must be doing something wrong. The TTS file is not created on my NAS share (synology, so used the same mounting set-up as above).

Regular TTS works fine

Log:[00:36:54] INFO: Player lock exists…exiting.

Try removing the .lock file with your players mac address from the config folder and try again.

Hi Phiax,

Sorry, i am not sure if I understand what this means and how I can remove the lock file. Can you elaborate? Show me how?

Thanks,
Martijn

I made an integration with the same functionality that adds notify services and a service to use in the automations gui
It is easy to install and configure

2 Likes

@pkozul I’ve managed to get LMS Announce setup with multiple squeezebox players. The problem for me only appeared with synced devices, unsynced players worked fine. I think the issue is that when a player is not the master device for the sync group, then it creates the issue as you have described. If it is the master device, then it works, but also plays the notification to all players with in the group (slave devices).

To overcome this, as part of my notification automation, it checks if the device is synced to another player. If it is, store this information in an input_text, unsync the device, play the notification and then re-sync it to the player stored in the input_text. There is a slight pause in music when it re-syncs, but that is part of sync process from LMS.

One thing note is to add a delay in the automation so that LMS Announce can finish before trying to re-sync the player back. If it’s an mp3 file with a fixed time, then use the time of the file and add a second. If it’s TTS, use the “wait for trigger” and use the state change of the device from playing to idle as the trigger.

1 Like

I installed the intergration and it saves the playlist, plays the notification but does not resume playing. I’m on the latest 8.2 lms nightly. What lms version do you use?
Great work btw!

I am using LMS 8.1.1
Try rescanning the media collection in LMS, I remember LMS not finding a playlist, but not sure when or why a ran into that problem anymore
Please go to: