There are scripts on the forum to resume the previous media once tts is done.
Thanks for replying. I dived into the forums and found things which were too complicated for me and didn’t even seem satisfactory to the people who knew what they were doing. However I came across the JSONRPC Squeezebox API which lets you send URLs to the LMS server to control it. If you install the HA Squeezebox integration you can not only use more geeky ways of sending the URLs (http-request using RESTful etc.), there is already a built in visual interface for thickos like me. You still have to spend time finding out what commands and parameters are available and then how to format your commands. I have LMS on a separate Raspberry Pi and a another Pi controlling each pair of speakers. There is supposed to be a security feature of the API which prevents software other than your browser from sending commands without a special code in the URL but it didn’t seem to stop me. I don’t care; it works! There are tons of commands. The one which seemed to regain control of my speakers once the TTS had used them was"clear playlist". So far I’ve only managed to get our usual radio station to play after regaining control, but resuming where you left off before the TTS seems possible (“save playlist” possibly) but I can’t save or manipulate playlists at the moment and don’t know why.
I use this intergration for notifications. I just have to see how this can be combined with the new voice assistant in the May 2023 version of homeassistant.
If you’re using ssl for HA then the link for LMS must also use SSL. I did not include instructions for setting up the SSL proxy on the LMS server, but I do indeed use SSL with an nginx proxy. I use a wildcard domainname so I only have to generate one certificate for all the services on my network that I integrate with HA. My router resolves the domainname. My nginx configuration in sites-enabled for the lms server looks like this:
server {
listen 9001 ssl;
# Set to "_" to listen to all domains
server_name lms.myhouse.net;
# Update the following to reflect your certificate and key location
#ssl on;
ssl_certificate /home/cert-usr/certs/myhouse.net.cer;
ssl_certificate_key /home/cert-usr/certs/myhouse.net.key;
ssl_prefer_server_ciphers on;
proxy_http_version 1.1;
proxy_read_timeout 600s;
# location = / {
# return 301 /iris/;
# }
location / {
proxy_pass http://127.0.0.1:9000;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $http_connection;
}
}
So then in the HA iframe I don’'t connect to the lms http port 9000 as that doesn’t work in an iframe when HA is using ssl. I connect to https://lms.myhouse.net/9001. So the proxy provides https access to lms on port 9001, which can then be used as the url in HA.
This is great, thanks so much for sharing it as I’ve been looking for a good multi-room option for quite some time now. I’ve got everything working for the most part, but when I stop playing a channel the album artwork from the previous channel stays on the mini-player. Is there a setting in LMS or somewhere else to clear this out once a channel stops playing?
Interesting question. I’m not aware of an LMS option to clear the playlist upon completion of play.
Easy to do with an ha automation.
Good idea. Here’s what I’ve come up with. Is there a way to “loop” through this for the 8 different media_player entities (speakers) that I have without having to copy/paste the same code 8 times?
- alias: 'Clear media player playlists if inactive'
trigger:
platform: time_pattern
minutes: '/10'
condition:
- condition: template
value_template: '{{ states.media_player.kitchen_speakers.state != "playing"}}'
action:
- service: media_player.clear_playlist
data: {}
target:
entity_id: media_player.kitchen_speakers
Instead of using a time pattern trigger, why not use a trigger on the state of the player i.e. from playing
to idle
or off
?
You can then list all your players under the entity_id
key within the state trigger, and use the trigger.entity_id
in your condition and entity templates to target the correct player (although the condition would probably be redundant actually).
You would probably need to set the automation mode to parallel
in case it was triggered simultaneously by more than one player.
Excellent, thanks for the suggestion. Here’s what I’ve come up with and it’s working great:
- alias: 'Clear media player playlists if inactive'
trigger:
platform: state
entity_id:
- media_player.media_player_1
- media_player.media_player_2
- etc.....
from: 'playing'
for:
minutes: 2
action:
- service: media_player.clear_playlist
data: {}
target:
entity_id: "{{ trigger.entity_id }}"
I’ve gone down the research rabbit hole on HASS + LMS + Raspberry Pi + squeezelite + etc etc for a very similar project I’m going to undertake in the coming months. But I’m confused about something that I don’t think I’ve seen people discuss, and I was wondering if someone could help fill in the gaps for me.
My family and I and most friends tend to prefer the Spotify desktop or mobile app as our primary audio interface - i.e. search, see your recommendations, playlists, ‘start radio’, library, etc, and it’s usually our preferred way to listen to and/or stream music.
Within Spotify, it’s easy for me to choose the audio playback device. For example, on the lower right corner of the desktop app:
It’s a really great user experience for us to choose which of those devices we want, hit play, and enjoy. So:
Is it possible somehow to have each HASS/LMS smart speaker ‘group’ available as their own ‘device’ choice within Spotify?
For example, if I have a Master Bedroom ‘group’ with two speakers (one left, one right, both in the ceiling), and another Master Bathroom ‘group’ (two speakers in the ceiling), and a third ‘Master Suite’ group that aggregates all 4 speakers, I’d like to choose ‘Master Bedroom’ within Spotify and only hear it in the bedroom, ‘Master Bathroom’ and only hear it in the bathroom, or ‘Master Suite’ and hear in both locations simultaneously.
If this is not possible, how do people use Spotify’s features (search, playlists, random radio, etc) and translate that to group/room selection playback as simply as possible? What user interface do they use?
Thanks!
I do not know if what you desire is possible. The LMS browse option gives access to apps, which include spotify, if configured.
When you select the spotify app you’re presented multiple ways to access your music. The interface isn’t the best but its functional. If you create playlists via the spotify app you can access from the LMS spotify app.
At the top of the interface, you can select the LMS output groups and individual media player you’d like to send music to.
My output music devices are a combination of squeezelite players and chromcast device.
That’s very helpful, thanks, I appreciate it. Kind of a bummer for me however.
I’ll have to dig deep into Spotify device connection support documentation when I get the chance to see if something like that can be enabled in code.
I’ll also want to see if I can eventually get voice commands working. For example, one of my favorite things to do when I’m not at my computer is to use Google Assistant with a bluetooth-connected speaker:
“Hey Google, play <song-name>
by <artist>
on Spotify”.
Bam, instant music.
And when that song is done, the Spotify ‘radio’ functionality automatically kicks in and starts playing genre/style-similar music in succession. Or you can just speak again and choose a new song. It’s especially great when in the shower or when cooking since you don’t have to touch any control surfaces.
A Hass local-only alternative to this would be the holy grail for me. I’ll definitely see what I can tinker with after I get the base LMS whole-home audio setup working.
Yes that works. Lms players are selectable in the Spotify app.
I did a cursory search with Spotify Connect documentation and the LMS Spotty plugin and did find some encouraging pointers, but I couldn’t get too deep into it before I had to address another obligation.
Thanks so much for confirming! This is fantastic news🎉
Like Brian, the Add-On wasn’t an ideal (though very slick, IMO) option for my environment due to network isolation, performance and settings that are needed for my Rio / Dell Receivers to function as SliMP3 emulators.
What I did do to address the SSL / iFrame issues was this…
I have Nginx Proxy Manager Add-on providing SSL for my HA instance internally and externally using a DuckDNS domain. I have another domain that is configured with a different SSL proxy (with authentication) for my LMS instance. That second proxy addresses the SSL / iFrame issue in the HA interface (when using SSL for HA access).
To resolve the HA name internally, I run split DNS using the Dnsmasq Add-on as my primary DNS server. Dnsmasq forwards my internal domain to another DNS server I have running. Probably not as efficient as some other configs would be but I had most of those services already configured.
Maybe a stupid question… but can I use Alexa to play music? Can I choose music providers like YouTube Music?