Squeezebox Audio Alert Script

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:

The playlist is found but doese not play, its in pause until i hit the play button. Will try the rescan.

@floris-b nice work! Managed to get it working with tts. Only one thing, if there is music in the playlist but not playing before the announcement, following the tts announcement, it will start playing the music.

This is fixed in the latest update

Seem like @floris-b knows what he is doing (at least! :slight_smile:) a bit better then me, so i’m stopping work on my implementation and switching to that.