LMS Controls - Google Home / Home Assistant Voice Command for Squeezebox Players

For those who may be interested, I have opened a github project here: https://github.com/ynot123/LMS_Controls that contains the code required to voice enable much of your Logitech Media Server installation.

The configuration allows voice control for your Logitech Media Server from Google Home or Google Assistant (on your iPhone / Android device) with Home Assistant (HA) acting as the middle man. The following functions are supported:

  • Perform queries for songs, albums, artists and playlists from the LMS server or from Spotify (compound queries are supported “Play album Dog and Butterfly by Heart in the kitchen with shuffle on”)
  • Play queried items
  • Add to current playlist
  • Set music source (local LMS database or Spotify (using spotty)
  • Set volume
  • Set sleep timer
  • Set shuffle on / off
  • Set repeat on / off
  • Next track
  • Pause and re-start players

A Home Assistant web GUI front-end for the query tool is also included. Using HA you can further enhance the LMS tools to create home automation scenes (ie: play your favorite radio station when you get home, turn down the lights when listening to music, etc…).

Warning, there is some configuration required to make this work. the prerequisites are:

  • Logitech Media Server
  • Home Assistant - open source home automation package
  • Google Home (or google assistant)
  • Developer account for Dialogflow for the voice activation part
  • Spotify account with Client_ID and Client_Secret to allow query processing

If interested give it a go. I’ve been using it for sometime now and find it “cute” and convenient for simple listening and I especially enjoy the sleep timer feature.

Ynot.

LMS Controls Project Updated - January 18, 2019

New features / upgrades include:

  • Use of a package file which contains the bulk of the code
  • Audio feedback of query results and player status
  • Created an env.sh file which contains the bulk of the shell file customization details (much less editing this way :))
  • Better error checking on query results
  • Support of contractions (it’s, don’t) and
  • The ability to handle both secured and unsecured LMS installations.
  • Updated installation and troubleshooting documents
  • Created Hass.io / Home Assistant installation document for multiple platforms to help users new to Hass.io / Home Assistant.

LMS Controls Project Updated - January 24, 2019

Just a quick heads up to anyone updating their Home Assistant configuration to version 0.86 (released 23 January 2019). Changes to the Automation Trigger means that interval triggers are now separated from the ‘time’ platform and moved to a new ‘time_pattern’ platform:

This necessitates a very simple change to LMS Controls. Open the file lmscontrols.yaml in the /packages/ subfolder, and in the automation section, change platform: time to platform: time_pattern . This will ensure that the “LMS GUI Update Player Values” trigger passes the configuration check. Thanks, Ynot.

15 Likes

The GitHub distribution has been updated with a few additional features including:

  • All intents can now be called implicitly “Hey google, ask LMS Controls to play artist Pink Floyd in the kitchen with shuffle on”
  • When an implicit intent is called, LMS Controls app stays active for an additional 10 seconds allowing the user to issue supplementary direct commands “Set volume to 40”, “Set shuffle on”, “Add album Crime of the Century by Supertramp”, with having to invoke the “Hey google, ask LMS Controls to”
  • Streamlined the DF dialog requirements (more music less talk)
  • Syncing of squeezebox players can now be done using the HA GUI
  • More responsive GUI

Enjoy. Ynot.

1 Like

Damn this looks good.

Aug 5, 2018 - Added support allowing sync / unsync or (link / unlink) of players using voice commands.

  • “Sync kitchen to the mediaroom” or “Link garage to the kitchen”
  • “Sync all” or “Link all players to the kitchen”
  • “Unsync all”
  • “Unsync the garage”

Ynot.

Awesome I don’t use Google but I copied and pasted and got your UI and syncing control which works great, thank you!

Now to see if I can adapt your scripts to work with Snips…

3 Likes

@oakbrad when you get snips working I want to see, so I can get Alexa working

You should be able to make that work. Seems similar in nature.

Hello All,

A quick FYI with regards to the Voice Control of LMS players from GoogleHome using Home Automation software as the middle man.

I will be doing a minor update over the next couple of weeks which will include:

  • Cleaning up / stream lining the DF API upgrades from API V1 to V2, refining of entities to reduce configuration requirements and provide more flexible naming conventions, modifications to allow sync of all defined players
  • Update the HA GUI to include up to 10 sync players
  • Update of Spotify shell scripts to improve accuracy of query results

If you have any thoughts or ides on how to improve this tool, please feel free to email me the ideas for consideration. These can include DF functionality, HA GUI / script additions, or any other features you think might be useful for this application. [email protected]

Thanks in advance, Ynot.

Thanks for sharing this!! I just recently discovered LMS and this seems like the perfect way to integrate it with Google Assistant and Home Assistant. I have most of the integration working at this point, but I can’t get LMS playlists to trigger from HA or Google Assistant. I believe the cause of the issue is the HA scripts aren’t calling the playlists from the correct location.

On my LMS server, the playlist folder is pointed to /vol1/media/playlists/. From HA I’m able to play LMS playlists directly on a squeezebox device using the following script:

lms_playlist_test:                                                                                                                          
  alias:  "LMS playlist test"                                                                                                  
  sequence:                                                                                                                                     
    - service:  media_player.squeezebox_call_method                                                                                             
      data_template:                                                                                                                            
        entity_id: media_player.bedroom_speaker_2                                                                     
        command: playlist                                                                                                                       
        parameters: ["play","/vol1/media/playlists/classic_rock.m3u8"]

How can I configure your lms_cmd_play_playlist script to call the playlists from the correct location?

lms_cmd_play_playlist:                                                                                                                          
  alias:  "LMS command to play LMS playlist"                                                                                                    
  sequence:                                                                                                                                     
    - service:  media_player.squeezebox_call_method                                                                                             
      data_template:                                                                                                                            
        entity_id: "media_player.{{states.input_select.lms_player.state}}"                                                                      
        command: playlist                                                                                                                       
        parameters: ["play",'{{states.input_text.lms_playlist.state|title|trim|replace(" ","_")}}']

If the playlist is available from the LMS webGUI (in the playlist section) it should be playable directly using the voice command method using the source LMS. For Spotify, obviously it uses Spotify playlists. Setting it up this way avoids the pitfalls of paths, file naming conventions, etc…

That being said, I suppose you could modify the script call outlined above to include a full path and playlist file extension directly.

Without testing something like:

parameters: ["play",'/vol1/media/playlists/{{states.input_text.lms_playlist.state|title|trim|replace(" ","_")}}.m3u8']

might work. You just have to ensure the path and file extension is added to the states value properly. My suggestion however is to use and define your playlists in the GUI so they are easily accessible. That has the added advantage of being able to see what playlists you have using the LMS web GUI and the playlist stored in the LMS DB. Handy when defining the radio stations as playlists as well if you are using that function.

Very nice project.
I’ll prepare my setup, test it, and enable some commands (translation) in italian via Google Assistant actions :wink:

Good stuff. let me know how it works with the translation. If it’s easy enough, perhaps I can incorporate it into the original dialogflow using the language feature.

I have had some problems installing this on my system. I have my Home Assistant installed via Docker on a Synology NAS. Synology does not out of the box support Netcat (NC).The bash scripts uses NC. I had to install Synogear: https://github.com/SynoCommunity/spksrc/wiki/FAQ-synogear to get is workin with ncat. All the NC commands needs to be replaced by ncat in the scripts.

So to be clear, you now have it working using ncat instead of nc. Good note for those who may be running Synology NAS. Thanks. Ynot.

Wouldn’t it be easier to symlink ncat to nc and change nothing else?

sudo ln /usr/bin/ncat /usr/bin/nc

Vary depending where ncat is in your file system. You can check with

which ncat

That would certainly be a cleaner solution. Thank you

This is indeed a much cleaner solution. Ncat works fine on Synology.

I am trying to find a solution to get Tidal working with LMS Controls. I like to listen to music in lossless quality and therefore prefere Tidal over Spotify. I have tried to find a solution to do the searches on Tidal directly through url commands. I have not been able to do this however some developers have made an unofficial Tidal api wrapper:

https://github.com/spencercharest/tidal-api
and
https://github.com/lucaslg26/TidalAPI

I am not a hardcore programmer. How difficult would it be to get Tidal working with LMS Controls?

To make the symbolic link to nc you need to type the following command via ssh on Synology: ln -s /var/packages/DiagnosisTool/target/usr/bin/ncat /usr/bin/nc

(First you need to install synogear: sudo synogear install)

Sorry, I’m afraid I don’t have an account for that service and likely won’t have the time to look at it in the near future.

As Tidal is supported in Logitech Media Server, you should be able to accomplish this fairly easily. The key is understanding the method to query Tidal to return the results you want using your credentials as required. Simple modifications of the scripts should be able to get you there.

Let me know how it goes or get in touch with me again early Winter when I will have a bit more time for this.

Ynot.

This looks great. Has anyone got this working with Alexa?