PDA

View Full Version : Announce: LMS Controls - Google Home / Google Assistant Voice Control of LMS Players



ynot1234567890
2018-07-26, 05:12
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 LMS Player services. An audio demo is also available there.

The project 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 the music source Spotify
Compound queries are supported (ie: "Play album Breakfast in America by Supertramp in the Kitchen with Shuffle on")
Play queried items on selected player
Add queried items to select player's playlist
Set music source (local LMS database or Spotify (using spotty)
Set selected default player (can be changed on the fly)
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 (checkout the REAME.md files).

The prerequisites for this are:

Logitech Media Server (obviously :))
Home Assistant (HASSIO) - open source home automation package (can be run on a PI or even on your LMS server)
Google Home (or google assistant for android or Iphone devices)
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. Been using it for sometime now and find it "cute" and convenient for simple listening and I especially enjoy the sleep timer feature.

Ynot

*** EDITED January 20, 2019 ***

LMS Controls Project Updated - January 18, 2019

New features / upgrades include:
- Use of a package file (most HA changes are all in one file now)
- 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 have also been updated.
- Hass.io / Home Assistant installation document for multiple platforms to help users new to Hass.io / Home Assistant.

Thanks and enjoy.

Ynot.

jollybully
2018-07-31, 05:29
This looks brilliant! Can't wait to get some time to sit down and set this all up

Sent from my Nexus 6 using Tapatalk

ynot1234567890
2018-08-02, 14:05
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.



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 LMS Player services. An audio demo is also available there.

The project 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 the music source Spotify
Compound queries are supported (ie: "Play album Breakfast in America by Supertramp in the Kitchen with Shuffle on")
Play queried items on selected player
Add queried items to select player's playlist
Set music source (local LMS database or Spotify (using spotty)
Set selected default player (can be changed on the fly)
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 (checkout the REAME.md files).

The prerequisites for this are:

Logitech Media Server (obviously :))
Home Assistant (HASSIO) - open source home automation package (can be run on a PI or even on your LMS server)
Google Home (or google assistant for android or Iphone devices)
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. Been using it for sometime now and find it "cute" and convenient for simple listening and I especially enjoy the sleep timer feature.

Ynot

rgdawson
2018-08-03, 17:18
This looks awesome! I can't wait to try it out. Recently received a Google Home device as a gift and getting something like this for LMS has been on my list. I have an extra R-Pi, so I should be able to get this going. Recently ordered a Samsung SmartThings Hub in order to integrate it with Google Home to turn on/off my equipment, i.e. "Hey Google, turn on Squeezebox in the Backyard", which would turn on the receiver's backyard zone. Now with this I should be able to tell LMS what to do. Thanks!

R Greg Dawson

ynot1234567890
2018-08-03, 17:40
This looks awesome! I can't wait to try it out. Recently received a Google Home device as a gift and getting something like this for LMS has been on my list. I have an extra R-Pi, so I should be able to get this going. Recently ordered a Samsung SmartThings Hub in order to integrate it with Google Home to turn on/off my equipment, i.e. "Hey Google, turn on Squeezebox in the Backyard", which would turn on the receiver's backyard zone. Now with this I should be able to tell LMS what to do. Thanks!

R Greg Dawson

You're welcome. Give it a try, it's really quite flexible once it's setup. The Home Assistant component is also very cool, adds a lot of possibilities for google and home automation side. As an example, I monitor the PI squeeze player in my garage and when it goes live (starts playing), my old analog stereo turns on automatically via a wifi plug. I also use things like dimmers, switches, etc.

Also a quick "Hey Google, Mommy's in the mood", and the lights dim, the stereo turns on and Barry White starts playing. Hasn't been successful yet but the automation part works. Haha. Ynot

ynot1234567890
2018-08-05, 08:24
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.

Aug 5, 2018 - Updated Dialogflow and scripts to allow sync / unsync of players via voice command as well. Ynot.

Mark Miksis
2018-08-05, 09:58
I can't wait to try this! Hopefully sometime in the next few days. Thanks for contributing!

rgdawson
2018-08-06, 19:34
So I am working on this...
Step 1: I set up a R-Pi with Home Assistant according to the online instructions, including installing the Configurator plugin.
Step 2: Modify and merge HomeAssistant config files. I got to the part that says:

- **_shell_** sub-directory:
- For the files: qry_alb.sh, qry_alb_song.sh the following modifications are required:
- Replace `localhost 9090` with `your path to LMS CLI interface & Port#`
- Update `https://HA_Link.duckdns.org/api/states/sensor.art_ID?api_password=HA_API_Password` with you're `HA_Link` (accessible from the internet) and you're `HA_API_Password`


Question 1: By "your path to LMS CLI interface & port#", do you mean the host name of my LMS server, as in MYSERVER 9090? or do you mean http://myserver 9000?
Question 2: What is HA_Link and HA_API_Password? I apologize if this should be obvious, this is my first experience with Home Assistant.

Thanks for the help.


R Greg Dawson

ynot1234567890
2018-08-07, 04:38
So I am working on this...
Step 1: I set up a R-Pi with Home Assistant according to the online instructions, including installing the Configurator plugin.
Step 2: Modify and merge HomeAssistant config files. I got to the part that says:

- **_shell_** sub-directory:
- For the files: qry_alb.sh, qry_alb_song.sh the following modifications are required:
- Replace `localhost 9090` with `your path to LMS CLI interface & Port#`
- Update `https://HA_Link.duckdns.org/api/states/sensor.art_ID?api_password=HA_API_Password` with you're `HA_Link` (accessible from the internet) and you're `HA_API_Password`


Question 1: By "your path to LMS CLI interface & port#", do you mean the host name of my LMS server, as in MYSERVER 9090? or do you mean http://myserver 9000?
Question 2: What is HA_Link and HA_API_Password? I apologize if this should be obvious, this is my first experience with Home Assistant.

Thanks for the help.


R Greg Dawson

Hi,

1. Yes the hostname (myserver) in your case. The http:// part is not required. It could even be the ip address if you prefer. The CLI port number which unless you changed something should be 9090. It's a different port than the web interface port 9000. The Command Line Interface Port (CLI) that responds to requests is set to 9090 by default. You can confirm this by choosing settings, advanced and selecting command line interface on the LMS web app. It will show you the CLI port number for your installation.

2a. For the system to work it needs to be reachable from the internet. Most HASSIO users use a free service called duckdns.org to keep track of their ip and route the internet requests to the hassio service. So first you need to have this service available and installed, I suggest the using the DUCKDNS form the ADD_ON store in your HASSIO config. Once you can access HASSIO from the internet, HA_Link is the name of your server without the domain part. As an example, my server may be reached by typing https://helloworld.duckdns.org my HA_Link value would then be helloworld.

2b. HA_API_Password is the password you created (or should have created) to access HASSIO. This can usually be found in your configuration.yaml file under the http: heading.

The key before you go too far is first to ensure HASSIO is working on its own and is accessible from the internet. Until this works, you're dead in the water as far as voice commands, etc due to cloud service requirements. On the Github there is also a troubleshooting document https://github.com/ynot123/LMS_Controls/blob/master/troubleshooting.md (https://github.com/ynot123/LMS_Controls/blob/master/troubleshooting.md) to help during your setup.

I appreciate any feedback on lack of instructions, clarification requirements, etc.. Most users to date already had working versions of HASSIO installed so less setup was required. Also, I may be offline for a few days (fishing) but will get back to any requests / questions upon my return.

Cheers, Ynot.

castalla
2018-08-07, 05:39
Hi,

1. Yes the hostname (myserver) in your case. The http:// part is not required. It could even be the ip address if you prefer. The CLI port number which unless you changed something should be 9090. It's a different port than the web interface port 9000. The Command Line Interface Port (CLI) that responds to requests is set to 9090 by default. You can confirm this by choosing settings, advanced and selecting command line interface on the LMS web app. It will show you the CLI port number for your installation.

2a. For the system to work it needs to be reachable from the internet. Most HASSIO users use a free service called duckdns.org to keep track of their ip and route the internet requests to the hassio service. So first you need to have this service available and installed, I suggest the using the DUCKDNS form the ADD_ON store in your HASSIO config. Once you can access HASSIO from the internet, HA_Link is the name of your server without the domain part. As an example, my server may be reached by typing https://helloworld.duckdns.org my HA_Link value would then be helloworld.

2b. HA_API_Password is the password you created (or should have created) to access HASSIO. This can usually be found in your configuration.yaml file under the http: heading.

The key before you go too far is first to ensure HASSIO is working on its own and is accessible from the internet. Until this works, you're dead in the water as far as voice commands, etc due to cloud service requirements. On the Github there is also a troubleshooting document https://github.com/ynot123/LMS_Controls/blob/master/troubleshooting.md (https://github.com/ynot123/LMS_Controls/blob/master/troubleshooting.md) to help during your setup.

I appreciate any feedback on lack of instructions, clarification requirements, etc.. Most users to date already had working versions of HASSIO installed so less setup was required. Also, I may be offline for a few days (fishing) but will get back to any requests / questions upon my return.

Cheers, Ynot.

Am I correct in assuming that duckdns requires open ports on the router?

rgdawson
2018-08-07, 05:47
Hi,

1. Yes the hostname (myserver) in your case. The http:// part is not required. It could even be the ip address if you prefer. The CLI port number which unless you changed something should be 9090. It's a different port than the web interface port 9000. The Command Line Interface Port (CLI) that responds to requests is set to 9090 by default. You can confirm this by choosing settings, advanced and selecting command line interface on the LMS web app. It will show you the CLI port number for your installation.

2a. For the system to work it needs to be reachable from the internet. Most HASSIO users use a free service called duckdns.org to keep track of their ip and route the internet requests to the hassio service. So first you need to have this service available and installed, I suggest the using the DUCKDNS form the ADD_ON store in your HASSIO config. Once you can access HASSIO from the internet, HA_Link is the name of your server without the domain part. As an example, my server may be reached by typing https://helloworld.duckdns.org my HA_Link value would then be helloworld.

2b. HA_API_Password is the password you created (or should have created) to access HASSIO. This can usually be found in your configuration.yaml file under the http: heading.

The key before you go too far is first to ensure HASSIO is working on its own and is accessible from the internet. Until this works, you're dead in the water as far as voice commands, etc due to cloud service requirements. On the Github there is also a troubleshooting document https://github.com/ynot123/LMS_Controls/blob/master/troubleshooting.md (https://github.com/ynot123/LMS_Controls/blob/master/troubleshooting.md) to help during your setup.

I appreciate any feedback on lack of instructions, clarification requirements, etc.. Most users to date already had working versions of HASSIO installed so less setup was required. Also, I may be offline for a few days (fishing) but will get back to any requests / questions upon my return.

Cheers, Ynot.

1. I figured you meant hostname/ip but the term "path" confused me. Probably better to use the term "hostname".

2a. That is sorta what I was expecting you to say. I already have a dynamic dns service I use to make my home server accessible from the internet. Since the home server is getting the standard http and https ports forwarded to it, I guess I'll need to use a non-standard port id for Home Assistant API. So I'll have something like "https://rgdawson.homeserver.com:9443/api/states/sensor.art_ID?api_password=HA_API_Password". And I'll set my router up to forward port 9443 to the Home Assistant R-Pi. I think I need to configure the Home Assistant API to use a different port somewhere.

R Greg Dawson

ynot1234567890
2018-08-10, 10:21
1. I figured you meant hostname/ip but the term "path" confused me. Probably better to use the term "hostname".

2a. That is sorta what I was expecting you to say. I already have a dynamic dns service I use to make my home server accessible from the internet. Since the home server is getting the standard http and https ports forwarded to it, I guess I'll need to use a non-standard port id for Home Assistant API. So I'll have something like "https://rgdawson.homeserver.com:9443/api/states/sensor.art_ID?api_password=HA_API_Password". And I'll set my router up to forward port 9443 to the Home Assistant R-Pi. I think I need to configure the Home Assistant API to use a different port somewhere.

R Greg Dawson

1. I will clean up the documentation to reflect hostname.
2. Alternate ports should work as well, the shell scripts and configuration.yaml files will need to be updated to reflect this fact.
3. I find the easiest way is to ensure the HA instance is working properly first over the internet using https: links before tackling the LMS and Dialogflow portions. There is a fair bit of documentation available in securing HA and the use of SSL and alternate ports.


Ynot

ynot1234567890
2018-08-16, 15:21
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. yland@vianet.ca

Thanks in advance, Ynot.

CypherMK
2018-09-20, 07:36
Cool project. I will try this once I got the time.

courtjestr
2018-10-15, 18:51
I am so close. I say "ask lms to pause livingroom" and google home pauses the lms but talks about the "getting the test version of lms". How do I get rid of the test version prompt?

servies
2018-10-16, 06:10
I'm a little bit confused regarding the spotify account
The documentation on github mentions this:

If this is music query function:
Performs required queries against either LMS DB or Spotify using shell scripts
This suggests that I only need a Spotify account if I want to search for music on Spotify, the query processing is done by DF...
But in the prerequisites in the first post here you write:

The prerequisites for this are:
...
Spotify account with Client_ID and Client_Secret to allow query processing
That would suggest that the query is somehow done by Spotify...

Can I use this without a Spotify account as all the music I have/need is on my own LMS...

ynot1234567890
2018-10-16, 13:47
I am so close. I say "ask lms to pause livingroom" and google home pauses the lms but talks about the "getting the test version of lms". How do I get rid of the test version prompt?

Glad to hear its working for you. Doesn't seem to much interest in it lately.

Getting rid of the test prompt is a bit painful. Check this thread, I did it, it works but takes a bit of doing. Essentially (if memory serves), the developer account always get the test message (unless its been changed recently). First you need to publish your app to alpha, create a reviewer account and issue the request using the reviewer account and you should be good.

A link here details it: https://productforums.google.com/forum/#!msg/dialogflow/_iuwgWyyWd8/gM6h1mLsAwAJ

ynot

ynot1234567890
2018-10-16, 13:49
I'm a little bit confused regarding the spotify account
The documentation on github mentions this:

This suggests that I only need a Spotify account if I want to search for music on Spotify, the query processing is done by DF...
But in the prerequisites in the first post here you write:

That would suggest that the query is somehow done by Spotify...

Can I use this without a Spotify account as all the music I have/need is on my own LMS...

Yes you can. Your music source will simply be limited to LMS. Set music source to LMS and your queries will be directed against the LMS database (Spotify is not involved for LMS source).

After re-reading the pre-requisites statement it is mis-leading. I will update it.


Ynot.

bitterroots
2018-10-22, 19:22
I am making headway. But I can't get the "query" feature to work. Here is where I am stuck. I get this error from my LMS server log. Slim::Web::JSONRPC::requestMethod (425) Request failed with error: Bad dispatch!
Slim::Control::Request::execute (1888) Error: While trying to run function coderef [Slim::Control::Commands::playlistcontrolCommand]: [Can't call method "title" on an undefined value at /usr/local/share/logitechmediaserver/Slim/Control/Commands.pm line 2021. It seems that the command is getting executed, but the "variable" component is missing. Does port 9090 need to be forwarded?

ynot1234567890
2018-10-23, 03:10
I am making headway. But I can't get the "query" feature to work. Here is where I am stuck. I get this error from my LMS server log. Slim::Web::JSONRPC::requestMethod (425) Request failed with error: Bad dispatch!
Slim::Control::Request::execute (1888) Error: While trying to run function coderef [Slim::Control::Commands::playlistcontrolCommand]: [Can't call method "title" on an undefined value at /usr/local/share/logitechmediaserver/Slim/Control/Commands.pm line 2021. It seems that the command is getting executed, but the "variable" component is missing. Does port 9090 need to be forwarded?

Not sure off hand, but the easiest way I know to troubleshoot is outlined in the troubleshooting guide on the Github. https://github.com/ynot123/LMS_Controls/blob/master/troubleshooting.md Refer to the section about running the query commands in a shell from your HASSIO installation.

Yes you definitely need to have access to port 9090 on LMS from your HASSIO installation to make this work. I assume you have modified the shell scripts properly to suit your installation?

Running the query functions in a shell as outlined in the troubleshooting.md file provides simple feedback on what's being returned from LMS. This should provide some insight into what's happening. Unless your default LMS install is highly customized, it should pretty much just work.

If you can't figure it out from there, feel free to send me a copy of one of your query scripts and I can take a peek. Include what systems and versions you're running.

Thanks, Ynot.

bitterroots
2018-10-23, 18:04
Not sure off hand, but the easiest way I know to troubleshoot is outlined in the troubleshooting guide on the Github. https://github.com/ynot123/LMS_Controls/blob/master/troubleshooting.md Refer to the section about running the query commands in a shell from your HASSIO installation.

Yes you definitely need to have access to port 9090 on LMS from your HASSIO installation to make this work. I assume you have modified the shell scripts properly to suit your installation?

Running the query functions in a shell as outlined in the troubleshooting.md file provides simple feedback on what's being returned from LMS. This should provide some insight into what's happening. Unless your default LMS install is highly customized, it should pretty much just work.

If you can't figure it out from there, feel free to send me a copy of one of your query scripts and I can take a peek. Include what systems and versions you're running.

Thanks, Ynot.

Here is my output from qry_alb.sh:
Artists are:
artists 0 20 search%3A_supertramp tags%3Aa

Artist check zero is: artists 0 20 search%3A_supertramp tags%3Aa

qry_alb.sh: line 14: [: too many arguments

Artist found so moving on to albums....

Album check zero is: albums 0 20 artist_id%3Aartists 0 20 search0X0P%2B0_supertramp tags0X0P%2B0a search%3A_breakfast _in_america tags%3Aal


Albums are:
albums 0 20 artist_id%3Aartists 0 20 search0X0P%2B0_supertramp tags0X0P%2B0a search%3A_breakfast_in_america tags%3Aal
qry_alb.sh: line 53: [: too many arguments

Artist ID is:artists 0 20 search%3A_supertramp tags%3Aa
Album ID is: albums 0 20 artist_id%3Aartists 0 20 search0X0P%2B0_supertramp tags0X0P%2B0a search%3A_breakfast_in_amer ica tags%3Aal
now Posting results

{"attributes": {}, "context": {"id": "c006ab421c63435b82fc2aea73428c5a", "user_id": null}, "entity_id": "sensor.art_i d", "last_changed": "2018-10-24T00:20:41.190793+00:00", "last_updated": "2018-10-24T00:20:41.190793+00:00", "state": "artists 0 20 search%3A_supertramp tags%3Aa"}
{"attributes": {}, "context": {"id": "299e07f6762f481cb97c2ea0320b6a18", "user_id": null}, "entity_id": "sensor.alb_i d", "last_changed": "2018-10-24T00:43:56.234218+00:00", "last_updated": "2018-10-24T00:43:56.234218+00:00", "state": "albums 0 20 artist_id%3Aartists 0 20 search0X0P%2B0_supertramp tags0X0P%2B0a search%3A_breakfast_in_america tags%3Aa l"}

Here is my output from qry_alb_song.sh:
Artists are:
artists 0 20 search%3A_pearl_jam tags%3Aa

Artist check zero is: artists 0 20 search%3A_pearl_jam tags%3Aa

qry_alb_song.sh: line 14: [: too many arguments

Artist found so moving on to albums....

Album check zero is: albums 0 20 artist_id%3Aartists 0 20 search0X0P%2B0_pearl_jam tags0X0P%2B0a search%3A_alive tags%3Aal


Albums are:
albums 0 20 artist_id%3Aartists 0 20 search0X0P%2B0_pearl_jam tags0X0P%2B0a search%3A_alive tags%3Aal
qry_alb_song.sh: line 90: [: too many arguments

Album found so moving on to songs....
qry_alb_song.sh: line 115: printf: `B': invalid format character

But it hangs and does not finish.
Where do I enter username/password for CLI interface port 9090? I think that is my issue.

ynot1234567890
2018-10-24, 05:03
Here is my output from qry_alb.sh:
Artists are:
artists 0 20 search%3A_supertramp tags%3Aa

Album found so moving on to songs....
qry_alb_song.sh: line 115: printf: `B': invalid format character

But it hangs and does not finish.
Where do I enter username/password for CLI interface port 9090? I think that is my issue.

You are quite right, didn't realize you were using secure system (mine is open and only exposed to local network).

So that being said, reviewing the LMS CLI documentation (On your LMS: http://localhost:9000/html/docs/cli-api.html (replace "localhost" with your server's address), you need to issue the login request upon initial connection before submitting any requests. The command is in the form of "login username correctpassword" to open, proceed with your queries and you can then close the connection (not sure is you really need to) using "login username wrongpassword".

Basically modify each shell script that queries the LMS server to include the login and give it a try. You can always issue the commands by typing them in manually as well to ensure proper syntax.

If you make this work, I would appreciate a copy of one of the shell scripts and I will include this as an optional format on the GitHub project for other users. If you can't make it work, let me know and I'll see if I can make some time to test on my install over the next week or two.

Ynot.

bitterroots
2018-10-24, 07:28
You are quite right, didn't realize you were using secure system (mine is open and only exposed to local network).

So that being said, reviewing the LMS CLI documentation (On your LMS: http://localhost:9000/html/docs/cli-api.html (replace "localhost" with your server's address), you need to issue the login request upon initial connection before submitting any requests. The command is in the form of "login username correctpassword" to open, proceed with your queries and you can then close the connection (not sure is you really need to) using "login username wrongpassword".

Basically modify each shell script that queries the LMS server to include the login and give it a try. You can always issue the commands by typing them in manually as well to ensure proper syntax.

If you make this work, I would appreciate a copy of one of the shell scripts and I will include this as an optional format on the GitHub project for other users. If you can't make it work, let me know and I'll see if I can make some time to test on my install over the next week or two.

Ynot.

I was thinking along those lines. Doesn't LMS port 9000 need to be open for Home Assistant to access it? Also, any idea on the other errors in the script? Or is it anything to be concerned about. I will let you know what I find out.

ynot1234567890
2018-10-24, 16:52
I was thinking along those lines. Doesn't LMS port 9000 need to be open for Home Assistant to access it? Also, any idea on the other errors in the script? Or is it anything to be concerned about. I will let you know what I find out.

Port 9000 is not used in the scripting. Only the CLI port which by default is 9090. As for the rest of the errors, they may clear up after you fix the login thing.

Ynot

bitterroots
2018-10-25, 16:47
Port 9000 is not used in the scripting. Only the CLI port which by default is 9090. As for the rest of the errors, they may clear up after you fix the login thing.

Ynot

I have not been able to get the query to work without authentication. Removing the password protection allows it to work. I think that the main issue with the password is that it only works in a telnet session. There does not seem to be a log in/log out. I am currently using HTML webhooks through IFTTT. The usage is http://USERNAME:password@HA_Link.duckdns.org:9000/anyurl?p0=radiotime&p1=playlist&p2=play&p3=item_id:0.5<lf>&player=XX:XX:XX:XX:XX:XX. But you have to issue it each time. If I use this: | nc 192.168.1.X | \login USERNAME password ) I get a password prompt when I run the script. But it will not take the typed password.

ynot1234567890
2018-10-25, 16:54
I have not been able to get the query to work without authentication. Removing the password protection allows it to work. I think that the main issue with the password is that it only works in a telnet session. There does not seem to be a log in/log out. I am currently using HTML webhooks through IFTTT. The usage is http://USERNAME:password@HA_Link.duckdns.org:9000/anyurl?p0=radiotime&p1=playlist&p2=play&p3=item_id:0.5<lf>&player=XX:XX:XX:XX:XX:XX. But you have to issue it each time. If I use this: | nc 192.168.1.X | \login USERNAME password ) I get a password prompt when I run the script. But it will not take the typed password.

Well, glad to see it worked without authentication. I will take a look at it when I get a chance to see if I can make it work. Will have to play with my setup a bit to try it out.

Ynot

ynot1234567890
2018-10-25, 17:10
I have not been able to get the query to work without authentication. Removing the password protection allows it to work. I think that the main issue with the password is that it only works in a telnet session. There does not seem to be a log in/log out. I am currently using HTML webhooks through IFTTT. The usage is http://USERNAME:password@HA_Link.duckdns.org:9000/anyurl?p0=radiotime&p1=playlist&p2=play&p3=item_id:0.5<lf>&player=XX:XX:XX:XX:XX:XX. But you have to issue it each time. If I use this: | nc 192.168.1.X | \login USERNAME password ) I get a password prompt when I run the script. But it will not take the typed password.

Looking at the way the shell scripts are written, it opens and closes the connection each time it asks for something from the LMS CLI interface. In order to make the login thing work, I believe you would need to issue two lines at each call, the first for login, the second being the request.

As an example:

query=$(printf "artists 0 20 search:$1 tags:a \nexit\n" | nc localhost 9090 )

becomes

query=$(printf "login username password\nartists 0 20 search:$1 tags:a \nexit\n" | nc localhost 9090 )

Give something like that a shot and let me know. Ynot

ynot1234567890
2018-10-26, 15:08
I have not been able to get the query to work without authentication. Removing the password protection allows it to work. I think that the main issue with the password is that it only works in a telnet session. There does not seem to be a log in/log out. I am currently using HTML webhooks through IFTTT. The usage is http://USERNAME:password@HA_Link.duckdns.org:9000/anyurl?p0=radiotime&p1=playlist&p2=play&p3=item_id:0.5<lf>&player=XX:XX:XX:XX:XX:XX. But you have to issue it each time. If I use this: | nc 192.168.1.X | \login USERNAME password ) I get a password prompt when I run the script. But it will not take the typed password.

I have updated the shell LMS query scripts on the GITHUB https://github.com/ynot123/LMS_Controls/tree/master/HomeAssistant/config/shell to allow for username and password on LMS installations.

The script qry_alb_sec.sh should be renamed to replace the existing script qry_alb.sh. Remember to update the username, password, ip address, HA_link and HA_API_Password.
The script qry_alb_song_sec.sh should be renamed to replace the existing script qry_alb_song.sh. Remember to update the username, password, ip address, HA_link and HA_API_Password.

Give that a go, seems to work for me here. Ynot.

The change log for those interested is:

Added an extra line "login username password" to the CLI query to authenticate before executing the query
Replaced nc command with socat for additional flexibility and to allow the connection to stay open to process multiple commands.

Typical query statement would be:
query=$(printf "login username password\nartists 0 20 search:$1 tags:a \n" | socat stdio tcp:192.168.0.XX:9090,shut-none )

bitterroots
2018-10-27, 10:01
I have updated the shell LMS query scripts on the GITHUB https://github.com/ynot123/LMS_Controls/tree/master/HomeAssistant/config/shell to allow for username and password on LMS installations.

The script qry_alb_sec.sh should be renamed to replace the existing script qry_alb.sh. Remember to update the username, password, ip address, HA_link and HA_API_Password.
The script qry_alb_song_sec.sh should be renamed to replace the existing script qry_alb_song.sh. Remember to update the username, password, ip address, HA_link and HA_API_Password.

Give that a go, seems to work for me here. Ynot.

The change log for those interested is:

Added an extra line "login username password" to the CLI query to authenticate before executing the query
Replaced nc command with socat for additional flexibility and to allow the connection to stay open to process multiple commands.

Typical query statement would be:
query=$(printf "login username password\nartists 0 20 search:$1 tags:a \n" | socat stdio tcp:192.168.0.XX:9090,shut-none )

Success!! Thank you. On another note, any chance that you could add playing Favorites and Random Mixes (song, album, artist)?
p0=radiotime& p1=playlist& p2=play& p3=item_id:0.0<lf>&
p0=radiotime& p1=playlist& p2=play& p3=item_id:0.1<lf>&
p0=radiotime& p1=playlist& p2=play& p3=item_id:0.2<lf>&
p0=radiotime& p1=playlist& p2=play& p3=item_id:0.3<lf>&
p0=radiotime& p1=playlist& p2=play& p3=item_id:0.4<lf>&
p0=radiotime& p1=playlist& p2=play& p3=item_id:0.5<lf>&
p0=radiotime& p1=playlist& p2=play& p3=item_id:0.6<lf>&
p0=radiotime& p1=playlist& p2=play& p3=item_id:0.7<lf>&
p0=radiotime& p1=playlist& p2=play& p3=item_id:0.8<lf>&
p0=radiotime& p1=playlist& p2=play& p3=item_id:0.9<lf>&
p0=radiotime& p1=playlist& p2=play& p3=item_id:0.10<lf>&
p0=randomplay& p1=tracks&

ynot1234567890
2018-10-28, 16:16
Success!! Thank you. On another note, any chance that you could add playing Favorites and Random Mixes (song, album, artist)?


Glad it worked out. As for the Favorite and Random mix, I've never really made use of those features in LMS, I use a similar feature with Spotify via LMS.

I will consider the implementation of these LMS features in my Winter upgrade (should have some free time). There are a few other items on the to do list as well.

Stay Tuned. Ynot

holst1966
2018-11-10, 23:31
Hi
Wow, just found your application and realize that this would be a great function to get implemented on my LMS setup that consists of 4 players, however im new to HASSIO and not sure how this should be done.
The lack of interest from the community lately might be due to the level of implementation, at least in my eyes this is a bit complicated.
Also, its actually just now that this can be an option for us in Sweden as we now finally got the google assistant available in stores and also working with Swedish language, dont know if we must change anything in your configuration to get this to work with other languages.

I have installed HASSIO on a PI and i can run it from outside over Duckdns and I understand what to do in the "configuration.yaml"-file but i dont understand where to put the shell files, if this is explained in your instructions then i have missed it completely.

Thanks for your effort, I would love to make this work.

ynot1234567890
2018-11-12, 17:09
Hi
Wow, just found your application and realize that this would be a great function to get implemented on my LMS setup that consists of 4 players, however im new to HASSIO and not sure how this should be done.
The lack of interest from the community lately might be due to the level of implementation, at least in my eyes this is a bit complicated.
Also, its actually just now that this can be an option for us in Sweden as we now finally got the google assistant available in stores and also working with Swedish language, dont know if we must change anything in your configuration to get this to work with other languages.

I have installed HASSIO on a PI and i can run it from outside over Duckdns and I understand what to do in the "configuration.yaml"-file but i don't understand where to put the shell files, if this is explained in your instructions then i have missed it completely.

Thanks for your effort, I would love to make this work.

Hi, I will try to address your items one at a time here. So here goes:


Yes it's a bit complicated to setup, but is quite flexible in what it can do. I still use it all the time for simple music requests. An alternate method would be to use IFTT with Google HOME but I believe LMS installation would then have to be exposed to the internet (not very secure). IFTT approach is not as flexible as the DialogFlow approach.
Didn't know Google Home wasn't available in Sweden until just recently. Not sure how well it functions in Swedish but in English, the AI speech interpreter is excellent and easily picks up the request including (usually) proper spelling of artists names, etc..
Not sure if Google DialogFlow language change is easily done, one fellow here used Italian but was having some trouble making it work I believe. You can certainly re-create the intent in Swedish and proceed that way, automatic language conversion, not so sure.
As for how to install the files, in the GITHUB project under the https://github.com/ynot123/LMS_Controls/tree/master/HomeAssistant/config, all these files need to be modified to suit your application environment. There is a README.md file in that directory that goes through the required changes. You create a sub directory under config directory called shell and this is where the shell files reside.
If you carefully follow the instructions, you should be able to make it work, several others have with little assistance. Bear in mind, the following things need to be completed and functioning to make the full install work: LMS server, Home Assistant (HASSIO), Google Home (or assistant), DialogFlow.


If I might add a bit, while the solution is a bit convoluted, the addition of Home Assistant allows you to create a fully operational home automation system controlling lights, heat, cameras, alarm systems, sprinklers, weather forecasting, who's home. With it you can create all kinds of automation scripts to trigger based on time of day, location of people, mood, weather, activity, etc.. There is significant power and flexibility there. This is why I chose it to control and automate the LMS Server. Home Assistant also functions very well on a phone and the interface to LMS server works pretty well even without Google Home or Assistant.

Just my 2 cents, there is more than one way to "skin the cat", but this method seems to work pretty well for me at least and was a great learning experience.

Ynot.

didjean
2018-11-14, 11:20
Wow, discovering this thread. Thanks for your great work. I really need to test this as soon as I find some time.

To be honest, voice control via Google Home or Alexa is definitely something missing from my Squeezebox experience. This, the LMS web interface and integration with some of the online services show that our beloved Squeezebox setup is getting a tiny bit behind other proposals. But I am still in love with it.

Do you think that your approach could be integrated as a plugin to the Max2Play experience so it would be easy to make it work ?

ynot1234567890
2018-11-14, 17:02
Wow, discovering this thread. Thanks for your great work. I really need to test this as soon as I find some time.

To be honest, voice control via Google Home or Alexa is definitely something missing from my Squeezebox experience. This, the LMS web interface and integration with some of the online services show that our beloved Squeezebox setup is getting a tiny bit behind other proposals. But I am still in love with it.

Do you think that your approach could be integrated as a plugin to the Max2Play experience so it would be easy to make it work ?

Haven't used Max2Play environment so I hesitate to comment on that one. Not sure that a PI can handle all the tasks of LMS server, Home Assistant and LMS player in one go. That being said, you could certainly have an image created to do just that. As for the dialogflow part, that would still be required to be done as it is a cloud based app.

Ynot

kalimeroo
2018-11-21, 09:14
Really great job you did !

Also I am a complete beginner with Hass.io and DialgFlow I will try and reproduce your setup with all the informations/files you kindly provided.

I have one rpi, a google home mini and a squeezebox touch. I would thus need a second rpi in order ro run LMS server or maybe there is a way to define the mysqueezebox.com account in place of the local server in DialogFlow webhook ?

Thanks for your work and sharing it.

Kali

ynot1234567890
2018-11-21, 15:31
Really great job you did !

Also I am a complete beginner with Hass.io and DialgFlow I will try and reproduce your setup with all the informations/files you kindly provided.

I have one rpi, a google home mini and a squeezebox touch. I would thus need a second rpi in order ro run LMS server or maybe there is a way to define the mysqueezebox.com account in place of the local server in DialogFlow webhook ?

Thanks for your work and sharing it.

Kali

That would be best, you could run LMS and HASSIO on the same pi I suppose but you may find performance lacking.

Otherwise an old desktop PC is what I use running:

- Debian server (no X-windows)
- LMS Server
- HASSIO using docker (or not)
- My particular setup also uses Openmediavault as a NAS and bit torrent client

In my opinion, this is usually a better performing setup and access to old PC desktop is usually simple (cheap) enough. In addition, this setup allows you to add other linux functionality and add ons to the mix.

Just my 2 cents. Good luck, Ynot

kalimeroo
2018-11-22, 03:16
Thanks for your suggestion. I currently have a rpi with Digiamp hat running picoreplayer and LMS server.
In the future (when I move home) I will go for a NAS running both LMS and Hassio in containers (or an old PC running this).
I will go for two rpi at the moment (one for Homass and the other for LMS/squeezeplayer).

I will try and document all the processes in details and then make it public (if I succeed ;)) and if you agree of course.

Thx

ynot1234567890
2018-11-22, 04:55
Thanks for your suggestion. I currently have a rpi with Digiamp hat running picoreplayer and LMS server.
In the future (when I move home) I will go for a NAS running both LMS and Hassio in containers (or an old PC running this).
I will go for two rpi at the moment (one for Homass and the other for LMS/squeezeplayer).

I will try and document all the processes in details and then make it public (if I succeed ;)) and if you agree of course.

Thx

That config should work easily enough. Feel free to add to any documentation as you see fit. The basic instructions on the GIT hub should do it, many have tried and most (that I am aware of) have succeeded. Let me know if you need some help. While somewhat convoluted the concepts are easy enough.

Ynot.

hopeful
2018-11-26, 04:08
I am struggling to work out how to specify an API password. I installed Home Assistant using a Pi image and have a password to enter on the web page when I go to http://hassio.local:8123
This isn't the same password as the API password is it? Also, isn't the API password feature is now deprecated?

Do I need to modify the following lines in configuration.yaml and add a line 'api_password: !secret http_password'?

# Uncomment this if you are using SSL/TLS, running in Docker container, etc.
# http:
# base_url: example.duckdns.org:8123

Do I also need to add the following?

auth_providers:
- type: legacy_api_password

Colin

kalimeroo
2018-11-26, 06:01
Hi,

When you first login to Home assistant, it will prompt you with a login ans password. This is not an authentification step. Indeed here you can create a new home assistant user ans its password. You will then use this login/password to effectively login.

hopeful
2018-11-26, 09:41
Hi,

When you first login to Home assistant, it will prompt you with a login ans password. This is not an authentification step. Indeed here you can create a new home assistant user ans its password. You will then use this login/password to effectively login.

Maybe I didn't phrase my question clearly. I created the initial user and password OK and can login, but I believe that that password is not the same one as used for an API password is it? I was asking how to create the API password, and whether I even should, as it appears to be deprecated.

ynot1234567890
2018-11-26, 19:50
I am struggling to work out how to specify an API password. I installed Home Assistant using a Pi image and have a password to enter on the web page when I go to http://hassio.local:8123
This isn't the same password as the API password is it? Also, isn't the API password feature is now deprecated?

Do I need to modify the following lines in configuration.yaml and add a line 'api_password: !secret http_password'?

# Uncomment this if you are using SSL/TLS, running in Docker container, etc.
# http:
# base_url: example.duckdns.org:8123

Do I also need to add the following?

auth_providers:
- type: legacy_api_password

Colin

In the configuration.yaml file the following entry is required in the http section to set the API password:

http:
# Secrets are defined in the file secrets.yaml
api_password: !secret http_password
# Uncomment this if you are using SSL/TLS, running in Docker container, etc.
base_url: !secret base_url
ssl_certificate: /ssl/fullchain.pem
ssl_key: /ssl/privkey.pem

In my secrets.yaml file the following entries:

http_password: HA_API_Password
base_url: https://HA_Link.duckdns.org


Hope that helps. Ynot.

kalimeroo
2018-11-27, 10:04
@Hopeful Sorry, I misunderstood your issue.

Setting a Legacy PI password works fine but will indeed be dropped (https://www.home-assistant.io/docs/authentication/providers/).

@ynot

I think I have set up the Home Assistant (Hassbian) and LMS fine on my Rpi. You state that you created a playlist for the radio station. Could you please let me know where to store this playlist and its name.

Thanks

ynot1234567890
2018-11-27, 19:36
@Hopeful Sorry, I misunderstood your issue.

Setting a Legacy PI password works fine but will indeed be dropped (https://www.home-assistant.io/docs/authentication/providers/).

@ynot

I think I have set up the Home Assistant (Hassbian) and LMS fine on my Rpi. You state that you created a playlist for the radio station. Could you please let me know where to store this playlist and its name.

Thanks

To create a radio station playlist I simply use the LMS web frontend and:


Add a radio station to a player
Save it as a playlist using the following naming convention Radio_StationName


Some of my examples are: Radio_Cbc, Radio_Q92, Radio_Country_Classics.

These radio stations can be invoked by saying "Hey Google, ask LMS Controls to play radio station cbc". It will queue up the playlist "Radio_Cbc" on the default player.

Ynot.

hopeful
2018-11-28, 03:41
Following the guide troubleshooting.md I can successfully fill out the source and artist fields and select the play artist function and the player starts playing. However, the same doesn't work for play album or play playlist?

Colin

ynot1234567890
2018-11-28, 18:31
Following the guide troubleshooting.md I can successfully fill out the source and artist fields and select the play artist function and the player starts playing. However, the same doesn't work for play album or play playlist?

Colin

For the album issue, I assume you are using source LMS. Ensure the shell script is working properly and returning the proper sensor.alb_id and sensor.art_id properly. Note there are 2 types of shell scripts, those using "secure" versions of LMS, these require the login and the script names end in _sec. For those using the normal version of LMS (no login) the regular scripts should work.

As for the play playlist, I may have neglected to mention the playlist naming format should not contain spaces, use _ instead. (ie: country_classics).

Personally I use spotify source most of the time so don't use the LMS source too often.

Hope that helps. Ynot.

hopeful
2018-12-01, 07:48
The result of running the qry_alb.sh script directly:

bash-4.4# bash qry_alb.sh _supertramp _crisis_what_crisis?

Artists are:

Artist check zero is:

qry_alb.sh: line 14: [: ==: unary operator expected

Artist found so moving on to albums....

Album check zero is: 0


Albums are:
albums 0 20 artist_id%3A search%3A_crisis_what_crisis%3F tags%3Aal count%3A0

no album match setting ID to 0

Artist ID is:
Album ID is: 0
now Posting results

{"attributes": {}, "context": {"id": "e2b25b8b1eb1469e9948916ad73d9d49", "user_id": null}, "entity_id": "sensor.art_id", "last_changed": "2018-12-01T14:06:38.145783+00:00", "last_updated": "2018-12-01T14:06:38.145783+00:00", "state": ""}
{"attributes": {}, "context": {"id": "1820e0c4fa374c0ca6d47f5e7525c013", "user_id": null}, "entity_id": "sensor.alb_id", "last_changed": "2018-12-01T14:06:38.548493+00:00", "last_updated": "2018-12-01T14:06:38.548493+00:00", "state": "0"}

ynot1234567890
2018-12-01, 08:11
The result of running the qry_alb.sh script directly:

bash-4.4# bash qry_alb.sh _supertramp _crisis_what_crisis?


Artist ID is:
Album ID is: 0
now Posting results

{"attributes": {}, "context": {"id": "e2b25b8b1eb1469e9948916ad73d9d49", "user_id": null}, "entity_id": "sensor.art_id", "last_changed": "2018-12-01T14:06:38.145783+00:00", "last_updated": "2018-12-01T14:06:38.145783+00:00", "state": ""}
{"attributes": {}, "context": {"id": "1820e0c4fa374c0ca6d47f5e7525c013", "user_id": null}, "entity_id": "sensor.alb_id", "last_changed": "2018-12-01T14:06:38.548493+00:00", "last_updated": "2018-12-01T14:06:38.548493+00:00", "state": "0"}

Looks like your script isn't working and may have a typo or something in it. If you want, you can forward me a copy of the script and also let me know if you're using the secure (login) or unsecure version of LMS. This is the reason you're not getting an album. I ran the command on my system and it returned supertramp and crisis what crisis as the album. Also for future use, lose the ? as this would not normally come through in a voice command

My email is yland@vianet.ca

Ynot.

hopeful
2018-12-01, 09:41
Doh! As I was preparing to send you my script and replacing the IP address and DuckDNS ID with asterisks, I noticed that I'd missed replacing a 'localhost' entry in the original file. It works now - sorry about that.

One thing that may help others is the problem I had before this. If using Windows to create and edit the shell script files before copying them across to a Pi, make sure that the editor, e.g. Notepad++, is configured to just use LF for end-of-line characters, rather than the Windows default of CR LF.

ynot1234567890
2018-12-01, 11:57
Doh! As I was preparing to send you my script and replacing the IP address and DuckDNS ID with asterisks, I noticed that I'd missed replacing a 'localhost' entry in the original file. It works now - sorry about that.

One thing that may help others is the problem I had before this. If using Windows to create and edit the shell script files before copying them across to a Pi, make sure that the editor, e.g. Notepad++, is configured to just use LF for end-of-line characters, rather than the Windows default of CR LF.

Good stuff glad to hear it worked out. Usually the issues are something simple like that. Hopefully this winter I can take the time to write a small config script that would make the changes automatically based on answered options to avoid some of the grunt work. Might need a bit more time and talent to pull it off though. I don't do a whole lot of coding these days.
:)


Ynot

ynot1234567890
2018-12-02, 08:00
Please note if you upgrade your Home Assistant installation to version 0.83.2 the use of api_password is no longer supported (as pointed out by @kalimeroo) and your webhooks and shell script authentication will need to change to use long-lived tokens.

I will provide an update on the methods in the GitHub https://github.com/ynot123/LMS_Controls over the next week or two. The change is not very complicated but will require an update in several locations including the shell scripts and DialogFlow webhooks.

Ynot.

kalimeroo
2018-12-02, 10:05
Concerning the end of line character if using windows to edit the files, it can also be fixed whith the dos2unix tool.

I added the following lines in order to force API password usage:

homeassistant:
auth_providers:
- type: legacy_api_password

http:
api_password: !secret http_password

The search scripts work fine but I fails to issue the curl command to homeassistant.
If I put the following in the script I get a 405 error:
curl -X POST -d '{"state":"'"${art_id}"'"}' http://myserver.duckdns.org:8123/api/states/sensor.art_ID?api_password=API_password

If I change to curl -X POST -d '{"state":"'"${art_id}"'"}' http://myserver.duckdns.org/api/states/sensor.art_ID?api_password=API_password, I end up with a 401 error.

ynot1234567890
2018-12-03, 07:06
Concerning the end of line character if using windows to edit the files, it can also be fixed whith the dos2unix tool.

I added the following lines in order to force API password usage:

homeassistant:
auth_providers:
- type: legacy_api_password

http:
api_password: !secret http_password

The search scripts work fine but I fails to issue the curl command to homeassistant.
If I put the following in the script I get a 405 error:
curl -X POST -d '{"state":"'"${art_id}"'"}' http://myserver.duckdns.org:8123/api/states/sensor.art_ID?api_password=API_password

If I change to curl -X POST -d '{"state":"'"${art_id}"'"}' http://myserver.duckdns.org/api/states/sensor.art_ID?api_password=API_password, I end up with a 401 error.

The scripts can be modified for the new long lived token if needed. But first:

what version of HA are you using and
is your LMS flavour secure (you need to login) or unsecure (it just works).

If you want a copy of a working shell script, let me know as this is still a work in progress. I am having issues getting dialogflow to work with HA and long lived tokens. I am getting error 206 (Malformed response) from Google actions (dialogflow). Voice commands work, but dialogflow isn't happy with the response from HA and as a result stops responding.

Ynot.
(So many changes, sol little time)

kalimeroo
2018-12-03, 09:50
Hi,

I am running Hassbian with Home Assistant v0.83.2.

When running the qry_alb.sh script it returns successfully the ID number of the artist and album (LMS server is not secured as far as I know).

The issue is on the curl POST request which returns the error 401.

I tested :

$ curl -X POST -H "Authorization: Bearer ABCDEFGH" \
-H "Content-Type: application/json" \
-d '{"state": "25", "attributes": {"unit_of_measurement": "įC"}}' \
http://localhost:8123/api/states/sensor.kitchen_temperature

and this worked out fine so I tryed modifying yout curl request but this resulted in "curl illegal port number" and error 405

ynot1234567890
2018-12-03, 18:39
Hi,

I am running Hassbian with Home Assistant v0.83.2.

When running the qry_alb.sh script it returns successfully the ID number of the artist and album (LMS server is not secured as far as I know).

The issue is on the curl POST request which returns the error 401.

I tested :

$ curl -X POST -H "Authorization: Bearer ABCDEFGH" \
-H "Content-Type: application/json" \
-d '{"state": "25", "attributes": {"unit_of_measurement": "įC"}}' \
http://localhost:8123/api/states/sensor.kitchen_temperature

and this worked out fine so I tryed modifying yout curl request but this resulted in "curl illegal port number" and error 405

Below is the proposed shell script mods to accommodate the long lived token:

HA_token=ThisIsMyLongLivedToken
curl -X POST -d '{"state":"'"${art_id}"'"}' https://HA_Link.duckdns.org/api/states/sensor.art_ID? -H "Authorization: Bearer $HA_token"
echo
curl -X POST -d '{"state":"'"${alb_id}"'"}' https://HA_Link.duckdns.org/api/states/sensor.alb_ID? -H "Authorization: Bearer $HA_token"
echo
curl -X POST -d '{"state":"'"${name}"'"}' https://HA_Link.duckdns.org/api/states/sensor.lms_name? -H "Authorization: Bearer $HA_token"
echo
Give that a shot.
Ynot

kalimeroo
2018-12-04, 01:55
Thanks a lot for your time and efforts. The authentification with the long lasting token (generetad in https://your_server.duckdns.org/profile) works like a charm. I just had to specify the 8123 port as my router does not handle port forwarding correctly.

I can now move on with the Google part.

ynot1234567890
2018-12-04, 06:22
Thanks a lot for your time and efforts. The authentification with the long lasting token (generetad in https://your_server.duckdns.org/profile) works like a charm. I just had to specify the 8123 port as my router does not handle port forwarding correctly.

I can now move on with the Google part.
Glad to hear that. So now you have a basic LMS front-end that works anywhere in a secure fashion. ;)

As for the Google DialogFlow part, something has changed in the last week or so, either with DialogFlow / Google Actions and / or Home Assistant resulting in a webhook error 206 (at least on my system) causing the Dialogflow (Google) part to work for only the first command and then the app returns the message "LMS control is available right now, please try again later". The command actually gets processed (so volume goes up, song gets queued, etc..) but the feedback no longer works (ie: "Setting the volume to 20"). So it is functional (sort of) with one command at a time and no feedback

I will try to solve it fairly soon, but integrating 3 pieces of software I have little control over is proving a bigger task than I hoped for. If you have time, give it a shot and let me know how you make out. I will post if I make significant progress in this issue.

By the way: If you are using long lived tokens with Dialogflow the fullfilment URL should look something like: https://HA_Link.duckdns.org/api/services/script/lms_control with the Header field: Key=Authorization Value=Bearer insertyourtokenhere

Ynot

ynot1234567890
2018-12-05, 05:13
I will try to solve it fairly soon, but integrating 3 pieces of software I have little control over is proving a bigger task than I hoped for. If you have time, give it a shot and let me know how you make out. I will post if I make significant progress in this issue.

Ynot

Took another look at it. Made some progress, the Webhook function in DialogFlow no longer works properly using the brute force method I used previously :mad:.

I did manage however to make HA and DialogFlow work using proper intent structures and long-lived tokens (rather than the deprecated API_Password) which in the end will be a lot more flexible allowing additional new features like "What's playing in the kitchen?". It will however require some re-structuring of code on the HA side of things. Should have a working prototype back online in the near future.

The only drawback I see so far is HA support only V1 of the DialogFlow API. Another change will be required when V2 becomes supported.

Ynot.

kalimeroo
2018-12-05, 09:59
I probably experience the same issue.
I went on and created an action on google console and then created a new project and then an action in Dialogflow.
When testing the app in Dialogflow in works fine but if I then integrate it to google assistant and run the test I get the error "LMS control isn't responding right now. Try again soon."

During the integration step if I change the Explicit invocation from "Default Welcome intent" to any other intent it will respond once and then fallback to the error message (If I set the intent to "play_album" it responds "Alright. Getting the test version of LMS control.Which radio station ") .

The home-assistant.log file contains a line of ^@^@^@^@^@^@^@^@^@^@^@ so I guess there is some kind of communication.

ynot1234567890
2018-12-05, 13:08
@kalimeroo, That is exactly the issue. As mentioned above, in order to make this work now, the dialogflow method has to be implemented properly using HA intents, returning a valid JSON to Google Assistant. I will likely create a short term patch to make it work as it was, then do a better job of re-structuring the HA code to suit this method and add a few new features like feedback of query results and allow a more feedback from HA like:

"What's playing in the kitchen", which would return name of artist, album and song
"Who's at home"
" What's the temperature in the house"
And whatever else HA happens to know

I should have something workable fairly soon. Will keep you posted. If you send me an email address, perhaps I can share the first rough draft as you already have the backend working with Long-lived tokens. yland@vianet.ca

ynot.

hopeful
2018-12-07, 08:20
I'm curious to know how the Google Assistant recognises the intent 'LMS Controls' in order to start the app. If I wanted to change the name, could I do that and, if so, where? So, for example, I could say 'Hey google ask Vortexbox to play album Dog and Butterfly by Heart in the kitchen with shuffle on'

And thanks for an exciting project!

Colin

kalimeroo
2018-12-07, 08:43
When you create a google application you create an action (in this case it will be Dialogflow). You can decide the way your action is triggered. It requires two words (Vortexbox won't work but Vortex box will) so you can use "Ok google, tell Vortex Box to play nirvana in the kitchen".

hopeful
2018-12-07, 08:55
You can decide the way your action is triggered. It requires two words .
So where is that string and can it be edited after the application has been created?

kalimeroo
2018-12-07, 09:28
You log on to your https://console.actions.google.com/ and you select your action. On the left panel you'll get the "Invocation" menu where you can change your trigger phrase.

hopeful
2018-12-07, 09:39
You log on to your https://console.actions.google.com/ and you select your action. On the left panel you'll get the "Invocation" menu where you can change your trigger phrase.

But I haven't created the LMS Controls action, ynot has, hasn't he? If I log on to that URL, there is no action to select.

Sorry if I'm being dumb.

ynot1234567890
2018-12-07, 12:05
But I haven't created the LMS Controls action, ynot has, hasn't he? If I log on to that URL, there is no action to select.

Sorry if I'm being dumb.

You will need to create your own action, calling your own url, with your webhook, etc.. You can name it whatever you want as outlined previously, set the invocation to whatever you would like. I won't publish the action as an available app to all users because I do not want to be responsible for everyone's stuff, passwords, links, authentication, etc... Don't have the infrastructure for it and of course I am doing this for free with no implied warranty. :)

If you hang tough for a week or so (hopefully) I will publish another revision using the new long lived tokens and security model for Home Assistant as well as proper webhook syntax that is now required with the upgrades at HA, Google and DialogFlow.

Ynot.

hopeful
2018-12-08, 07:32
If you haven't published the action as an available app to all users and I haven't created an action, how does Google Assistant recognise the phrase 'LMS Controls' at the moment?

ynot1234567890
2018-12-08, 08:03
If you haven't published an action to be available to all and I haven't created an action from the console, how does Google Assistant recognize the phrase 'LMS Control'?

Hum, not sure. I did indeed publish it as an alpha action only which should only appear to those I invite. Did a quick check using another google account and the action did not show up on the web for that account, but the action name (LMS Controls) is reserved for me.

So did you build the DialogFlow part of the project and test it on google actions? If yes that is likely how the action came to be available.

Otherwise, not quite sure where you got the action from. Sorry.

hopeful
2018-12-08, 08:41
Bearing in mind that this is all new to me, are my following assumptions correct ...
1. Following your complete set of instructions, provided that I'm happy to use the phrase 'LMS Controls', I wouldn't need to create an Action from https://console.actions.google.com/ , because the DialogFlow part somehow sees the Alpha action that you published?
2. If I wanted to use a different phrase to connect to the LMS Controls app, I would need to create a new Action from https://console.actions.google.com/ . I would need to associate this with the existing DialogFlow project somehow.

ynot1234567890
2018-12-08, 13:30
Good news, the LMS Controls project (see here (https://github.com/ynot123/LMS_Controls)) has been updated to incorporate the new Home Assistant authentication system. This project now uses Long Lived Access Tokens to authenticate between Google DialogFlow and Home Assistant.

In addition, changes at Google and HA have required a different (proper) implementation of the webhooks method for the two applications.

For those who have already installed this project and simply want a short cheat sheet on how to update your current installation, please see here: https://github.com/ynot123/LMS_Controls/blob/master/cheatsheet.md

For those starting fresh, please go to the project's GitHub (see here (https://github.com/ynot123/LMS_Controls)) and follow the instructions.

Thanks and enjoy.

Ynot.

ynot1234567890
2018-12-08, 13:43
Bearing in mind that this is all new to me, are my following assumptions correct ...
1. Following your complete set of instructions, provided that I'm happy to use the phrase 'LMS Controls', I wouldn't need to create an Action from https://console.actions.google.com/ , because the DialogFlow part somehow sees the Alpha action that you published?
2. If I wanted to use a different phrase to connect to the LMS Controls app, I would need to create a new Action from https://console.actions.google.com/ . I would need to associate this with the existing DialogFlow project somehow.

Hi Hopeful,

Not sure how far along you are with the config for the project. I have just released an update that deals with a security issue for HA version 0.83 and up that causes problems with the shell scripts and dialogflow programs. Please take a quick look at that and start the installation as outlined in the refreshed readme.md files. In there you should find all the details you need to make this work. As for the DialogFlow part, everyone needs to login into Dialogflow and build the Agent (from my zip file), fill in the url and token details, then test it in Google Assistant (which creates the Google action).

If you are still having difficulty after that, send me an email at yland@vianet.ca and I can try to help sort it out with you. In the email, please include, HA version and how far you have gotten in the process which is:

First step - Build the HA part and test interface to LMS using HA GUI interface. This will tell you if the shell scripts are working, if HA is talking to LMS, etc..
Second step is - Build and test Dialogflow part which is the interface between GoogleHome and HA

Hope that helps clear it up a bit. Ynot.

dclbas
2018-12-14, 23:33
Thanks ynot123 for creating the Google Assistant voice control for LMS. I'm a newbie setting up Hassio and have been following your instructions on how to get Google Voice working. I did have a question regarding how to setup the Webhooks, you mention:

"Fill in the URL field with "https://homeassistant.duckdns.org/api/webhook/insert_your_webhook_id_here" replacing homeassistant with your HA internet link and insert_your_webhook_id_here with your Webhook ID provided by the HA DialogFlow integration component."

I've setup duckdns and presume that I'll use my duckdns domain for "homeasstant," but how do I obtain or get a Webhook ID setup in HA? When I go to "Set up a new integration" for Dialogflow, I get the following message:

Aborted
Your Home Assistant instance needs to be accessible from the internet to receive Dialogflow messages.

What am I doing wrong?

Thanks in advance for your help!

hopeful
2018-12-15, 03:50
Is your HA server accessible from the internet, e.g. from a mobile 'phone using 4G and not the local wi-fi network? You need to be able to get to it externally using 'mydomain.duckdns.org'

If not, here's what I had to do:
1. In the DuckDNS add-in, configure your DuckDNS token and domain name and set accept_terms to true
2. In configuration.yaml, the following is required (using your own domain name and ip address subnet - the trusted networks bit is not essential):
http:
base_url: https://mydomain.duckdns.org
ssl_certificate: /ssl/fullchain.pem
ssl_key: /ssl/privkey.pem
trusted_networks:
- 192.168.0.0/24

3. On your router, forward port 443 to 8123

Cheers
Colin

ynot1234567890
2018-12-15, 06:57
Hi dclbas:

For those starting from scratch, as Hopeful mentioned, step 1 is to ensure your HA instance is fully accessible from the internet using https://mydomain.duckdns.org, Hopefuls instructions should help you there.

Step 2: Is setup the HA access long lived access tokens

Step 3: Modify the shell files for your domain and HA token from above. Enusre you have a : between Authorization and Bearer in the shell files. It is required apparently on some systems

Step 4: Test HA GUI with LMS server and ensure you can play, add, volume, pause, etc.. form the GUI both on your internal network and the internet

Step 5: Setup DialogFlow / Google Home links.

Good luck. For support you can try here or my email yland@vianet.ca Ynot.

dclbas
2018-12-15, 09:50
Hi dclbas:

For those starting from scratch, as Hopeful mentioned, step 1 is to ensure your HA instance is fully accessible from the internet using https://mydomain.duckdns.org, Hopefuls instructions should help you there.

Step 2: Is setup the HA access long lived access tokens

Step 3: Modify the shell files for your domain and HA token from above. Enusre you have a : between Authorization and Bearer in the shell files. It is required apparently on some systems

Step 4: Test HA GUI with LMS server and ensure you can play, add, volume, pause, etc.. form the GUI both on your internal network and the internet

Step 5: Setup DialogFlow / Google Home links.

Good luck. For support you can try here or my email yland@vianet.ca Ynot.

Thanks Hopefuls and Ynot for your replies. Yes, I did setup HA for external access using duckdns but I also used NGINX so that I could access HA locally without having to use https, but apparently this does not allow Dialogflow to see it externally. So I removed NGINX and now am able to configure Dialogflow.

dclbas
2018-12-15, 09:54
Is your HA server accessible from the internet, e.g. from a mobile 'phone using 4G and not the local wi-fi network? You need to be able to get to it externally using 'mydomain.duckdns.org'

If not, here's what I had to do:
1. In the DuckDNS add-in, configure your DuckDNS token and domain name and set accept_terms to true
2. In configuration.yaml, the following is required (using your own domain name and ip address subnet - the trusted networks bit is not essential):
http:
base_url: https://mydomain.duckdns.org
ssl_certificate: /ssl/fullchain.pem
ssl_key: /ssl/privkey.pem
trusted_networks:
- 192.168.0.0/24

3. On your router, forward port 443 to 8123

Cheers
Colin

Thanks Colin for your instructions, what does the last lines do?

trusted_networks:
- 192.168.0.0/24

What IP address do I use for the trusted_networks, my raspberrypi address?

Thanks

hopeful
2018-12-15, 10:13
Thanks Colin for your instructions, what does the last lines do?

trusted_networks:
- 192.168.0.0/24

What IP address do I use for the trusted_networks, my raspberrypi address?

Thanks
It's documented here:

https://www.home-assistant.io/docs/authentication/providers/

The final zero in the IP address is a wildcard. It means that any device with an IP address beginning with 192.68.0 connecting to your HA server is trusted and you shouldn't have to sign on.

dclbas
2018-12-15, 16:15
It's documented here:

https://www.home-assistant.io/docs/authentication/providers/

The final zero in the IP address is a wildcard. It means that any device with an IP address beginning with 192.68.0 connecting to your HA server is trusted and you shouldn't have to sign on.

Thanks!

dclbas
2018-12-16, 21:35
Hi dclbas:

For those starting from scratch, as Hopeful mentioned, step 1 is to ensure your HA instance is fully accessible from the internet using https://mydomain.duckdns.org, Hopefuls instructions should help you there.

Step 2: Is setup the HA access long lived access tokens

Step 3: Modify the shell files for your domain and HA token from above. Enusre you have a : between Authorization and Bearer in the shell files. It is required apparently on some systems

Step 4: Test HA GUI with LMS server and ensure you can play, add, volume, pause, etc.. form the GUI both on your internal network and the internet

Step 5: Setup DialogFlow / Google Home links.

Good luck. For support you can try here or my email yland@vianet.ca Ynot.

While setting up the fullfillment section under dialogflow, I had another question for the Webhooks instruction:

"In the Headers section, replace insert_your_long_lived_token_here with your long lived access token ID generated by Home Assistant."

What do I put in for the "Enter key" entry, and for the "insert_your_long_lived_token_here" is it my duckdns token or where is it generated by Home Assistant?

Thanks in advance for you help.

ynot1234567890
2018-12-17, 06:50
While setting up the fulfillment section under dialogflow, I had another question for the Webhooks instruction:

"In the Headers section, replace insert_your_long_lived_token_here with your long lived access token ID generated by Home Assistant."

What do I put in for the "Enter key" entry, and for the "insert_your_long_lived_token_here" is it my duckdns token or where is it generated by Home Assistant?

Thanks in advance for you help.

I assume you generated a long lived token already for the shell scripts to use with HA_Token entry. If not, to generate a long lived token, go to your HA GUI, click on the 3 bars in left hand corner of the GUI and this will call up the side menu, then click on the username at the top in my case it's "yl". This will call up the user profile, scroll down to Long Lived Access tokens and create a token for This application (mine is called Shell_DialogFlow) to help me remember what it's for.

When you do this you will get a long string of values which is your token. Copy it and put it some place safe so you can use it for the shell scripts and DialogFlow. This is basically the password to access HA for these two applications.

I also assume in HA GUI, you have setup the integration for DialogFlow Webhook which when enabled will give you a unique Webhook_ID to access HA. This is located on the menu under Configuration then Integration. Save this WebHook_ID for use in DialogFlow


Your fulfillment link in DialogFlow should look like:


URL: https://Your_domain.duckdns.org/api/webhook/Your_web_hook_id
Headers: Authorization Bearer Your_long_lived_access_token
Content-Type application/json
DOMAINS: Enable webhook for all domains

Ynot.

dclbas
2018-12-17, 19:38
I assume you generated a long lived token already for the shell scripts to use with HA_Token entry. If not, to generate a long lived token, go to your HA GUI, click on the 3 bars in left hand corner of the GUI and this will call up the side menu, then click on the username at the top in my case it's "yl". This will call up the user profile, scroll down to Long Lived Access tokens and create a token for This application (mine is called Shell_DialogFlow) to help me remember what it's for.

When you do this you will get a long string of values which is your token. Copy it and put it some place safe so you can use it for the shell scripts and DialogFlow. This is basically the password to access HA for these two applications.

I also assume in HA GUI, you have setup the integration for DialogFlow Webhook which when enabled will give you a unique Webhook_ID to access HA. This is located on the menu under Configuration then Integration. Save this WebHook_ID for use in DialogFlow


Your fulfillment link in DialogFlow should look like:


URL: https://Your_domain.duckdns.org/api/webhook/Your_web_hook_id
Headers: Authorization Bearer Your_long_lived_access_token
Content-Type application/json
DOMAINS: Enable webhook for all domains

Ynot.

Thanks Ynot, it really helps to see the configuration entries for DialogFlow.

dclbas
2018-12-17, 21:51
I assume you generated a long lived token already for the shell scripts to use with HA_Token entry. If not, to generate a long lived token, go to your HA GUI, click on the 3 bars in left hand corner of the GUI and this will call up the side menu, then click on the username at the top in my case it's "yl". This will call up the user profile, scroll down to Long Lived Access tokens and create a token for This application (mine is called Shell_DialogFlow) to help me remember what it's for.

When you do this you will get a long string of values which is your token. Copy it and put it some place safe so you can use it for the shell scripts and DialogFlow. This is basically the password to access HA for these two applications.

I also assume in HA GUI, you have setup the integration for DialogFlow Webhook which when enabled will give you a unique Webhook_ID to access HA. This is located on the menu under Configuration then Integration. Save this WebHook_ID for use in DialogFlow


Your fulfillment link in DialogFlow should look like:


URL: https://Your_domain.duckdns.org/api/webhook/Your_web_hook_id
Headers: Authorization Bearer Your_long_lived_access_token
Content-Type application/json
DOMAINS: Enable webhook for all domains

Ynot.

Thanks Ynot for the clarification and sharing the DialogFlow configuration.

dclbas
2018-12-17, 21:52
I assume you generated a long lived token already for the shell scripts to use with HA_Token entry. If not, to generate a long lived token, go to your HA GUI, click on the 3 bars in left hand corner of the GUI and this will call up the side menu, then click on the username at the top in my case it's "yl". This will call up the user profile, scroll down to Long Lived Access tokens and create a token for This application (mine is called Shell_DialogFlow) to help me remember what it's for.

When you do this you will get a long string of values which is your token. Copy it and put it some place safe so you can use it for the shell scripts and DialogFlow. This is basically the password to access HA for these two applications.

I also assume in HA GUI, you have setup the integration for DialogFlow Webhook which when enabled will give you a unique Webhook_ID to access HA. This is located on the menu under Configuration then Integration. Save this WebHook_ID for use in DialogFlow


Your fulfillment link in DialogFlow should look like:


URL: https://Your_domain.duckdns.org/api/webhook/Your_web_hook_id
Headers: Authorization Bearer Your_long_lived_access_token
Content-Type application/json
DOMAINS: Enable webhook for all domains

Ynot.

Thanks Ynot for the clarification and DialogFlow configurations.

CypherMK
2018-12-25, 15:00
Hi ynot,

Finally got some time to get this running. Thanks for the guide.

But I'm running into some problems with setting this up. I think I have done everything right, but I can't use the artist, song etc fields in HA GUI as explained in the troubleshooting guide.

If that works then fill out the source and artist fields and select the play artist function and ensure it gets queued to your selected player and starts playing. After the command launches the command window returns to ____________ command.
Nothing happens. The rest works: volume, shuffle, repeat etc.

Next I want to try the shell commands, but where do I do this? Command line? When I do this in the command line:
bash-4.4# bash qry_alb.sh _supertramp _breakfast_in_america
I get: command not found

I have no clue how to continue. Can you help me?

Thanks you!

hopeful
2018-12-26, 02:05
Did you change directories before running the command?
cd config/shell

CypherMK
2018-12-26, 02:39
Did you change directories before running the command?
cd config/shell

I did, but did I put the "shell" files in the correct directory? I put them in: /home/homeassistant/.homeassistant/shell
Is that correct?

CypherMK
2018-12-26, 08:49
Managed to run it, and this is the outcome:


osmc@osmc:/home/homeassistant/.homeassistant/shell$ bash qry_alb.sh _supertramp _breakfast_in_america
Artists are:
artists 0 20 search%3A_supertramp tags%3Aa id%3A14404 artist%3ASupertramp count%3A1

Artist check zero is: 1


Artist found so moving on to albums....

Album check zero is: 5


Albums are:
albums 0 20 artist_id%3A14404 search%3A_breakfast_in_america tags%3Aal id%3A7747 album%3ABreakfast%20In%20America%20(Shm-Cd) artist%3ASupertramp id%3A8050 album%3A16%20Jaar%20Radio%202%20Top%202000 artist%3ADiverse%20artiesten id%3A7748 album%3AParis%20%7BLive%7D artist%3ASupertramp id%3A7749 album%3AParis%20(Shm-Cd)%20%7BLive%7D artist%3ASupertramp id%3A7750 album%3ARetrospectable%20-%20The%20Supertramp%20Anthology%20%7BAnthology%7D artist%3ASupertramp count%3A5

Artist ID is:14404
Album ID is: 7747
Name is: Breakfast In America (Shm-Cd)
now Posting results

curl: (7) Failed to connect to mydomain.duckdns.org port 443: Connection refused

curl: (7) Failed to connect to mydomain.duckdns.org port 443: Connection refused

curl: (7) Failed to connect to mydomain.duckdns.org port 443: Connection refused

CypherMK
2018-12-26, 10:06
Managed to run it, and this is the outcome:


osmc@osmc:/home/homeassistant/.homeassistant/shell$ bash qry_alb.sh _supertramp _breakfast_in_america
Artists are:
artists 0 20 search%3A_supertramp tags%3Aa id%3A14404 artist%3ASupertramp count%3A1

Artist check zero is: 1


Artist found so moving on to albums....

Album check zero is: 5


Albums are:
albums 0 20 artist_id%3A14404 search%3A_breakfast_in_america tags%3Aal id%3A7747 album%3ABreakfast%20In%20America%20(Shm-Cd) artist%3ASupertramp id%3A8050 album%3A16%20Jaar%20Radio%202%20Top%202000 artist%3ADiverse%20artiesten id%3A7748 album%3AParis%20%7BLive%7D artist%3ASupertramp id%3A7749 album%3AParis%20(Shm-Cd)%20%7BLive%7D artist%3ASupertramp id%3A7750 album%3ARetrospectable%20-%20The%20Supertramp%20Anthology%20%7BAnthology%7D artist%3ASupertramp count%3A5

Artist ID is:14404
Album ID is: 7747
Name is: Breakfast In America (Shm-Cd)
now Posting results

curl: (7) Failed to connect to mydomain.duckdns.org port 443: Connection refused

curl: (7) Failed to connect to mydomain.duckdns.org port 443: Connection refused

curl: (7) Failed to connect to mydomain.duckdns.org port 443: Connection refused



Ok, got it working. Forwarded port 433 to 8123 in my router as mentioned in this thread somewhere. Let's see if I get the rest to work.

CypherMK
2018-12-26, 10:24
Putting an artist or song etc in the HA GUI doesn't add songs to the playlist...

ynot1234567890
2018-12-27, 18:31
Putting an artist or song etc in the HA GUI doesn't add songs to the playlist...

Hi, sorry for the late reply, been on holidays with little time or access. But I see Hopeful has been helping out nicely, thank you. How did you make out. I assume you got the shell scripts running properly by changing the port routing 443 to 8123 and updating mydomain.duckdns.org to your proper url link and HA token. Judging from the posted response, the query part worked correctly but posting of the results to HA sensors did not due to bad URL, port and / or HA token

I will try to keep an eye out when I get a chance if there are any further questions. Again unfortunately my access may be limited for the next few days.

Ynot

ynot1234567890
2018-12-27, 18:37
I did, but did I put the "shell" files in the correct directory? I put them in: /home/homeassistant/.homeassistant/shell
Is that correct?

The shell files go in the config/shell directory as indicated in the configuration.yaml file. Ynot.

CypherMK
2018-12-28, 01:55
The shell files go in the config/shell directory as indicated in the configuration.yaml file. Ynot.So it should be: /home/homeassistant/. homeassistant/config/shell.

Thanks for helping!

ynot1234567890
2018-12-28, 06:03
So it should be: /home/homeassistant/. homeassistant/config/shell.

Thanks for helping!

I guess so if that's how your system is configured. I am using docker and in that install it's simply /config/shell. You may need to update the path to the shell files in configuration.yaml file to ensure they get executed. For the next revision I will try to use relative paths to avoid this issue,


shell_command:
lms_qry_alb: 'bash /config/shell/qry_alb.sh {{text1}} {{text2}}'
lms_qry_alb_song: 'bash /config/shell/qry_alb_song.sh {{text1}} {{text2}} {{text3}}'
lms_spot_art: 'bash /config/shell/spot_art_top.sh {{text1}}'
lms_spot_art_alb: 'bash /config/shell/spot_art_alb.sh {{text1}} {{text2}}'
lms_spot_art_alb_song: 'bash /config/shell/spot_art_alb_song.sh {{text1}} {{text2}} {{text3}}'
lms_spot_playlist: 'bash /config/shell/spot_playlist.sh {{text1}}'

You will know if the shell files get executed if the album_id, song_id sensors get updated and obviously if the song and album functions are queuing to LMS properly.

CypherMK
2018-12-28, 17:13
I guess so if that's how your system is configured. I am using docker and in that install it's simply /config/shell. You may need to update the path to the shell files in configuration.yaml file to ensure they get executed. For the next revision I will try to use relative paths to avoid this issue,


shell_command:
lms_qry_alb: 'bash /config/shell/qry_alb.sh {{text1}} {{text2}}'
lms_qry_alb_song: 'bash /config/shell/qry_alb_song.sh {{text1}} {{text2}} {{text3}}'
lms_spot_art: 'bash /config/shell/spot_art_top.sh {{text1}}'
lms_spot_art_alb: 'bash /config/shell/spot_art_alb.sh {{text1}} {{text2}}'
lms_spot_art_alb_song: 'bash /config/shell/spot_art_alb_song.sh {{text1}} {{text2}} {{text3}}'
lms_spot_playlist: 'bash /config/shell/spot_playlist.sh {{text1}}'

You will know if the shell files get executed if the album_id, song_id sensors get updated and obviously if the song and album functions are queuing to LMS properly.

I tried everything I could think of, but I can't get it to work. I also have some weird groups in my HA GUI. Maybe it is related:
2640626407
Tekstinvoer=text input
Automatisering=Automation
Boolean invoer=boolean input

CypherMK
2018-12-28, 17:26
This is also different from your example:
26408
And I don't have those player controls like your example.

ynot1234567890
2018-12-29, 03:41
This is also different from your example:
26408
And I don't have those player controls like your example.

Hi, sounds like the shell scripts are not executing or executing properly. That is why you're not getting anything queued up. So to test open a shell in your HA instance and:

goto the /config/shell directory
execute the following command: `bash qry_alb.sh _supertramp _breakfast_in_america'
review the result, it should find the artist and album and post the results into the HA sensors.

Please send the result to my email yland@vianet.ca. If that worked properly, then it's an issue with the path calling the scripts or possible the scripts can't be executed. (chmod 777). The next step would be to ensure the path to the scripts is OK in the configuration.yaml file.

Also please include the result of pwd command when you are in your shell directory so I can see the exact path.

As for the GUI, those are additional entry for more players. Some users have up to 10 players they want to be able to sync. You can remove likely by commenting out the input booleans in the configuration.yaml file.

CypherMK
2018-12-29, 03:49
Ok, I will send you an email.
Another thing I see you mention. I don't see any HA sensors anywhere posting my results.

ynot1234567890
2018-12-29, 03:51
Ok, I will send you an email.
Another thing I see you mention. I don't see any HA sensors anywhere posting my results.

That would be the case if the shell scripts were not running properly. It is supposed to post the query results to sensors for use inside HA. sensor.art_id and sensor.alb_id I believe.

ColH
2018-12-30, 05:31
How to I get the client ID and secret for the Spotify scripts?

ynot1234567890
2018-12-30, 06:48
How to I get the client ID and secret for the Spotify scripts?

Sign up for a Spotify developers account here: https://developer.spotify.com/dashboard/

Create an app and you will get a client id and client secret. These are used for security purposes to run queries against the spotify engine. The id and secret is then entered into the spotify shell scripts (spot*.sh).

And yes, next release I will try to reduce the places to enter the same info several times. :).

Ynot.

ColH
2018-12-30, 07:02
What is the toggle switch at the top of this pane? I assumed it was going to be power on/off on the player selected below, but it doesn't seem to do anything, or react to on/off done in any other ways (even through voice control).

grimmace92
2018-12-30, 12:55
I guess so if that's how your system is configured. I am using docker and in that install it's simply /config/shell. You may need to update the path to the shell files in configuration.yaml file to ensure they get executed. For the next revision I will try to use relative paths to avoid this issue,


shell_command:
lms_qry_alb: 'bash /config/shell/qry_alb.sh {{text1}} {{text2}}'
lms_qry_alb_song: 'bash /config/shell/qry_alb_song.sh {{text1}} {{text2}} {{text3}}'
lms_spot_art: 'bash /config/shell/spot_art_top.sh {{text1}}'
lms_spot_art_alb: 'bash /config/shell/spot_art_alb.sh {{text1}} {{text2}}'
lms_spot_art_alb_song: 'bash /config/shell/spot_art_alb_song.sh {{text1}} {{text2}} {{text3}}'
lms_spot_playlist: 'bash /config/shell/spot_playlist.sh {{text1}}'

You will know if the shell files get executed if the album_id, song_id sensors get updated and obviously if the song and album functions are queuing to LMS properly.

I'm pretty close to getting this working. I've got everything in Home Assistant and I can change songs, pause, etc. However the shell scripts aren't working I don't think. I have home assistant installed on a synology NAS using docker. The home assistant folder is accessible through the web folder which allows you to access through windows. Do I have the shell scripts installed in the correct place? They are located under /volume1/web/HomeAssistant/shell. How do I test the scripts? I tried to follow thetroubleshooting but not sure how to do it. I used putty to get the /volume1/web/HomeAssistant/shell folder and tried to run the commands but they didn't work. It came back with -sh: bash-4-4#: command not found. No idea if I'm doing this correctly. Thanks for the help and for creating this!

Also this line:

Update https://HA_Link.duckdns.org/api/states/sensor.art_ID? -H "Authorization Bearer $HA_Token" with you're HA_Link (must be accessible from the internet)

I assumed this meant to change "HA_Link" to what you created in duck dns and also to replace "Authorization Bearer $HA_Token" with the duck dns token leavin the quotes. Is that correct?

CypherMK
2018-12-30, 13:01
I'm pretty close to getting this working. I've got everything in Home Assistant and I can change songs, pause, etc. However the shell scripts aren't working I don't think. I have home assistant installed on a synology NAS using docker. The home assistant folder is accessible through the web folder which allows you to access through windows. Do I have the shell scripts installed in the correct place? They are located under /volume1/web/HomeAssistant/shell. How do I test the scripts? I tried to follow thetroubleshooting but not sure how to do it. I used putty to get the /volume1/web/HomeAssistant/shell folder and tried to run the commands but they didn't work. It came back with -sh: bash-4-4#: command not found. No idea if I'm doing this correctly. Thanks for the help and for creating this!Try: bash qry_alb.sh _supertramp _breakfast_in_america

grimmace92
2018-12-30, 14:33
Try: bash qry_alb.sh _supertramp _breakfast_in_america

Thanks. Progress but following error

Getting closer. I created a cert via lets encrpyt and then exported them and placed them in my homeassistant folder where my configuration.yaml file is. I can access home assistant via https. This query is giving me the following error. Im guessing maybe because I exported the certificates and exported them to the folder where my configuration.yaml file is?

curl (60) SSL certificate problem: unable to get local issuer certificate

**EDIT**

I'm stuck. I can access HA from https over 4g. However I can only access over my LAN by https as well and it gives me a warning that its not secure. Not sure where to go from here. When I do the troubleshooting it complains about my certificate.

ynot1234567890
2018-12-30, 19:57
What is the toggle switch at the top of this pane? I assumed it was going to be power on/off on the player selected below, but it doesn't seem to do anything, or react to on/off done in any other ways (even through voice control).

It should not be there at all. Serves no purpose at this time. To make it disappear add control: hidden in the group file see below:


my_player:
name: LMS Music Player Controls
control: hidden
entities:
- input_select.lms_player
- input_number.lms_volume
- input_number.lms_sleep_time
- input_select.lms_source
- input_text.lms_artist
- input_text.lms_album
- input_text.lms_song
- input_text.lms_playlist
- input_select.lms_command
- script.lms_cmd_pause_player
- script.lms_cmd_start_player
- script.lms_cmd_next_track
- input_boolean.lms_shuffle
- input_boolean.lms_repeat


Ynot.

ynot1234567890
2018-12-30, 20:22
I'm pretty close to getting this working.
Update https://HA_Link.duckdns.org/api/states/sensor.art_ID? -H "Authorization Bearer $HA_Token" with you're HA_Link (must be accessible from the internet)

I assumed this meant to change "HA_Link" to what you created in duck dns and also to replace "Authorization Bearer $HA_Token" with the duck dns token leavin the quotes. Is that correct?

Hi,


The HA_Link is to be replaced with your domain line name. So mine might be (but isn't) ynotmylink.duckdns.org
The HA Token needs to be generated for your application. It is a long lived access token and allows other applications (shell scripts and DialogFlow app) to access the HA instance. It's the new security model implemented as of version 0.80. You can create it from your profile page (click on your initials) in HA. When you create it you will be given the HA token code, copy it and keep it secure it's the only time you get to see it. Then for each shell script, it needs to be copied into the line HA_Token=Your_Long_Lived_Token_Here
Also note that some systems require a : between "Authorization: Bearer $HA_Token"

ynot1234567890
2018-12-30, 20:25
Thanks. Progress but following error

Getting closer. I created a cert via lets encrpyt and then exported them and placed them in my homeassistant folder where my configuration.yaml file is. I can access home assistant via https. This query is giving me the following error. Im guessing maybe because I exported the certificates and exported them to the folder where my configuration.yaml file is?

curl (60) SSL certificate problem: unable to get local issuer certificate

**EDIT**

I'm stuck. I can access HA from https over 4g. However I can only access over my LAN by https as well and it gives me a warning that its not secure. Not sure where to go from here. When I do the troubleshooting it complains about my certificate.

Ensure your router is forwarding internet port 443 to HA_IP port 8123

grimmace92
2018-12-30, 21:24
Hi,


The HA_Link is to be replaced with your domain line name. So mine might be (but isn't) ynotmylink.duckdns.org
The HA Token needs to be generated for your application. It is a long lived access token and allows other applications (shell scripts and DialogFlow app) to access the HA instance. It's the new security model implemented as of version 0.80. You can create it from your profile page (click on your initials) in HA. When you create it you will be given the HA token code, copy it and keep it secure it's the only time you get to see it. Then for each shell script, it needs to be copied into the line HA_Token=Your_Long_Lived_Token_Here
Also note that some systems require a : between "Authorization: Bearer $HA_Token"


Here is what I'm doing in putty and what I see. Something with my certificate is causing an issue. I just have no idea what else to check. Port 443 is forwarded to 8123. For this line is it supposed to stay like this or is the whole thing supposed to be replaced with the token?

For example this:

https://HA_Link.duckdns.org/api/states/sensor.art_ID? -H "Authorization: Bearer $HA_Token"

should become this?

https://mynameused.duckdns.org/api/states/sensor.art_ID? -H "Authorization: Bearer $HA_Token"

or this

https://mynameused.duckdns.org/api/states/sensor.art_ID? -H "Authorization: the_token_generated_from_duckdns"

26437

ynot1234567890
2018-12-31, 05:50
Here is what I'm doing in putty and what I see. Something with my certificate is causing an issue. I just have no idea what else to check. Port 443 is forwarded to 8123. For this line is it supposed to stay like this or is the whole thing supposed to be replaced with the token?

For example this:

https://HA_Link.duckdns.org/api/states/sensor.art_ID? -H "Authorization: Bearer $HA_Token"

should become this?

https://mynameused.duckdns.org/api/states/sensor.art_ID? -H "Authorization: Bearer $HA_Token"

or this

https://mynameused.duckdns.org/api/states/sensor.art_ID? -H "Authorization: the_token_generated_from_duckdns"



The line is supposed to be this: https://mynameused.duckdns.org/api/states/sensor.art_ID? -H "Authorization: Bearer $HA_Token"
The second line of the shell script files (ie: qry_alb.sh) should read HA_Token=Your_Long_Lived_Token_Here. Replace "Your_Long_Lived_Token_Here" with the Home Assistant generated token using the procedure I sent yesterday. You should create a dedicated long lived access token for the Dialogflow / shell scripts.

As for the output from the script, a few things:

Looks like your system does not have the command "nc" installed. You need this to make it work or you can use "socat" but that would require some minor changes in the query statements
Also the results did not get posted because the curl statement got a certificate error which could be due to several different things. Improper HA_Token which is likely if you used the duckdns certificate as your HA token. Also make sure you can access HA GUI directly from the internet using https://yourdomain.duckdns.org. The https: part is important and it won't work otherwise in dialogflow.



Re-reading your previous posts I notice that you created certificates and such for let's encrypt. Generally if your just using the duckdns addon, all that let's encrypt stuff should just happen automatically provided you accepted the terms in the config file when setting up HA's duckdns addon package. Carefully check the duckdns setup part.

Ynot

Ynot.

grimmace92
2018-12-31, 06:00
The line is supposed to be this: https://mynameused.duckdns.org/api/states/sensor.art_ID? -H "Authorization: Bearer $HA_Token"
The second line of the shell script files (ie: qry_alb.sh) should read HA_Token=Your_Long_Lived_Token_Here. Replace "Your_Long_Lived_Token_Here" with the Home Assistant generated token using the procedure I sent yesterday. You should create a dedicated long lived access token for the Dialogflow / shell scripts.

As for the output from the script, a few things:

Looks like your system does not have the command "nc" installed. You need this to make it work or you can use "socat" but that would require some minor changes in the query statements
Also the results did not get posted because the curl statement got a certificate error which could be due to several different things. Improper HA_Token which is likely if you used the duckdns certificate as your HA token. Also make sure you can access HA GUI directly from the internet using https://yourdomain.duckdns.org. The https: part is important and it won't work otherwise in dialogflow.



Re-reading your previous posts I notice that you created certificates and such for let's encrypt. Generally if your just using the duckdns addon, all that let's encrypt stuff should just happen automatically provided you accepted the terms in the config file when setting up HA's duckdns addon package. Carefully check the duckdns setup part.

Ynot

Ynot.

Iím using the using the home assistant package available on synology diskstation through docker not HASSIO. I just add duckdns to my configuration.yaml file. Do I need HASSIO for this to work?

ynot1234567890
2018-12-31, 06:42
Iím using the using the home assistant package available on synology diskstation through docker not HASSIO. I just add duckdns to my configuration.yaml file. Do I need HASSIO for this to work?

Sorry but I don't know anything about the HA package for synology diskstation. Don't have access to that for testing.

In theory it should work on HA, you just need proper setup of duckdns with let's encrypt support. HASSIO is just more convenient for most users as it provides the addons in a simpler to install form if I understand that correctly which helps reduce the amount of work to get things running smoothly.

In the end as long as you can access your HA install from the internet using the https://yourdomain.duckdns.org and don't get any complaints about the link not being secure you should be good to go.

Ynot.

.

ColH
2018-12-31, 08:35
I'm still not entirely sure about all the cert stuff either - I've got mine working, but tried so many things!
I do notice thought that your script is failing to find 'nc'. Following suggestions I saw somewhere, I made a symlink from nc to ncat.
@ynot: another suggestion for the scripts - do a 'which nc' and if it fails then use ncat instead? ;)


Here is what I'm doing in putty and what I see. Something with my certificate is causing an issue. I just have no idea what else to check. Port 443 is forwarded to 8123. For this line is it supposed to stay like this or is the whole thing supposed to be replaced with the token?

For example this:

https://HA_Link.duckdns.org/api/states/sensor.art_ID? -H "Authorization: Bearer $HA_Token"

should become this?

https://mynameused.duckdns.org/api/states/sensor.art_ID? -H "Authorization: Bearer $HA_Token"

or this

https://mynameused.duckdns.org/api/states/sensor.art_ID? -H "Authorization: the_token_generated_from_duckdns"

26437

ynot1234567890
2018-12-31, 08:54
I'm still not entirely sure about all the cert stuff either - I've got mine working, but tried so many things!
I do notice thought that your script is failing to find 'nc'. Following suggestions I saw somewhere, I made a symlink from nc to ncat.
@ynot: another suggestion for the scripts - do a 'which nc' and if it fails then use ncat instead? ;)

Thanks I will consider that. In the next release, nc will be replaced with socat in order to handle lms connections that require username and passwords.

As for the certificates and long lived access tokens, etc.., I'm afraid that's a HA thing and how they handle security. If using HASSIO, it is generally pretty straight forward to setup. It is outside of my scope, I think, to write a manual on how to install duckdns with let's encrypt.

It would be good perhaps if some users want to put together a short how to for HA or HASSIO to get the basic setup going with duckdns, creating HA tokens and setup webhook integration. This would be very helpful for those who are using different platforms such as synology, OSMC image on PI, standard HASSIO image for PI, HASSIO install on Debian (my setup).

I can then post the guidelines on the GitHub site for use by others. Ynot

grimmace92
2018-12-31, 09:30
I'm still not entirely sure about all the cert stuff either - I've got mine working, but tried so many things!
I do notice thought that your script is failing to find 'nc'. Following suggestions I saw somewhere, I made a symlink from nc to ncat.
@ynot: another suggestion for the scripts - do a 'which nc' and if it fails then use ncat instead? ;)

Ok. I did the symlink from nc to ncat and that fixed the 'nc' issue. I still can't figure out the certificate issue. I've created it successfully in synology using let's encrypt but for some reason its not using it properly.

ColH
2018-12-31, 10:35
Thanks I will consider that. In the next release, nc will be replaced with socat in order to handle lms connections that require username and passwords.


FYI: I'm running HA in a Docker container (on my QNAP NAS) - the docker image doesn't have socat either.... ;)
But, that said, my LMS doesn't use security anyway.

ynot1234567890
2018-12-31, 12:26
Ok. I did the symlink from nc to ncat and that fixed the 'nc' issue. I still can't figure out the certificate issue. I've created it successfully in synology using let's encrypt but for some reason its not using it properly.

So now when you run the shell script it executes a call against lms does it return the artist, album but fails posting the result? You can send me a copy of one your script files (say qry_alb.sh) and I will check it out to ensure the format is correct. I assume you were able to create the HA token and copied it into the shell script file as discussed previously.

Email yland@vianet.ca

grimmace92
2018-12-31, 13:06
So now when you run the shell script it executes a call against lms does it return the artist, album but fails posting the result? You can send me a copy of one your script files (say qry_alb.sh) and I will check it out to ensure the format is correct. I assume you were able to create the HA token and copied it into the shell script file as discussed previously.

Email yland@vianet.ca

It returns zero for everything and is now giving me a 405 not allowed messages. Sent you a mail. Thanks and Happy New Year!


**EDIT** I'm able to access home assistant over https now and it says the connection is secure. However the scripts are still complaining about the SSL certificates. If I activate "http" in the configuration.yaml file I'm no longer able to access home assistant.

grimmace92
2019-01-01, 21:48
The only way I'm able to access home assisstant externally via https on my synology is if I use reverse proxy. I still get the certificate errors though :-(. Any reason I'm getting the below as well. I had the player controls working at first but now I seem to have messed something up with all the things I've been trying to get the SSL to work. I no longer see these in the script_lms_controls.yaml to copy over to the scripts.yaml file.


script.lms_cmd_pause_player
script.lms_cmd_start_player
script.lms_cmd_next_track

I do see the below in my scripts.yaml file though. Is this correct?

lms_cmd_next_track:
alias: "LMS command to advance to the next track"
sequence:
- service: media_player.media_next_track
data_template:
entity_id: "media_player.{{states.input_select.lms_player.stat e}}"

lms_cmd_pause_player:
alias: "LMS command to pause a media player"
sequence:
- service: media_player.media_pause
data_template:
entity_id: "media_player.{{states.input_select.lms_player.stat e}}"

lms_cmd_start_player:
alias: "LMS command to re-start a media player"
sequence:
- service: media_player.turn_on
data_template:
entity_id: "media_player.{{states.input_select.lms_player.stat e}}"
- service: media_player.media_play
data_template:
entity_id: "media_player.{{states.input_select.lms_player.stat e}}"


26452

samoth
2019-01-02, 10:30
@ynot1234567890: Absolutely great gadget and nice work. With Dialogflow it is working perfect.:o
Could you please describe how you can use LMS Controls from Google Assistant directly or perhaps I have missed something ?

Best regards,
Samoth

kalimeroo
2019-01-03, 05:03
In order to install secured certificates on a rpi with Hassbian, I logged in as homeassistant user (sudo -u homeassistant -H -s) and then followed the instructions detailed here: https://www.splitbrain.org/blog/2017-08/10-homeassistant_duckdns_letsencrypt

In order to generate a token for Home Assitant, you have to navigate to https://your_duckdns_address:8123/profile

kalimeroo
2019-01-03, 08:16
@ynot1234567890: Absolutely great gadget and nice work. With Dialogflow it is working perfect.:o
Could you please describe how you can use LMS Controls from Google Assistant directly or perhaps I have missed something ?

Best regards,
Samoth

If it is working in Dialogflow then you have to click integration and choose Google Assistant. With your android device you start by saying "Talk to LMS control" and then issue command like "Play artist Pink Floyd in the kitchen"

ynot1234567890
2019-01-03, 15:38
If it is working in Dialogflow then you have to click integration and choose Google Assistant. With your android device you start by saying "Talk to LMS control" and then issue command like "Play artist Pink Floyd in the kitchen"

@samoth Glad to hear it's working for you. @kalimeroo Thanks for the support and answering the questions. Have been out to a camp for the last few days with no cell or internet access. Very nice for a change. Ynot.

grimmace92
2019-01-03, 22:27
Hi Ynot,

I've made some progress I think. I've fixed the certificate issue but I'm not getting the expected results. Is there anything else I can try? I haven't entered anything in my confirguration.yaml file for the http section. If I do I get an error trying to login into home assistant. Without it I can access via https using my duckdns domain.

for this query against spotify I see this at the end...

26469

and this against LMS I see this

26468

kalimeroo
2019-01-04, 00:40
@grimmace92
How did you edit the Bash files ?
If this wad done under Windows, you can run the utility dos2unix on the files.
Lightning also be a folder rights issue

@ynot
You're welcome

samoth
2019-01-04, 03:31
See necessary configuration for proper access from the internet.

First register account in DuckDNS. Then add the following configurations.

Configurator-Addon
Config
{
"username": "username",
"password": "password",
"ssl": true,
"certfile": "fullchain.pem",
"keyfile": "privkey.pem",
"allowed_networks": [
"192.168.1.0/24",
"172.30.0.0/16"
],
"banned_ips": [
"8.8.8.8"
],
"banlimit": 0,
"ignore_pattern": [
"__pycache__"
],
"dirsfirst": false,
"enforce_basepath": false,
"notify_service": "persistent_notification.create"
}

Duckdns-Addon
Config
{
"lets_encrypt": {
"accept_terms": true,
"certfile": "fullchain.pem",
"keyfile": "privkey.pem"
},
"token": "yourtokenfromduckdns",
"domains": [
"Yourdomain1.duckdns.org",
"Yourdomain2.duckdns.org",
"Yourdomain3.duckdns.org"
],
"seconds": 300
}

Section for DuckDNS in configuration.yaml

# Uncomment this if you are using SSL/TLS, running in Docker container, etc.
# api_password: 1234567890987654321
http:
server_port: 8123
base_url: https://yourdomain.duckdns.org:8123
ssl_certificate: /ssl/fullchain.pem
ssl_key: /ssl/privkey.pem
trusted_networks:
- 192.168.1.0/24
- 172.30.0.0/16
ip_ban_enabled: true
login_attempts_threshold: 5

Necessary ports to forward to your HassIO ip adress from outside:
outside 443 to inside 8123
outside 3218 to inside 3218

Now HassIO should be now reachable from ouside via https://yourdomain.duckdns.org:8123 or internally via https://hassIO:8123

After that generate you longlive Access Token in HassIO and the generate as well the webhook link and store it safely.

Best regards, Samoth

grimmace92
2019-01-04, 06:08
@grimmace92
How did you edit the Bash files ?
If this wad done under Windows, you can run the utility dos2unix on the files.
Lightning also be a folder rights issue

@ynot
You're welcome

Hi Kalimeroo,

Yes I am using windows to edit the files using notepad++ yaml language. From your reply It sounds like that is wrong especially the yaml part. All this is new to me so please bear with me. Should I just SSH into the synology with putty and edit the files there? If so can you provide the commands to do that and resave the file. Thank you for the help.

kalimeroo
2019-01-04, 07:17
You can also change notepad++ config on order to use unix type end of line character:
https://stackoverflow.com/questions/8195839/choose-newline-character-in-notepad

ynot1234567890
2019-01-04, 07:36
Hi Ynot,

I've made some progress I think. I've fixed the certificate issue but I'm not getting the expected results. Is there anything else I can try? I haven't entered anything in my confirguration.yaml file for the http section. If I do I get an error trying to login into home assistant. Without it I can access via https using my duckdns domain.

for this query against spotify I see this at the end...

and this against LMS I see this


Hi, Indeed it looks like you are getting much closer. My http section reads as follows:

http:
base_url: https://mydomain.duckdns.org
ssl_certificate: /ssl/fullchain.pem
ssl_key: /ssl/privkey.pem
trusted_networks:
- 192.168.0.0/24


Reviewing your output (which is very helpful) looks like the query for spotify is working ok, it returned your album and posted the result to your sensor (sensor.spotify_uri) but there is a syntax error in line 23 looks like a missing " or ' so sensor.lms_name did not get posted.

As for the result of the query against the lms database, looks like the query did not run and no result was found however on the positive side, the results do seem to be posted to HA sensors sensor.art_id, sensor.alb_id, sensor.lms_name so that part is working.

I reviewed your previous sh file you sent and it appears ok for the section that queries the lms server.

A couple of quick questions:


Does your lms installation require you to use a username / password (ie: secure install). If yes, you need to use the secure scripts and socat.
In your configuration.yaml file the following entry in place?

media_player:
- platform: squeezebox
host: 192.168.0.XX
Do you see your logitech media players defined in HA GUI?
Is your lms server reachable from your HA instance (ie: can you ping the lms server from a shell in the HA instance)
Is your lms CLI port 9090 (check your settings in lms for this)
Do you have the artist and album supertramp, breakfast in america in your lms database (query it in your lms interface to make sure)
If memory serves, you did a symbolic link to use netcat instead of nc, is the syntax exactly the same?? You could replace nc with netcat in the shell files for lms


You can also test the CLI interface to lms to ensure its working and returns valid results, using putty, set connection type to RAW, set your lms IP address and port to 9090. Press the open button to connect and press enter in the window. Now you can test the query directly by entering:

artists 0 20 search:_supertramp tags:a
The results should be something like:

artists 0 20 search%3A_supertramp tags%3Aa id%3A1234 artist%3ASupertramp count%3A1
Note: If using the secure version of lms, you need to login first (upon initial connection before pressing enter) by typing login username password

As for editing my files I use the built in editor in hassio (HASS Configurator) or notepadd++.

Hope this helps. Ynot.

grimmace92
2019-01-04, 08:42
Hi, Indeed it looks like you are getting much closer. My http section reads as follows:

http:
base_url: https://mydomain.duckdns.org
ssl_certificate: /ssl/fullchain.pem
ssl_key: /ssl/privkey.pem
trusted_networks:
- 192.168.0.0/24


Reviewing your output (which is very helpful) looks like the query for spotify is working ok, it returned your album and posted the result to your sensor (sensor.spotify_uri) but there is a syntax error in line 23 looks like a missing " or ' so sensor.lms_name did not get posted.

As for the result of the query against the lms database, looks like the query did not run and no result was found however on the positive side, the results do seem to be posted to HA sensors sensor.art_id, sensor.alb_id, sensor.lms_name so that part is working.

I reviewed your previous sh file you sent and it appears ok for the section that queries the lms server.

A couple of quick questions:


Does your lms installation require you to use a username / password (ie: secure install). If yes, you need to use the secure scripts and socat.
In your configuration.yaml file the following entry in place?

media_player:
- platform: squeezebox
host: 192.168.0.XX
Do you see your logitech media players defined in HA GUI?
Is your lms server reachable from your HA instance (ie: can you ping the lms server from a shell in the HA instance)
Is your lms CLI port 9090 (check your settings in lms for this)
Do you have the artist and album supertramp, breakfast in america in your lms database (query it in your lms interface to make sure)
If memory serves, you did a symbolic link to use netcat instead of nc, is the syntax exactly the same?? You could replace nc with netcat in the shell files for lms


You can also test the CLI interface to lms to ensure its working and returns valid results, using putty, set connection type to telnet, set your lms IP address and port to 9090. Press the open button to connect and press enter in the window, you should get a bunch of characters back. Now you can test the query directly by entering:

artists 0 20 search:_supertramp tags:a
The results should be something like:

artists 0 20 search%3A_supertramp tags%3Aa id%3A1234 artist%3ASupertramp count%3A1
Note: If using the secure version of lms, you need to login first (upon initial connection before pressing enter) by typing login username password

As for editing my files I use the built in editor in hassio (HASS Configurator) or notepadd++.

Hope this helps. Ynot.

Oh man. I am such a fool. I went way to far down the rabbit hole on this one. Obviously that song wasn't in my LMS database. I picked one that was and got the expected results. I will investigate the spotify query when I am home later. Also I am still having issues with the play, pause and next track buttons not showing up. I did a full install a few times and had issues with that. In post #118 I showed a pic of what I am seeing and the code I see in the files. Is that correct? THANK YOU for the help. In return I will put together a guide for synology users as it was a real pain to get the SSL certificate installed.

ynot1234567890
2019-01-04, 09:00
Oh man. I am such a fool. I went way to far down the rabbit hole on this one. Obviously that song wasn't in my LMS database. I picked one that was and got the expected results. I will investigate the spotify query when I am home later. Also I am still having issues with the play, pause and next track buttons not showing up. I did a full install a few times and had issues with that. In post #118 I showed a pic of what I am seeing and the code I see in the files. Is that correct? THANK YOU for the help. In return I will put together a guide for synology users as it was a real pain to get the SSL certificate installed.

Based on the GUI view, looks like your script entities are not being found (ie: contents of script_lms_controls.yaml is not being found in the scripts section). So, in your configuration.yaml file, look for the line:

script: !include_dir_merge_named scripts
If it's exactly as listed above, then all your scripts need to be installed in a directory named scripts, this would typically contain a file called scripts.yaml and the file script_lms_controls.yaml.

Otherwise if it reads something like: script: !include scripts.yaml then the contents of the file script_lms_controls.yaml needs to be merged with the file scripts.yaml

Either way works just fine.

After working with several users now, the next release will make use of a package file, env.sh script, etc which will help take care of some of the tedious installation parts of this little app. I would expect that release nearing the end of January.

Ynot.

grimmace92
2019-01-04, 09:27
Based on the GUI view, looks like your script entities are not being found (ie: contents of script_lms_controls.yaml is not being found in the scripts section). So, in your configuration.yaml file, look for the line:

script: !include_dir_merge_named scripts
If it's exactly as listed above, then all your scripts need to be installed in a directory named scripts, this would typically contain a file called scripts.yaml and the file script_lms_controls.yaml.

Otherwise if it reads something like: script: !include scripts.yaml then the contents of the file script_lms_controls.yaml needs to be merged with the file scripts.yaml

Either way works just fine.

After working with several users now, the next release will make use of a package file, env.sh script, etc which will help take care of some of the tedious installation parts of this little app. I would expect that release nearing the end of January.

Ynot.

Awesome. This is now fixed as well after creating the scripts directory and placing the files in there. Thanks again. One more thing I noticed I used to have a toggle button next to LMS Music Player Controls in the pic I posted in post # 118. I don't now and not sure why. Any reason you could think of?

**EDIT** I switched to lovelace and its back. So all good. I'll report back after testing later

ynot1234567890
2019-01-04, 12:44
Awesome. This is now fixed as well after creating the scripts directory and placing the files in there. Thanks again. One more thing I noticed I used to have a toggle button next to LMS Music Player Controls in the pic I posted in post # 118. I don't now and not sure why. Any reason you could think of?

**EDIT** I switched to lovelace and its back. So all good. I'll report back after testing later

The toggle on the traditional interface for LMS Music Player Controls serves no purpose. See post 105 for how to remove. (control: hidden)

Ynot.

grimmace92
2019-01-04, 19:42
The toggle on the traditional interface for LMS Music Player Controls serves no purpose. See post 105 for how to remove. (control: hidden)

Ynot.

Ok I've tested from the Home Assistant GUI and the only thing I can get to work is populating Artist name with the music source as LMS and then choosing play artist. Nothing else works. Nothing from Spotify. I've checked all of the shell scripts to see if they work from putty and they do. I still haven't put anything in the configuration.yaml file under http. I'll mess around with it now to see if it makes a difference but anytime I put anything in there it gives me an error when trying to login,

ynot1234567890
2019-01-05, 05:08
Ok I've tested from the Home Assistant GUI and the only thing I can get to work is populating Artist name with the music source as LMS and then choosing play artist. Nothing else works. Nothing from Spotify. I've checked all of the shell scripts to see if they work from putty and they do. I still haven't put anything in the configuration.yaml file under http. I'll mess around with it now to see if it makes a difference but anytime I put anything in there it gives me an error when trying to login,

Does pause, play, volume work on the player?

If the only one working is artist for music source lms (this action does not require a shell script file at this time), then the shell files are not being called properly and the likely cause of that is path to the shell scripts is incorrect or the shell script file rights are incorrect / not executable. Check the configuration.yaml section and confirm the path to the files is correct. In addition you could chmod the shell files with 777 to ensure they are executable by all.


shell_command:
lms_qry_alb: 'bash /config/shell/qry_alb.sh {{text1}} {{text2}}'
lms_qry_alb_song: 'bash /config/shell/qry_alb_song.sh {{text1}} {{text2}} {{text3}}'
lms_spot_art: 'bash /config/shell/spot_art_top.sh {{text1}}'
lms_spot_art_alb: 'bash /config/shell/spot_art_alb.sh {{text1}} {{text2}}'
lms_spot_art_alb_song: 'bash /config/shell/spot_art_alb_song.sh {{text1}} {{text2}} {{text3}}'
lms_spot_playlist: 'bash /config/shell/spot_playlist.sh {{text1}}'

Depending on how you installed Home Assistant, your path could be somethign like: /home/homeassistant/.homeassistant/shell rather than /config/shell

grimmace92
2019-01-05, 08:21
Does pause, play, volume work on the player?

If the only one working is artist for music source lms (this action does not require a shell script file at this time), then the shell files are not being called properly and the likely cause of that is path to the shell scripts is incorrect or the shell script file rights are incorrect / not executable. Check the configuration.yaml section and confirm the path to the files is correct. In addition you could chmod the shell files with 777 to ensure they are executable by all.


shell_command:
lms_qry_alb: 'bash /config/shell/qry_alb.sh {{text1}} {{text2}}'
lms_qry_alb_song: 'bash /config/shell/qry_alb_song.sh {{text1}} {{text2}} {{text3}}'
lms_spot_art: 'bash /config/shell/spot_art_top.sh {{text1}}'
lms_spot_art_alb: 'bash /config/shell/spot_art_alb.sh {{text1}} {{text2}}'
lms_spot_art_alb_song: 'bash /config/shell/spot_art_alb_song.sh {{text1}} {{text2}} {{text3}}'
lms_spot_playlist: 'bash /config/shell/spot_playlist.sh {{text1}}'

Depending on how you installed Home Assistant, your path could be somethign like: /home/homeassistant/.homeassistant/shell rather than /config/shell

Still no luck. The play, restart and advance buttons work. In my docker details I see the file folder as web/docker/homeassistant and the mount as /config
Under environment variables I see this /usr/local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin

I tried chmod 777 -R /config/shell and it says no such directory do I did it for the full path /volume1/web/docker/homeassistant/shell and it looked like it worked as it went back to the prompt

this is how i installed home assistant

sudo docker run --name home-assistant --restart=always --net=host --privileged -itd -v /volume1/web/docker/homeassistant:/config -v /usr/syno/etc/certificate:/certificate --device /dev/ttyACM0 homeassistant/home-assistant:latest

Do I need to make the user root in order for these to run? In trying to research it seems docker doesn't see user only PID? I'm not sure of any of this stuff. Seems like I'm very close though...

Seeing this in the log a lot

Log Details (ERROR)
Sat Jan 05 2019 14:08:17 GMT-0500 (Eastern Standard Time)

Failed communicating with LMS: <class 'aiohttp.client_exceptions.ServerDisconnectedError '>

ynot1234567890
2019-01-05, 14:51
Still no luck. The play, restart and advance buttons work. In my docker details I see the file folder as web/docker/homeassistant and the mount as /config
Under environment variables I see this /usr/local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin

I tried chmod 777 -R /config/shell and it says no such directory do I did it for the full path /volume1/web/docker/homeassistant/shell and it looked like it worked as it went back to the prompt

this is how i installed home assistant

sudo docker run --name home-assistant --restart=always --net=host --privileged -itd -v /volume1/web/docker/homeassistant:/config -v /usr/syno/etc/certificate:/certificate --device /dev/ttyACM0 homeassistant/home-assistant:latest

Do I need to make the user root in order for these to run? In trying to research it seems docker doesn't see user only PID? I'm not sure of any of this stuff. Seems like I'm very close though...

Seeing this in the log a lot

Log Details (ERROR)
Sat Jan 05 2019 14:08:17 GMT-0500 (Eastern Standard Time)

Failed communicating with LMS: <class 'aiohttp.client_exceptions.ServerDisconnectedError '>

Open a terminal to your HA installation, go to your shell directory which is usually (supposed to be) just under the config directory /config/shell (where you put your shell script files (ie: qry_alb.sh, etc..)) and type pwd. This will give you the full path. The full path is what should be put in you configuration.yaml file. A typicall hassio direcotry structure would look like:

\config
\config\shell
\config\scripts
etc...

To open a shell to the docker container I use the following type of command: docker exec -it homeassistant bash
This will open a terminal inside the docker container.

grimmace92
2019-01-05, 15:11
Open a terminal to your HA installation, go to your shell directory which is usually (supposed to be) just under the config directory /config/shell (where you put your shell script files (ie: qry_alb.sh, etc..)) and type pwd. This will give you the full path. The full path is what should be put in you configuration.yaml file. A typicall hassio direcotry structure would look like:

\config
\config\shell
\config\scripts
etc...

To open a shell to the docker container I use the following type of command: docker exec -it homeassistant bash
This will open a terminal inside the docker container.

When I type in the command docker exec -it home-assistant bash it goes to /usr/src/app

from there I can type cd /config where I found shell and the scripts. It looks to me like its /config/shell but I have to be logged in as root though. Does this pic help?

26492

ynot1234567890
2019-01-05, 17:39
When I type in the command docker exec -it home-assistant bash it goes to /usr/src/app

from there I can type cd /config where I found shell and the scripts. It looks to me like its /config/shell but I have to be logged in as root though. Does this pic help?

26492

You could try your full path as you stated in the previous post: /volume1/web/docker/homeassistant/shell . I presume this is where you copied your shell script files.

when you login as root (su) and you go to your /config/shell directory if you do a listing, do you see your shell script files there? Have these been chmod -R 777? Is it the same location as: /volume1/web/docker/homeassistant/shell

I'm not sure I understand how you are setup exactly.

Sorry I couldn't help more with this. Ynot.

grimmace92
2019-01-05, 22:39
You could try your full path as you stated in the previous post: /volume1/web/docker/homeassistant/shell . I presume this is where you copied your shell script files.

when you login as root (su) and you go to your /config/shell directory if you do a listing, do you see your shell script files there? Have these been chmod -R 777? Is it the same location as: /volume1/web/docker/homeassistant/shell

I'm not sure I understand how you are setup exactly.

Sorry I couldn't help more with this. Ynot.

I tried the full path and yes this is where I copied the shell scripts. Also tried chmod 777 on /config/shell and still no good :-(. When I login as root (su) and go to the /config/shell folder the script files are there. I tried to run it and it failed though. See pic. When you run the chmod command should anything happen. It just goes back to the prompt. I ran chmod 777 -R /config/shell. Might be time to start over and give it one last shot. What command do you use to install home assistant in docker? Maybe starting fresh with the proper command will yield benefits. This is what I used.

sudo docker run --name home-assistant --restart=always --net=host --privileged -itd -v /volume1/web/docker/homeassistant:/config -v /usr/syno/etc/certificate:/certificate --device /dev/ttyACM0 homeassistant/home-assistant:latest

26494

ColH
2019-01-06, 05:21
I tried the full path and yes this is where I copied the shell scripts. Also tried chmod 777 on /config/shell and still no good :-(. When I login as root (su) and go to the /config/shell folder the script files are there. I tried to run it and it failed though. See pic. When you run the chmod command should anything happen. It just goes back to the prompt. I ran chmod 777 -R /config/shell. Might be time to start over and give it one last shot. What command do you use to install home assistant in docker? Maybe starting fresh with the proper command will yield benefits. This is what I used.

sudo docker run --name home-assistant --restart=always --net=host --privileged -itd -v /volume1/web/docker/homeassistant:/config -v /usr/syno/etc/certificate:/certificate --device /dev/ttyACM0 homeassistant/home-assistant:latest

26494

You maybe need a './' in front of script name e.g. bash ./spot_art_alb.sh

ColH
2019-01-06, 05:31
I'm seeing some confusion with what the current player is.
I can say "set current player to living room" and it seems to respond positively. But if the HA UI has the player set to e.g. "study" , then all the pause/restart commands go to that player, even if I say "pause living room". Similarly with "play artist Whoever in the living room".
If I set the UI to living room, then I can control that player.
Not sure how this aspect is all tied together. Should "set current player to..." update the UI view?

ynot1234567890
2019-01-06, 07:16
I tried the full path and yes this is where I copied the shell scripts. Also tried chmod 777 on /config/shell and still no good :-(. When I login as root (su) and go to the /config/shell folder the script files are there. I tried to run it and it failed though. See pic. When you run the chmod command should anything happen. It just goes back to the prompt. I ran chmod 777 -R /config/shell. Might be time to start over and give it one last shot. What command do you use to install home assistant in docker? Maybe starting fresh with the proper command will yield benefits. This is what I used.

sudo docker run --name home-assistant --restart=always --net=host --privileged -itd -v /volume1/web/docker/homeassistant:/config -v /usr/syno/etc/certificate:/certificate --device /dev/ttyACM0 homeassistant/home-assistant:latest



My installation was done on a debian server and I installed HASSIO as per the following instructions for generic Linux servers:
https://www.home-assistant.io/hassio/installation/

To prepare I installed the following packages:
sudo apt-get install -y apparmor-utils apt-transport-https avahi-daemon ca-certificates curl dbus jq network-manager socat software-properties-common

Then install Docker-CE as per Docker.com instructions:
sudo apt-get install docker-ce

To install HASSIO I used:
sudo curl -sL https://raw.githubusercontent.com/home-assistant/hassio-build/master/install/hassio_install | bash -s

To open a shell into the docker container I use the following command:
docker exec -it homeassistant bash
This drops me directly into the config directory inside the home-assistant docker container. You can confirm by typing the pwd command which shows your current path.

Ynot

grimmace92
2019-01-06, 07:20
My installation was done on a debian server and I installed HASSIO as per the following instructions for generic Linux servers:
https://www.home-assistant.io/hassio/installation/

To prepare I installed the following packages:
sudo apt-get install -y apparmor-utils apt-transport-https avahi-daemon ca-certificates curl dbus jq network-manager socat software-properties-common

Then install Docker-CE as per Docker.com instructions:
sudo apt-get install docker-ce

To install HASSIO I used:
sudo curl -sL https://raw.githubusercontent.com/home-assistant/hassio-build/master/install/hassio_install | bash -s

To open a shell into the docker container I use the following command:
docker exec -it homeassistant bash
This drops me directly into the config directory inside the home-assistant docker container. You can confirm by typing the pwd command which shows your current path.

Ynot

I can't install HASSIO on synology only the regular home assistant...

ynot1234567890
2019-01-06, 07:35
I'm seeing some confusion with what the current player is.
I can say "set current player to living room" and it seems to respond positively. But if the HA UI has the player set to e.g. "study" , then all the pause/restart commands go to that player, even if I say "pause living room". Similarly with "play artist Whoever in the living room".
If I set the UI to living room, then I can control that player.
Not sure how this aspect is all tied together. Should "set current player to..." update the UI view?

Check your dialogflow mediaplayers entities and see that you defined livingroom player properly and that it's matches your players as defined in HA GUI. You can see my entities below. Your livingroom shoudll be similar to my mediaroom. Notice the 3 o's in rooom because sometimes Google get's it wrong:). In addition you can test in dialogflow or use google assistant to see what exactly is being sent. Beware spaces. Google give living room you may want livingroom hence the entitties section.

26498

ynot1234567890
2019-01-06, 07:45
I can't install HASSIO on synology only the regular home assistant...

Can anyone else here who has installed this on Synology help out here. Sorry but I don't have one to test on. Looks like there may be some limitiations on versions, etc.. that can be run?? Sorry can't really help here.

Ynot

grimmace92
2019-01-06, 08:02
Can anyone else here who has installed this on Synology help out here. Sorry but I don't have one to test on. Looks like there may be some limitiations on versions, etc.. that can be run?? Sorry can't really help here.

Ynot

I appreciate you taking the time. If anyone has installed on a synology which folder did you use to install it? I used the web folder which give access to other devices. Maybe that was my mistake?

ColH
2019-01-06, 09:59
Check your dialogflow mediaplayers entities and see that you defined livingroom player properly and that it's matches your players as defined in HA GUI. You can see my entities below. Your livingroom shoudll be similar to my mediaroom. Notice the 3 o's in rooom because sometimes Google get's it wrong:). In addition you can test in dialogflow or use google assistant to see what exactly is being sent. Beware spaces. Google give living room you may want livingroom hence the entitties section.

26498

Substituting living for media, I've set the DF entities as per yours. The HA player - as shown on GUI - is "living_room". Should that be space instead of '_', or no space?

BTW - I notice you show Google Home's in your example and in github source. Can these be made to play 'LMS' music..?

ColH
2019-01-06, 10:11
I appreciate you taking the time. If anyone has installed on a synology which folder did you use to install it? I used the web folder which give access to other devices. Maybe that was my mistake?

I am running HA on QNAP NAS. Also not possible to get HassIO on there it seems - which is a shame because HassIO adds some neat extra add-ins. Note though - according to what I have read - that HassIO is itself a docker image, so having HassIO in a docker would be a docker within a docker!
For my QNAP I followed this page - it also has a section for Synology. Don't know if this is the route you followed.
https://www.home-assistant.io/docs/installation/docker/

ynot1234567890
2019-01-06, 12:55
Substituting living for media, I've set the DF entities as per yours. The HA player - as shown on GUI - is "living_room". Should that be space instead of '_', or no space?

BTW - I notice you show Google Home's in your example and in github source. Can these be made to play 'LMS' music..?

The names need to match exactly no '_' in one but not the other. This name is used to find the entity name (mediaplayer.name) in HA. As for google home, mini and such, in LMS setup the chromecast plugin by Phillipe and you're good to go. Cast enabled devices can then be used in LMS. It is very similar to the UPnP bridge. Please note that sync is not perfect on UPnP and Chromecast.

Ynot.

ynot1234567890
2019-01-06, 14:23
I appreciate you taking the time. If anyone has installed on a synology which folder did you use to install it? I used the web folder which give access to other devices. Maybe that was my mistake?

Did a bit of research out of interest and I see that SynoCommunity already distributes a package for Home Assistant here:

https://synocommunity.com/package/homeassistant
Perhaps give this a try? It's version 0.82 but that's pretty close to current. Likely you can update from there as time goes by.

If this package works and you get the duckdns and certificate working properly, I would suggest you install the HA configurator add-on and use that to create your shell directory under /config (or wherever your *.yaml files are) and you can use this to create and edit .yaml and .sh files as well.

If I had one of these gadgets, I would make it work. :)
Good luck. Ynot.

grimmace92
2019-01-06, 15:16
Did a bit of research out of interest and I see that SynoCommunity already distributes a package for Home Assistant here:

https://synocommunity.com/package/homeassistant
Perhaps give this a try? It's version 0.82 but that's pretty close to current. Likely you can update from there as time goes by.

If this package works and you get the duckdns and certificate working properly, I would suggest you install the HA configurator add-on and use that to create your shell directory under /config (or wherever your *.yaml files are) and you can use this to create and edit .yaml and .sh files as well.

If I had one of these gadgets, I would make it work. :)
Good luck. Ynot.

I'll give it a shot. Before I do I see this in the LMS log.

Slim::Utils::Scanner::scanPathOrURL (54) Error: No path or URL was requested! I see someone had a similar message here https://github.com/ynot123/LMS_Controls/issues/3 but its not my issue. If I have music playing and try a command from HA gui it stops the music and empties the queue so it seems something is getting through

ynot1234567890
2019-01-06, 15:51
I'll give it a shot. Before I do I see this in the LMS log.

Slim::Utils::Scanner::scanPathOrURL (54) Error: No path or URL was requested! I see someone had a similar message here https://github.com/ynot123/LMS_Controls/issues/3 but its not my issue. If I have music playing and try a command from HA gui it stops the music and empties the queue so it seems something is getting through

Because HA is queuing an empty or invalid string because your shell files are not running when request, so sensors not updated, so empty / invalid string.

grimmace92
2019-01-06, 18:10
Because HA is queuing an empty or invalid string because your shell files are not running when request, so sensors not updated, so empty / invalid string.

I tried the install you sent me and the same behavior. There is one difference. The sensors on the main page of home assistant are updating. When actioning from the HA gui i get null but when doing it manually through putty as you describe in the trouble shooting section they update properly. As I'm using !include_dir_merge_named scripts I created a scripts folder. Inside is a scripts.yaml that is empty and the script_lms_controls.yaml file. That is correct right?

**EDIT** Some progress. If I run the spotify shell command in the troubleshooting section the sensors update. From there if I go to the HA gui and select play artist it will work and start playing. The issue is if I try to change the Artist name to something different it doesn't respect it and keeps playing whatever I entered in putty which is stuck in the sensors.

ynot1234567890
2019-01-06, 19:08
I tried the install you sent me and the same behavior. There is one difference. The sensors on the main page of home assistant are updating. When actioning from the HA gui i get null but when doing it manually through putty as you describe in the trouble shooting section they update properly. As I'm using !include_dir_merge_named scripts I created a scripts folder. Inside is a scripts.yaml that is empty and the script_lms_controls.yaml file. That is correct right?

Yes that should be correct if you have no additional scripts. Did you create the shell directory directly below /config and put your files there and are they executable? Is this a docker install? If yes, when open a shell in the Docker container and go to the shell directory. Can you list the files using 'ls -las' and review the result and when you type pwd what is the path? Is this the same path as defined in configuration.yaml for the shell files?

This really sounds like a permissions or path issue, because as described, the shell scripts are not being launched. I assume they are defined in the configuration.yaml file. If your install has created a HA user, perhaps you could elevate those rights to see if you can get it to run as that user?

One last suggestion did you try to run your shell script files through the program dos2unix in case you have an improperly formatted file.

Ynot

ynot1234567890
2019-01-06, 19:43
I tried the install you sent me and the same behavior. There is one difference. The sensors on the main page of home assistant are updating. When actioning from the HA gui i get null but when doing it manually through putty as you describe in the trouble shooting section they update properly. As I'm using !include_dir_merge_named scripts I created a scripts folder. Inside is a scripts.yaml that is empty and the script_lms_controls.yaml file. That is correct right?

**EDIT** Some progress. If I run the spotify shell command in the troubleshooting section the sensors update. From there if I go to the HA gui and select play artist it will work and start playing. The issue is if I try to change the Artist name to something different it doesn't respect it and keeps playing whatever I entered in putty which is stuck in the sensors.

Still sounds like the shell files are not being run. You should not have to run them manually. Add the following to your configuration.yaml in the logger section:

logger:
default: critical
logs:
homeassistant.components.shell_command: debug

Restart HA, set music source to lms, set artist, album and song in GUI, pick play song in the HA GUI then send me the log by email yland@vianet.ca. In there you will see what is being called and the path being used and the return status of the call.

The name of the file is: /config/home-assistant.log. Don't post it here as it will contain some sensitive details like your domain name, token, etc..

Perhaps also run a play song using source lms, and spotify, then play album using each source as well before you send it to me. Maybe we can make heads or tails out of it with that additional info.

Finally, does it work if you set music source to lms and type it artist name and then choose play artist?

If you need details on the logger function see here: https://www.home-assistant.io/components/logger/

grimmace92
2019-01-06, 20:06
Yes that should be correct if you have no additional scripts. Did you create the shell directory directly below /config and put your files there and are they executable? Is this a docker install? If yes, when open a shell in the Docker container and go to the shell directory. Can you list the files using 'ls -las' and review the result and when you type pwd what is the path? Is this the same path as defined in configuration.yaml for the shell files?

This really sounds like a permissions or path issue, because as described, the shell scripts are not being launched. I assume they are defined in the configuration.yaml file. If your install has created a HA user, perhaps you could elevate those rights to see if you can get it to run as that user?

One last suggestion did you try to run your shell script files through the program dos2unix in case you have an improperly formatted file.

Ynot

No this one isn't docker so I'm actually not 100% sure what the path should be. I've been messing around with it trying to get it to work. The .yaml files are located at /volume1/@appstore/homeassistant/var/config. I created a soft link for @appstore to appstore so I could access it. I put the shell folder there under config. I tried that path and it didn't work. The user is a system internal user and I gave read/write access. I ran the fiels through the converter. Here is a pic of what I see. The user I believe is sc-homeassistant which was created during the install

26512

ynot1234567890
2019-01-06, 20:22
No this one isn't docker so I'm actually not 100% sure what the path should be. I've been messing around with it trying to get it to work. The .yaml files are located at /volume1/@appstore/homeassistant/var/config. I created a soft link for @appstore to appstore so I could access it. I put the shell folder there under config. I tried that path and it didn't work. The user is a system internal user and I gave read/write access. I ran the fiels through the converter. Here is a pic of what I see. The user I believe is sc-homeassistant which was created during the install


Try the full path /volume1/appstore/homeassistant/var/config/shell/qry_alb.sh or you can try the relative path shell/qry_alb.sh

Also temporarily elevate the security of user sc-homeassistant to root to see if that works. The results of the log file will indicated if the shell files are found.

Just noticed, if you press the info button on the HA GUI the page will display the path to your configuration.yaml file and a list of loaded components. Ensure shell_command is one of the loaded components. On that page after running a play song command do any errors show up at the bottom like this one (typical of file not found):

26513

grimmace92
2019-01-06, 20:47
Try the full path /volume1/appstore/homeassistant/var/config/shell/qry_alb.sh or you can try the relative path shell/qry_alb.sh

Also temporarily elevate the security of user sc-homeassistant to root to see if that works. The results of the log file will indicated if the shell files are found.

Just noticed, if you press the info button on the HA GUI the page will display the path to your configuration.yaml file and a list of loaded components. Ensure shell_command is one of the loaded components. On that page after running a play song command do any errors show up at the bottom like this one (typical of file not found):

26513

Pulling my hair out lol. If I populate Artist Name and Artist Title in the gui using spotfy it works....but only the two commands play artist and play album. So I assume that confirms my path is now correct??

** EDIT** Play song works too. Yes! PLaylists however do not. You just put the plalist name in the gui and and select play playlist and it should work correct? Also if I just fill in the Artist name and select play artist that doesn't work either.

**DOUBLE EDIT. ** IT ALL WORKS. I'm not even sure what I did that made it work but THANK YOU for spending the time

ynot1234567890
2019-01-07, 06:06
Pulling my hair out lol. If I populate Artist Name and Artist Title in the gui using spotfy it works....but only the two commands play artist and play album. So I assume that confirms my path is now correct??

** EDIT** Play song works too. Yes! PLaylists however do not. You just put the plalist name in the gui and and select play playlist and it should work correct? Also if I just fill in the Artist name and select play artist that doesn't work either.

**DOUBLE EDIT. ** IT ALL WORKS. I'm not even sure what I did that made it work but THANK YOU for spending the time

Finally! ;) Glad to hear it's now working. Can you please tell me what the path to the shell files ended up being? Is it the same as shown on the HA info screen for path to config. This info may help others.

Next step is google's DialogFlow to provide voice control.

Please note the next release which will use a package file should help limit the amount of changes required to make this work setup to setup. That and better instructions will hopefully make this a smoother process. If you feel inspired, you can write up a blurb on how to for the Synology NAS.

Take care. Ynot.

grimmace92
2019-01-07, 06:35
Finally! ;) Glad to hear it's now working. Can you please tell me what the path to the shell files ended up being? Is it the same as shown on the HA info screen for path to config. This info may help others.

Next step is google's DialogFlow to provide voice control.

Please note the next release which will use a package file should help limit the amount of changes required to make this work setup to setup. That and better instructions will hopefully make this a smoother process. If you feel inspired, you can write up a blurb on how to for the Synology NAS.

Take care. Ynot.

It wound up being the whole path for me starting with /volume1/ but this is for the non docker community version you pointed me to. Iíll put something together. DialogFlow working too. Tested a few commands and itís working. Have to look into some of the additional automation now too. Iíll probably have some questions there. Thanks again.

ynot1234567890
2019-01-07, 08:27
It wound up being the whole path for me starting with /volume1/ but this is for the non docker community version you pointed me to. Iíll put something together. DialogFlow working too. Tested a few commands and itís working. Have to look into some of the additional automation now too. Iíll probably have some questions there. Thanks again.

Good stuff. The docker thing is a good approach, but the install you have is perfectly fine as well. DialogFlow is working too! Well done. Enjoy.

ColH
2019-01-07, 09:33
The names need to match exactly no '_' in one but not the other. This name is used to find the entity name (mediaplayer.name) in HA. As for google home, mini and such, in LMS setup the chromecast plugin by Phillipe and you're good to go. Cast enabled devices can then be used in LMS. It is very similar to the UPnP bridge. Please note that sync is not perfect on UPnP and Chromecast.

Ynot.

Hmmm. I've changed the player name to "livingroom" everywhere in configuration.yaml and customize.yaml
Now when I ask it to play something the player changes in the UI, and the artist/playlist etc as request. But it doesn't actually begin playing it...? In fact pause/restart no longer works either.
Did I misunderstand what I needed to change?

ynot1234567890
2019-01-07, 09:51
Hmmm. I've changed the player name to "livingroom" everywhere in configuration.yaml and customize.yaml
Now when I ask it to play something the player changes in the UI, and the artist/playlist etc as request. But it doesn't actually begin playing it...? In fact pause/restart no longer works either.
Did I misunderstand what I needed to change?

Check your HA entities and see if media_player.livingroom exists and is there a media_player.livingroom_2. Sometimes things get renamed if they existed already. You can try to clearout the media_player.* devices in the known_devices.yaml file. (Make a backup first). Reboot and see if that clears it up.

Because the UI is changing, that means your Dialogflow is correct, but the HA entity (media_player.livingroom) is not being found or resolved properly. My best guess. It's happened to me when I changed names in LMS server.

ColH
2019-01-07, 09:58
Check your HA entities and see if media_player.livingroom exists and is there a media_player.livingroom_2. Sometimes things get renamed if they existed already. You can try to clearout the media_player.* devices in the known_devices.yaml file. (Make a backup first). Reboot and see if that clears it up.

Because the UI is changing, that means your Dialogflow is correct, but the HA entity (media_player.livingroom) is not being found or resolved properly. My best guess. It's happened to me when I changed names in LMS server.

I'll give that a try. It is working for the "study".

EDIT: hmmm, don't think I have a known_devices.yaml . I don't have HASSIO etc, so I'm editing the files by hand. I do have

media_player.livingroom:
name: Living Room
playerid: 00:04:20:16:FC:93
sync_stat: false
in customize.yaml; "Living Room" being LMS' own name for that player
Everywhere else it's "livingroom"

EDIT2: It had been working mostly. Recently I'd just changed the DF entities as per post the other day.

ColH
2019-01-07, 11:37
I'll give that a try. It is working for the "study".

EDIT: hmmm, don't think I have a known_devices.yaml . I don't have HASSIO etc, so I'm editing the files by hand. I do have

media_player.livingroom:
name: Living Room
playerid: 00:04:20:16:FC:93
sync_stat: false
in customize.yaml; "Living Room" being LMS' own name for that player
Everywhere else it's "livingroom"

EDIT2: It had been working mostly. Recently I'd just changed the DF entities as per post the other day.

It seems to detect changes in the current player, yet even "pause current player" isn't working. So it's detecting the param value, but not able to correctly talk to that [param value] player?

ynot1234567890
2019-01-07, 13:59
It seems to detect changes in the current player, yet even "pause current player" isn't working. So it's detecting the param value, but not able to correctly talk to that [param value] player?

Review your media_player entities in HA. Do you have a near duplicate like: media_player.livingroom and a media_player.living_room. I think when HA creates the mediaplayer entities for lms, if there is a space in the name of lms player, the space is replaced with a _. Try making your lms mediaplayer name match the HA entity (ie: livingroom not living room).

Any mediaplayer changes in lms requires a reboot in HA to reflect the name and player availability.

You can view all your entities at: https://yourdomain.duckdns.org/dev-state.

grimmace92
2019-01-07, 22:46
Good stuff. The docker thing is a good approach, but the install you have is perfectly fine as well. DialogFlow is working too! Well done. Enjoy.


Just curious. I'd rather have HA running in docker as the version is always updated. The syno community package isn't. I made a little progress where if I run a spotify command in putty it will update the sensors and they appear in HA updated. I'm pretty sure its a path issue now. I see this in the log Error running command: `bash /volume1/web/docker/homeassistant/shell/spot_art_top.sh {{text1}}`, return code: 127

12:36 AM /usr/src/app/homeassistant/components/shell_command.py (ERROR)

I tried /config and /.config for the path as well and no luck. Any other last ditch ideas? Otherwise I will stick with the non docker package for now. Thanks!

ynot1234567890
2019-01-08, 05:12
Just curious. I'd rather have HA running in docker as the version is always updated. The syno community package isn't. I made a little progress where if I run a spotify command in putty it will update the sensors and they appear in HA updated. I'm pretty sure its a path issue now. I see this in the log Error running command: `bash /volume1/web/docker/homeassistant/shell/spot_art_top.sh {{text1}}`, return code: 127

12:36 AM /usr/src/app/homeassistant/components/shell_command.py (ERROR)

I tried /config and /.config for the path as well and no luck. Any other last ditch ideas? Otherwise I will stick with the non docker package for now. Thanks!

See exit codes: http://tldp.org/LDP/abs/html/exitcodes.html

Exit Code Number Meaning Example Comments
1 Catchall for general errors let "var1 = 1/0" Miscellaneous errors, such as "divide by zero" and other impermissible operations
2 Misuse of shell builtins (according to Bash documentation) empty_function() {} Missing keyword or command, or permission problem (and diff return code on a failed binary file comparison).
126 Command invoked cannot execute /dev/null Permission problem or command is not an executable
127 "command not found" illegal_command Possible problem with $PATH or a typo
128 Invalid argument to exit exit 3.14159 exit takes only integer args in the range 0 - 255 (see first footnote)
128+n Fatal error signal "n" kill -9 $PPID of script $? returns 137 (128 + 9)
130 Script terminated by Control-C Ctl-C Control-C is fatal error signal 2, (130 = 128 + 2, see above)
255* Exit status out of range exit -1 exit takes only integer args in the range 0 - 255
If a command is not found, the child process created to execute it returns a status of 127. If a com- mand is found but is not executable, the return status is 126. If a command fails because of an error during expansion or redirection, the exit status is greater than zero.

Basically command not found (path is incorrect or file does not exist). The intention is to make the shell sub directory just under where ever your configuration.yaml file is stored. This will ensure it can be found by the HA system. Then you can go to https://yourdomain.duckdns.org/dev-info and see the path to configuration.yaml in my example this is:
" Path to configuration.yaml: /config "

EDIT: If you're convinced your path is correct, try elevating your HA user to root to see if you can get there.
Ynot

grimmace92
2019-01-08, 07:02
See exit codes: http://tldp.org/LDP/abs/html/exitcodes.html

Exit Code Number Meaning Example Comments
1 Catchall for general errors let "var1 = 1/0" Miscellaneous errors, such as "divide by zero" and other impermissible operations
2 Misuse of shell builtins (according to Bash documentation) empty_function() {} Missing keyword or command, or permission problem (and diff return code on a failed binary file comparison).
126 Command invoked cannot execute /dev/null Permission problem or command is not an executable
127 "command not found" illegal_command Possible problem with $PATH or a typo
128 Invalid argument to exit exit 3.14159 exit takes only integer args in the range 0 - 255 (see first footnote)
128+n Fatal error signal "n" kill -9 $PPID of script $? returns 137 (128 + 9)
130 Script terminated by Control-C Ctl-C Control-C is fatal error signal 2, (130 = 128 + 2, see above)
255* Exit status out of range exit -1 exit takes only integer args in the range 0 - 255
If a command is not found, the child process created to execute it returns a status of 127. If a com- mand is found but is not executable, the return status is 126. If a command fails because of an error during expansion or redirection, the exit status is greater than zero.

Basically command not found (path is incorrect or file does not exist). The intention is to make the shell sub directory just under where ever your configuration.yaml file is stored. This will ensure it can be found by the HA system. Then you can go to https://yourdomain.duckdns.org/dev-info and see the path to configuration.yaml in my example this is:
" Path to configuration.yaml: /config "

EDIT: If you're convinced your path is correct, try elevating your HA user to root to see if you can get there.
Ynot

Very frustrating. It says its /config. How do I elevate the user to root? I'm not even sure of the user name that docker uses. Is there a way to use putty to get to the docker container path of /config? I've used the docker exec command but it brings me to usr/src/app and I can't see /config anywhere.

ynot1234567890
2019-01-08, 08:44
Very frustrating. It says its /config. How do I elevate the user to root? I'm not even sure of the user name that docker uses. Is there a way to use putty to get to the docker container path of /config? I've used the docker exec command but it brings me to usr/src/app and I can't see /config anywhere.

When you run the docker exec command, it takes you to /usr/src/app, it opens a shell within the docker container. From this shell find your config and shell directories. cd /config may get you there. Either way you have to find the files from the docker shell for this to work. Once you find the files type pwd to get the path.

grimmace92
2019-01-08, 09:35
When you run the docker exec command, it takes you to /usr/src/app, it opens a shell within the docker container. From this shell find your config and shell directories. cd /config may get you there. Either way you have to find the files from the docker shell for this to work. Once you find the files type pwd to get the path.

Ok docker exec command worked and /config/shell worked and the the shell scripts are there. When I try to execute through the HA gui the first time after restarting the container no matter what I enter for Artist name or song the sensors appear but every time its the supertramp breakfast in america in the sensors. And it seems to only update that one time if I try to enter something else. This is going to be something dumb I am doing. Just don't know what...

grimmace92
2019-01-08, 09:54
Ok docker exec command worked and /config/shell worked and the the shell scripts are there. When I try to execute through the HA gui the first time after restarting the container no matter what I enter for Artist name or song the sensors appear but every time its the supertramp breakfast in america in the sensors. And it seems to only update that one time if I try to enter something else. This is going to be something dumb I am doing. Just don't know what...


think im on right track. i see tbis when i run the command inside the shell

26523

ynot1234567890
2019-01-08, 10:02
Ok docker exec command worked and /config/shell worked and the the shell scripts are there. When I try to execute through the HA gui the first time after restarting the container no matter what I enter for Artist name or song the sensors appear but every time its the supertramp breakfast in america in the sensors. And it seems to only update that one time if I try to enter something else. This is going to be something dumb I am doing. Just don't know what...

As per post 155 try the logger, reboot, run the docker exec command, issue the tail -f do a few calls and see whats happening. Or if your docker is hassio then https://yourdomain.duckdns.org/hassio/system.

ColH
2019-01-08, 10:47
Review your media_player entities in HA. Do you have a near duplicate like: media_player.livingroom and a media_player.living_room. I think when HA creates the mediaplayer entities for lms, if there is a space in the name of lms player, the space is replaced with a _. Try making your lms mediaplayer name match the HA entity (ie: livingroom not living room).

Any mediaplayer changes in lms requires a reboot in HA to reflect the name and player availability.

You can view all your entities at: https://yourdomain.duckdns.org/dev-state.

I've gone the other way, and change the HA entity to 'living_room', and the name in DF too. I think it's now obeying....
Though it does say "living underscore room" - but I'll first give it a while and make sure I have some fully working settings, before messing further

ynot1234567890
2019-01-08, 16:08
think im on right track. i see tbis when i run the command inside the shell

26523

The attached screen shot says your authentication for spotify is invalid and that the command jq is not supported. jq is a command-line JSON processor. Got to look carefully at the output when there are issues. :p

For spotify ensure client_id and client_secret are correct. Add command jq by installing the package if its not already there. Not sure exactly how you do it on Synology.

The package could even be installed inside the docker container I suppose though that may be trickier.

EDIT: While reviewing the script I see the token is retrieved using the jq command. So that is likely why the token is invalid. Like client_id and secret are OK.

Ynot

grimmace92
2019-01-08, 16:48
The attached screen shot says your authentication for spotify is invalid and that the command jq is not supported. jq is a command-line JSON processor. Got to look carefully at the output when there are issues. :p

For spotify ensure client_id and client_secret are correct. Add command jq by installing the package if its not already there. Not sure exactly how you do it on Synology.

The package could even be installed inside the docker container I suppose though that may be trickier.

EDIT: While reviewing the script I see the token is retrieved using the jq command. So that is likely why the token is invalid. Like client_id and secret are OK.

Ynot

This has to be all docker container related. The synology community package I installed that you sent me I had none of these issues. I also had to change NC to NCAT to get the LMS shell scripts to work. The container wasnít honoring the symlink I made from NC to NCAT. I double checked and itís there. I will see if I can install JQ. Docker seems like a real pain on synology. Almost there it seems though...

grimmace92
2019-01-08, 20:39
The attached screen shot says your authentication for spotify is invalid and that the command jq is not supported. jq is a command-line JSON processor. Got to look carefully at the output when there are issues. :p

For spotify ensure client_id and client_secret are correct. Add command jq by installing the package if its not already there. Not sure exactly how you do it on Synology.

The package could even be installed inside the docker container I suppose though that may be trickier.

EDIT: While reviewing the script I see the token is retrieved using the jq command. So that is likely why the token is invalid. Like client_id and secret are OK.

Ynot

Installed jq doing this and I'm in business using docker. What a royal pain this was but I certianly learned a lot and thats a good thing. Thanks again for all the help. Hope this helps anyone else that has a synology diskstation.

# Install xml-to-json
WORKDIR /bin
RUN wget "http://stedolan.github.io/jq/download/linux64/jq" && chmod 755 jq

For the lovelace ui. When I switch to lovelace LMS controls is still in the standard gui. Is there anything special I need to do to get it to work? The ui-lovelace.yaml file is there. I just copied and saved it to the /config directory.

ynot1234567890
2019-01-09, 18:23
Installed jq doing this and I'm in business using docker. What a royal pain this was but I certianly learned a lot and thats a good thing. Thanks again for all the help. Hope this helps anyone else that has a synology diskstation.

# Install xml-to-json
WORKDIR /bin
RUN wget "http://stedolan.github.io/jq/download/linux64/jq" && chmod 755 jq

For the lovelace ui. When I switch to lovelace LMS controls is still in the standard gui. Is there anything special I need to do to get it to work? The ui-lovelace.yaml file is there. I just copied and saved it to the /config directory.

That should do it. I assume you went here: https://yourdomain.duckdns.org/dev-info and clicked on the "Try Out the New Lovelave UI" and ">> Set lovelace as default page on this device <<"

In your browser hit refresh.

If in Lovelace GUI, you can also click on the right hand side, click 3 vertical dots and choose raw config editor and add contents of lovelace.yaml in there. It's the new GUI interface method (0.84.6). You can read more about lovelace and how to here: https://www.home-assistant.io/lovelace/


Ynot.

chemirocha
2019-01-16, 12:01
Just to say thank you for creating this project! I've got it working (sort of) and even added an "unpause" command. Being a complete noob to home automation I found the Home Assistant side of things to be a huge learning curve but I think I now understand it a bit at least. The Dialogflow is a fantastic tool that I'm looking forward to using more. The only issue I haven't yet solved is that I need to be in Google Home on my phone - the normal Google Assistant doesn't recognize "Talk to my squeezeserver" while Google Home does. Maybe I need to deploy it from within Google Actions but it isn't clear to me how to keep it private!

One thing I'd say, working out how it all works, configuring it and extending it could take over quite a few days of your life that you're never going to get back! Is it worth it? Yes, I think it is, for me at least. I'm talking more and more to my android phone (it's either that or talking to the dog) and this is just a natural progression. So Cheers!

PS My set up is Hass.io on an RPi3 talking to LMS on another RPi and 3 SB duets scattered around the house.

ynot1234567890
2019-01-16, 19:06
Just to say thank you for creating this project! I've got it working (sort of) and even added an "unpause" command. Being a complete noob to home automation I found the Home Assistant side of things to be a huge learning curve but I think I now understand it a bit at least. The Dialogflow is a fantastic tool that I'm looking forward to using more. The only issue I haven't yet solved is that I need to be in Google Home on my phone - the normal Google Assistant doesn't recognize "Talk to my squeezeserver" while Google Home does. Maybe I need to deploy it from within Google Actions but it isn't clear to me how to keep it private!

One thing I'd say, working out how it all works, configuring it and extending it could take over quite a few days of your life that you're never going to get back! Is it worth it? Yes, I think it is, for me at least. I'm talking more and more to my android phone (it's either that or talking to the dog) and this is just a natural progression. So Cheers!

PS My set up is Hass.io on an RPi3 talking to LMS on another RPi and 3 SB duets scattered around the house.

Glad to hear it worked out for you. Was a fun project to put together. As you said many hours spent. I do agree the HomeAssistant learning curve can be steep but it is pretty powerful and can be extended to cover all kinds of automations. The next release of this tool will be a little simpler to install on the HA side and require less manual editing and hopefully better how to for the noobs.

In DialogFlow you should be able to test directly in GoogleAssistant using the See how it works in Google Assistant link. If you choose to publish which can get rid of the annoying "test" message, Alpha and Beta publishing is private. Your action would only be available to those you invite.

Enjoy. Ynot.

Wirrunna
2019-01-17, 15:18
Glad to hear it worked out for you. Was a fun project to put together. As you said many hours spent. I do agree the HomeAssistant learning curve can be steep but it is pretty powerful and can be extended to cover all kinds of automations. The next release of this tool will be a little simpler to install on the HA side and require less manual editing and hopefully better how to for the noobs.

In DialogFlow you should be able to test directly in GoogleAssistant using the See how it works in Google Assistant link. If you choose to publish which can get rid of the annoying "test" message, Alpha and Beta publishing is private. Your action would only be available to those you invite.

Enjoy. Ynot.

Ynot,
I have started "kicking the tyres" of this and after a frustrating few hours of climbing the Hass.io learning cliff I am looking forward to your next release.
So, before I perform "The following files need to be edited to add your personal access keys, secrets, links and passwords for access to Home Assistant, Spotify, LMS Server, etc.." is your next release imminent or should I continue blundering my way forward with the Hass Assistant and manual editing ?

ynot1234567890
2019-01-17, 17:16
Ynot,
I have started "kicking the tyres" of this and after a frustrating few hours of climbing the Hass.io learning cliff I am looking forward to your next release.
So, before I perform "The following files need to be edited to add your personal access keys, secrets, links and passwords for access to Home Assistant, Spotify, LMS Server, etc.." is your next release imminent or should I continue blundering my way forward with the Hass Assistant and manual editing ?

I should be out by the end of the month. It will require less editing, have a few new features and hopefully better documentation for those new to hassio / home assistant. Basically complete now but doing some testing, documentation updates, etc.. Sounds like it may be a cold weekend up here so may be more progress this weekend than originally planned. :)

Ynot

ynot1234567890
2019-01-20, 14:27
LMS Controls Project Updated - January 18, 2019

For those interested, the LMS Controls project for Voice control of your LMS server and players via Google Home / Google Assistant has been updated. A key change includes the use of a package file (an all-in-one file) that holds the bulk of the programming for the LMS Controls project.

New features / upgrades include:
- 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.

The installation and troubleshooting documents have also been updated.

Finally, based on much feedback, I created Hass.io / Home Assistant installation document for multiple platforms to help users new to Hass.io / Home Assistant. Any users who are willing to document their setup for other platforms are welcome to submit their "how to" for inclusion.

The GitHub link is: https://github.com/ynot123/LMS_Controls

Thanks and enjoy.

Ynot.

goharbourview123
2019-01-21, 10:46
First of all, many thanks for developing this project. I got it working over the new year, and have been having great fun playing around with this. It must have taken a huge amount of work and no little patience.

I tried updating to the latest version with the scripting variables stored in 'env_var.sh', and kept getting 401 authorization errors at the 'posting results' stage when running the scripts from a shell command. Player commands like pause, play and so on still worked though. And the initial query produces results fine. The variables seemed to be echoed OK when running the script, and the Home Assistant log did report the failed logins from my own WAN ip. Port 443 is forwarded on my router.

This is using an unsecured version of LMS by the way (no username/password). I even tried changing the HA long lived access token, but no joy. Reverting to previous version, and it's all back working again, even with the new token. Will try again with logging set to debug and see if I can see anything.

By the way, noticed a couple of duplicate aliases in lmscontrols.yaml:

'LMS command to add LMS artist to the queue' is repeated. Second one should be 'LMS command to add Spotify artist to the queue'
'LMS command to add LMS album to the queue' is repeated. Second one should be 'LMS command to add Spotify album to the queue'

Not sure if it affects the actual functionality in any way, but does affect the way the scripts are displayed in the Home Assistant overview.

ynot1234567890
2019-01-21, 11:02
First of all, many thanks for developing this project. I got it working over the new year, and have been having great fun playing around with this. It must have taken a huge amount of work and no little patience.

I tried updating to the latest version with the scripting variables stored in 'env_var.sh', and kept getting 401 authorization errors at the 'posting results' stage when running the scripts from a shell command. Player commands like pause, play and so on still worked though. And the initial query produces results fine. The variables seemed to be echoed OK when running the script, and the Home Assistant log did report the failed logins from my own WAN ip. Port 443 is forwarded on my router.

This is using an unsecured version of LMS by the way (no username/password). I even tried changing the HA long lived access token, but no joy. Reverting to previous version, and it's all back working again, even with the new token. Will try again with logging set to debug and see if I can see anything.

By the way, noticed a couple of duplicate aliases in lmscontrols.yaml:

'LMS command to add LMS artist to the queue' is repeated. Second one should be 'LMS command to add Spotify artist to the queue'
'LMS command to add LMS album to the queue' is repeated. Second one should be 'LMS command to add Spotify album to the queue'

Not sure if it affects the actual functionality in any way, but does affect the way the scripts are displayed in the Home Assistant overview.

Hi,

Not sure when you downloaded the code, but a user pointed out a typo in the shell scripts that while no affect in my system does cause others not to post results properly. Sounds like that's what's happening here, fix it a little earlier today. Please re-download the shell files (except env_var.sh) and try again.

Thanks for the note on the duplicate alias', not a functional problem but yes, still incorrect. Feel free to update them on your copy and I will update on the website sometime soon.

Enjoy. Ynot.

*** EDIT ***
package file alias' updated to remove duplicates

ynot1234567890
2019-01-21, 11:47
January 21, 2019 - LMS Controls Project

Minor update to the shell files and the package file was required, basic details are as follows:

Shell files:

Fixed dangling quote / double quote in all shell files except env_var.sh. - CRITICAL this prevented proper posting of shell query results on some systems
Fixed hard coded URL in qry_player_stat.sh - CRITICAL


Package file:

Fixed some duplicate alias', NON-CRITICAL


Sorry for the inconvenience. Ynot.

goharbourview123
2019-01-21, 14:02
Thanks for the really prompt response - the updated version is all working for me now

ynot1234567890
2019-01-21, 18:05
Thanks for the really prompt response - the updated version is all working for me now

Awesome glad to hear it. Thanks for the feedback. Ynot.

grimmace92
2019-01-23, 07:58
Awesome glad to hear it. Thanks for the feedback. Ynot.

Hi Ynot,

I've upgraded to the new version and everything went fairly smooth. One question I have is on playlists. LMS controls doesn't seem to recognize my Spotify playlists. When I ask it to play a playlist through Spotify it queues up music but its all random. It's not the actual playlist I asked for that is saved in Spotify. This is true when I'm using voice or typing it in directly in HA.

ynot1234567890
2019-01-23, 14:52
Hi Ynot,

I've upgraded to the new version and everything went fairly smooth. One question I have is on playlists. LMS controls doesn't seem to recognize my Spotify playlists. When I ask it to play a playlist through Spotify it queues up music but its all random. It's not the actual playlist I asked for that is saved in Spotify. This is true when I'm using voice or typing it in directly in HA.

Yes, unfortunately the Spotify docs say "Only popular public playlists are returned" using the search playlists function. So if your playlist is popular, public and a fairly unique name you migth get it, but not likely.

My basic work around is use Spotty add-on in LMS web GUI to load up your Spotify playlist then save it as an LMS playlist. This is also how I handle radio stations (add a radio station and save it as a playlist with first word "Radio".

If you think the direct query of Spotify playlists is a must have I will consider adding it in the next upgrade. It will take a bit of work as I would have to handle the query internally. Let me know what you think.

Ynot.

grimmace92
2019-01-23, 18:28
Yes, unfortunately the Spotify docs say "Only popular public playlists are returned" using the search playlists function. So if your playlist is popular, public and a fairly unique name you migth get it, but not likely.

My basic work around is use Spotty add-on in LMS web GUI to load up your Spotify playlist then save it as an LMS playlist. This is also how I handle radio stations (add a radio station and save it as a playlist with first word "Radio".

If you think the direct query of Spotify playlists is a must have I will consider adding it in the next upgrade. It will take a bit of work as I would have to handle the query internally. Let me know what you think.

Ynot.

Hmm...This sort of works for me. I got it to work with one playlist but it doesn't recognize any others. Maybe my query isn't perfect. I created Gary's Party and Rock. It recognizes the first but not the second. Tried a couple different things too and only the first one works. Query is bash qry_playlist.sh rock and it returns null. I can type in Ga only for the Gary;s Party playlist and it finds it.

ynot1234567890
2019-01-23, 18:31
Hmm...This sort of works for me. I got it to work with one playlist but it doesn't recognize any others. Maybe my query isn't perfect. I created Gary's Party and Rock. It recognizes the first but not the second. Tried a couple different things too and only the first one works. Query is bash qry_playlist.sh rock and it returns null. I can type in Ga only for the Gary;s Party playlist and it finds it.

Whenever you create a playlist in LMS you have to re-run scan media to get it into the index. At that point you should be able to query it provided your source is set to lms.

grimmace92
2019-01-23, 18:50
Whenever you create a playlist in LMS you have to re-run scan media to get it into the index. At that point you should be able to query it provided your source is set to lms.

Ah. You can tell how often I have used an LMS playlist. It certainly works. I would think most would like to have the spotify playlists available from spotty. Spotty is already limited in that you can't create a playlist using it. You have to create it in the Spotify app. Just my opinion of course. I see you have done thousands of lines of coding so I understand the time you have in this thing. By no means a deal breaker.

goharbourview123
2019-01-24, 10:13
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:


https://www.home-assistant.io/blog/2019/01/23/release-86/#noteworthy-breaking-changes

This necessitates a very simple change to LMS Controls. Open the file lmscontrols.yaml in the /packages/ subfolder, and at line 464 edit 'time:' to 'time_pattern:'. This will ensure that the "LMS GUI Update Player Values" trigger passes the configuration check.

ynot1234567890
2019-01-24, 15:42
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:


https://www.home-assistant.io/blog/2019/01/23/release-86/#noteworthy-breaking-changes

This necessitates a very simple change to LMS Controls. Open the file lmscontrols.yaml in the /packages/ subfolder, and at line 464 edit 'time:' to 'time_pattern:'. This will ensure that the "LMS GUI Update Player Values" trigger passes the configuration check.

Thanks you beat me to it. Ynot.

*** EDIT ***
GitHub Source has now been updated for this required change. time -> time_pattern; Jan 24, 2019

grimmace92
2019-01-26, 10:21
Whenever you create a playlist in LMS you have to re-run scan media to get it into the index. At that point you should be able to query it provided your source is set to lms.

I have a weblink in HA that goes to the LMS materrial skin. I also have an ipad mounted to the wall. Is there a way to have google assistant open the weblink if I ask it to play music in the kitchen or do I have to run a script or automation? I only want it to happen on this ipad on the wall.

ynot1234567890
2019-01-26, 14:25
I have a weblink in HA that goes to the LMS materrial skin. I also have an ipad mounted to the wall. Is there a way to have google assistant open the weblink if I ask it to play music in the kitchen or do I have to run a script or automation? I only want it to happen on this ipad on the wall.

Not aware of a direct way to do what you're asking. You could perhaps create a script (shell using a daemon or something like that) that runs on the tablet in question and checks to see if the kitchen player is playing in LMS (a curl statement could pull that) and if so launch the web skin once or as often as you like. A similar approach could work with windows as well.

Good luck. Ynot

Freddy
2019-02-08, 15:08
Hmm...This sort of works for me. I got it to work with one playlist but it doesn't recognize any others. Maybe my query isn't perfect. I created Gary's Party and Rock. It recognizes the first but not the second. Tried a couple different things too and only the first one works. Query is bash qry_playlist.sh rock and it returns null. I can type in Ga only for the Gary;s Party playlist and it finds it.

It would be cool to adress your own playlists in Spotify
Would an option be to a have like a list in HASS with playlistname:spotifyURI? And then the direct URI is used?

ynot1234567890
2019-02-08, 15:17
It would be cool to adress your own playlists in Spotify
Would an option be to a have like a list in HASS with playlistname:spotifyURI? And then the direct URI is used?

You could certainly add it as a pull down on HA GUI, but perhaps easier is to manually add your playlist to LMS queue using the LMS GUI then save that list as an LMS playlist. That's how I handle it and radio stations for now.

Freddy
2019-02-09, 14:39
Anyone got this to work with other language than English?

I have my Google Mini set up with Swedish (and English) but I have problem to open the LMS Control app and send commands, both in Swedish and English
In the simulator English works fine.

Problem is that I cannot add Swedish in DialogFlow and publish the a Google Assistant, it give me an error.

https://github.com/ynot123/LMS_Controls/issues/15

grimmace92
2019-02-19, 09:56
Thanks you beat me to it. Ynot.

*** EDIT ***
GitHub Source has now been updated for this required change. time -> time_pattern; Jan 24, 2019

I just updated to HA 0.87.1 and I'm getting this error

Tue Feb 19 2019 11:54:00 GMT-0500 (Eastern Standard Time)
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']

I downloaded the new lmscontrols.yaml file for the time pattern change. Is there something else I was supposed to do?

ynot1234567890
2019-02-19, 13:20
I just updated to HA 0.87.1 and I'm getting this error

Tue Feb 19 2019 11:54:00 GMT-0500 (Eastern Standard Time)
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']

I downloaded the new lmscontrols.yaml file for the time pattern change. Is there something else I was supposed to do?

If using that new file, then you would have to make the changes you made in the old lmscontrols.yaml file, or easier still open your existing lmscontrols.yaml file and change the line in the automation section:

- platform: time
to

- platform: time_pattern

The above change will ensure the shell script player_stat.sh will run every minute.

However your error indicates the player_stat.sh script is not returning a proper value for volume. This is usually caused by the player's mac address being incorrect or not formatted properly so the query returns an invalid value. Please ensure your player's mac address is all lower case. Worst case, run the player_stat.sh script in the shell using the mac address a review the returned values for errors.

Hope that helps. Ynot

grimmace92
2019-02-19, 19:01
If using that new file, then you would have to make the changes you made in the old lmscontrols.yaml file, or easier still open your existing lmscontrols.yaml file and change the line in the automation section:

- platform: time
to

- platform: time_pattern

The above change will ensure the shell script player_stat.sh will run every minute.

However your error indicates the player_stat.sh script is not returning a proper value for volume. This is usually caused by the player's mac address being incorrect or not formatted properly so the query returns an invalid value. Please ensure your player's mac address is all lower case. Worst case, run the player_stat.sh script in the shell using the mac address a review the returned values for errors.

Hope that helps. Ynot

Thanks. Back in business

CommanderROR
2019-02-23, 05:08
This is probably completely wrong...but would this system allow me to use my Home to stream to Squeezelite Players? Basically like I currently do with my Chromecast Audios

ynot1234567890
2019-02-24, 11:59
This is probably completely wrong...but would this system allow me to use my Home to stream to Squeezelite Players? Basically like I currently do with my Chromecast Audios

The tool is designed to provide voice control of and a Home Assistant GUI for LMS server. Using the LMS server, you can stream (with the chromecast and UPNP addons) to any Chromecast, Squeezeplayer or UPNP device. To date the following streams are supported: LMS local music database, Spotify and any radio stations or other streamed sources if defined as LMS playlists.

So strictly speaking while you could not say "Hey Google play Supertramp in the kitchen" you could say "Hey Google ask LMS controls to play Supertramp in the kitchen". Where the kitchen is a chromecast, squeezeplayer or UPNP device. The command will then stream Supertramp either from Spotify or LMS database. See the following link for further details: https://github.com/ynot123/LMS_Controls

Hope that answers your question.