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

It is much simpler to use hass.io image on ubuntu as most of the tools are all standard and it provides the option for “addons”. If you don’t have too much invested in Home Assistant already, see my basic install doc here: https://github.com/ynot123/LMS_Controls/blob/master/HassIO%20Home%20Assistant%20Installation%20on%20Multiple%20Platforms.md.
Use the Generic Debian / Ubuntu install method. If you notice before installing Docker, you install jq, socat and a bunch of other helping tools.

If memory serves, I have tested this on Ubuntu (several versions ago) and it worked using hass.io Docker image.
.
Ynot.

Is there a way to deploy this without Raspberry Pi? I have LMS running on Synology NAS and simply don’t want another piece of hardware running.

Home Assistant can be installed on many different platforms including the Synology NAS. The Hass.io image is preferred as it has all the prerequisites installed already including nc, jq, socat and curl. I have detailed the install on various platforms here: https://github.com/ynot123/LMS_Controls/blob/master/HassIO%20Home%20Assistant%20Installation%20on%20Multiple%20Platforms.md

Here’s two (2) additional links specifically regarding installation on Synology NAS. https://www.home-assistant.io/docs/installation/docker/
https://www.home-assistant.io/docs/installation/synology/

My favorite install actually is on an old PC running Debian or Ubuntu which runs my LMS, Openmediavault NAS and Home Assistant (hass.io using Docker).

It was a bit of a pain getting it up and running on my synology but I got there. I can help as well if you run into problems. For me I had to install jq in the docker container. I also had to use ncat instead of nc for the shell commands. A lot of my issues are documented here…

https://forums.slimdevices.com/showthread.php?109273-Announce-LMS-Controls-Google-Home-Google-Assistant-Voice-Control-of-LMS-Players

1 Like

Hi again,

I looked into Tidal using “telnet lmsip 9090” and “listen 1” method you described.
Unfortunately, I can’t quite figure out what is happening.
Here is what I did:

  1. From the Tidal app installed on my LMS I did a search
  2. Search for album “Dusk”
  3. No output from “Listen 1” but a list of albums appear in the GUI (be it on my phone or webclient)
  4. Add first item from the search shown in GUI
  5. Output from “listen 1”:
    00%3A04%3A20%3A1e%3A7f%3Ad9 displaynotify showbriefly HASH(0x65810e0) 1
    00%3A04%3A20%3A1e%3A7f%3Ad9 playlist addtracks listref ARRAY(0x6501458) index%3A31

Any ideas on how to proceed?
As I understand the above. The search query and search results are not picked up by the “listen 1” but the search result is nevertheless stored on the LMS as “listref ARRAY(0x6501458) index%3A31” . So perhaps the Tidal apps does some work on its own without using what ever “listen 1” picks up.

Some more info:
In the webclient when searching for the album “Breakfast” I got a list where the second item was “Breakfast in America”. The content of the displayed linked for this second item was:
http://192.168.0.9:9000/plugins/wimp/index.html?index=536dc19e.5.2_breakfast.1&player=00%3A04%3A20%3A1e%3A7f%3Ad9&sess=
The first item was:
http://192.168.0.9:9000/plugins/wimp/index.html?index=536dc19e.5.2_breakfast.0&player=00%3A04%3A20%3A1e%3A7f%3Ad9&sess=

Best
Thomas

Well, that wasn’t very helpful was it? :grinning::grinning: Try the other method of adding some tidal tracks to a player and then saving the player’s playlist. Open the playlist in notepad++ or something like that and see what is says instead. Hopefully you will see the url link to the music you are requested. Feel free to post or send me a copy to look at.

Again without a Tidal account it’s pretty hard to do much from here. The big trick will be how to query the tidal service to get those proper url’s using their api tool or web service.

Doing a quick search I do see some promising information here: https://www.npmjs.com/package/tidalapi written for node.js. Perhaps you could follow this method to at least determine your token, etc…

Ynot.

Hi there, I’m now running hass.io in a Virtualbox machine, specifically so I could get this up and running :slight_smile:

I’ve followed all the instructions and am getting this. This is before I do the Diagflow thing, as it’s part of the testing. Any ideas? It looks remarkably like my earlier message, except this time I’ve confirmed that I have the underlying executables installed.

2019-03-30 20:54:35 ERROR (MainThread) [homeassistant.core] Error executing service <ServiceCall script.lms_cmd_play_artist (c:40ec34baab6e48efb7ad6d4d882aef8f)>
Traceback (most recent call last):
  File "/usr/local/lib/python3.7/site-packages/homeassistant/core.py", line 1147, in _safe_execute
    await self._execute_service(handler, service_call)
  File "/usr/local/lib/python3.7/site-packages/homeassistant/core.py", line 1160, in _execute_service
    await handler.func(service_call)
  File "/usr/local/lib/python3.7/site-packages/homeassistant/components/script/__init__.py", line 116, in service_handler
    context=service.context)
  File "/usr/local/lib/python3.7/site-packages/homeassistant/components/script/__init__.py", line 174, in async_turn_on
    kwargs.get(ATTR_VARIABLES), context)
  File "/usr/local/lib/python3.7/site-packages/homeassistant/helpers/script.py", line 131, in async_run
    await self._handle_action(action, variables, context)
  File "/usr/local/lib/python3.7/site-packages/homeassistant/helpers/script.py", line 210, in _handle_action
    action, variables, context)
  File "/usr/local/lib/python3.7/site-packages/homeassistant/helpers/script.py", line 299, in _async_call_service
    context=context
  File "/usr/local/lib/python3.7/site-packages/homeassistant/helpers/service.py", line 88, in async_call_from_config
    domain, service_name, service_data, blocking=blocking, context=context)
  File "/usr/local/lib/python3.7/site-packages/homeassistant/core.py", line 1118, in async_call
    processed_data = handler.schema(service_data)
  File "/usr/local/lib/python3.7/site-packages/voluptuous/schema_builder.py", line 267, in __call__
    return self._compiled([], data)
  File "/usr/local/lib/python3.7/site-packages/voluptuous/schema_builder.py", line 589, in validate_dict
    return base_validate(path, iteritems(data), out)
  File "/usr/local/lib/python3.7/site-packages/voluptuous/schema_builder.py", line 427, in validate_mapping
    raise er.MultipleInvalid(errors)
voluptuous.error.MultipleInvalid: not a valid value for dictionary value @ data['entity_id']

Send me a quick note at [email protected] and I will try to troubleshoot it with you. Haven’t tried it with virtualbox I used the docker images instead, but it should work, I would like to think. A couple of quick items to include:

  • what version of Home Assistant
  • when does this error occur
  • do you have curl, jq, nc and socat commands installed
  • do any of the commands work
  • mediaplayer mac addresses need to be entered in lowercase only

Ynot

Thank you! To answer the questions (I’ve pinged you a mail too)

what version of Home Assistant - latest 0.90.2
when does this error occur - I've tried pretty much all of the standard commands (pause, next track, play artist, etc) and they all result in the same error
do you have curl, jq, nc and socat commands installed - yes, confirmed, I can run them from a command line, running  hass.io on Ubuntu 18.04.
do any of the commands work - not as far as I can see 
mediaplayer mac addresses need to be entered in lowercase only - yes, lmscontrols.yaml excerpt below (they're Chromecasts, which work fine when I play from LMS GUI)
    media_player.dining_room_speaker_2:
      name: Basement speaker
      playerid: cc:cc:67:d8:02:32
      sync_stat: false

Another potentially useful piece of information, when I restart HA, I get the following error:

Error while executing automation automation.lms_gui_update_player_values. Invalid data for call_service at pos 2: expected float for dictionary value @ data['value']

Then if I try and execute one of the commands, I get what I posted before

OK, I’m getting somewhere. I tried running the following from the shell directory on the command line, per the troubleshooting tips:

bash qry_alb.sh _supertramp _breakfast_in_america

And it returned an error stating it can’t find “env_var.sh”, so in qry_alb.sh I changed the reference to the “env_var.sh” from /config/shell/env_var.sh to just env_var.sh" and it appears to work, noting the following output

bash qry_alb.sh _queen _breakthru
lms_username is: null
login is: not required and lms_secure is: 0
HA Token is: readacted
My Domain is: redacted.duckdns.org
My lms_ip: 192.168.1.5
My lms_cli_port: 9090


Artists are:
artists 0 20 search%3A_queen tags%3Aa id%3A89 artist%3AQueen count%3A1

Artist check zero is: 1


Artist found so moving on to albums....

Album check zero is: 1


Albums are:
albums 0 20 artist_id%3A89 search%3A_breakthru tags%3Aal id%3A67 album%3AThe%20Miracle artist%3AQueen count%3A1

Artist ID is:89
Album ID is: 67
Name is: The Miracle
now Posting results

{"attributes": {}, "context": {"id": "8dbd0ed779214017b741211bd01a1a80", "parent_id": null, "user_id": "b0279f407b6c479a84b74649894b8384"}, "entity_id": "sensor.art_id", "last_changed": "2019-03-31T23:19:28.870189+00:00", "last_updated": "2019-03-31T23:19:28.870189+00:00", "state": "89"}
{"attributes": {}, "context": {"id": "9d36aabd54b441dab4273f3eb4c382a8", "parent_id": null, "user_id": "b0279f407b6c479a84b74649894b8384"}, "entity_id": "sensor.alb_id", "last_changed": "2019-03-31T23:19:43.774775+00:00", "last_updated": "2019-03-31T23:19:43.774775+00:00", "state": "67"}
{"attributes": {}, "context": {"id": "3e53679f7feb4f2cbddd0ed11c290599", "parent_id": null, "user_id": "b0279f407b6c479a84b74649894b8384"}, "entity_id": "input_text.lms_qry_result", "last_changed": "2019-03-31T23:19:43.820374+00:00", "last_updated": "2019-03-31T23:19:43.820374+00:00", "state": "The Miracle"}

Good stuff. Yes those errors appear to be related to the environment file. If you updated for all the shell scripts does it work properly now?

No, it does not :frowning:

OK will try to take a detailed look at it tonight when I return from work and I will write up a more detailed troubleshooting guide.

Looks like 2 separate problems. The pause, play functions should work if you are addressing the proper media player as it uses the simple HA commands for generic media players. So this is likely a media_player naming issue. I assume you have selected your squeeze player in the HA LMS controls GUI before trying the play and pause functions?

The second problem (invalid data type) is likely a shell script problem or mac address issue.

Been a while since I looked at this, so will review the code (and how I select the player name) and get back to you regarding naming conventions, etc…

If you send me (by email) a copy of the lmscontrols.yaml file, I can review your edits.

Hi,

As I said in previous conversations we had but there is surely no harm in repeating it here… LMS Controls is a fantastic integration of voice-assisted music server and I fully recommend anyone to go through the (not so difficult) installation of it, you will not regret it.

Ynot, do you have any plans regarding the implementation of a query system from dialogflow that would interrogate both music sources (lms and spotify) and make a choice depending on the availability of the song requested.
As a practical example, I would ask for a song request that would first go through the qry scripts (locally stored flac music) and if they return “no match” then the request would be passed to the spotify scripts which will most likely find something but in lower resolution?

Cheers,
Alex

Thanks for the note. Nice to see it’s still getting some use. Personally, I still use it daily for the simple music stuff. I will put your request on my to do list for future consideration. Would likely be easy enough to implement.

I am considering a small update in the near(ish) future which is primarily small bug fixes and some new requirements due to the constant update cycle of HA.

Take care and thanks. Ynot.

Thanks for you reply.
Good to know you are still actively working on it. I also use it on a daily basis and even my wife uses it, which is rather uncommon for her :slight_smile:
I actually went ahead and tried a few things to implement the function I mentioned.
My knowledge of HA is rather limited, that said, it seems that I have already come up with a working solution, as I tested it quickly on the “play artist” function only and it works. I will apply this solution to all the other scripts in HA and try to clean the code a bit. When it is done I can post it here for you to review (if you are happy with that) and other people to use it.

Take care.
Cheers,
Alex

Sure send me the code to review [email protected] . I was just starting to implement the same change with a new source called “any” and testing it myself. It would be good to see someone else’s interpretation. I am also considering a general clean up of the code and some simplification hopefully.

Something strange is going on. When I activate the new stream component I’m seeing this in my log related to LMS controls. If I deactivate the stream component the error disappears. Any idea why this is showing up?

Error running command: bash /config/shell/qry_player_stat.sh {{text1}}, return code: -11

Hi, Just tested on version 0.92.1 and enabled stream component in configuration.yaml with no issue. My return code is 0. Not doing anything with the streaming component but it is enabled. Ynot.