Closed ekkesa closed 6 years ago
Sounds like your fulfillment (JSON) is not being received by HA from DialogFlow, in the fullfilment section ensure:
Also try the GUI version (doesn't need voice) and test the functions to see if the HA part is working properly.
Thx! I double checked the fulfillment URL and it is definitely there. I can test the agent on DF web interface. It replies with all the correct answers, but nothing happens on LMS. From the HA interface I can use the local source (lms) to play music, but not spotify (believe you need a premium account for it to work)
I will put together a troubleshooting file in the near future to help with these issues. That being said:
Let me know how that works out and I will try to dig into deeper later tonite. More log details would be helpful.
HI, I got it sorted - Your advice of first trying the local option helped me pin point the issue. MY API in DF was set to V1 not V2, after changing it, it is working a charm!!!
Thank you so much for this - Absolutely awesome!
I'm struggling with the play radio command - It is as if its not finding the radio stations. I tried these two options from LMS: Title: Jacaranda FM 94.2 (Adult Hits) Title: 947 94.7 (Top 40 & Pop Music)
I think it has something to do with the brackets, not sure how to overcome that or set an alias for it..
Very good to hear. You are the first to my knowledge to install it. So some learning curves :).
I will note the V2 thing for DF in the install notes later tonite or tmo.
As for radio stations, not sure it's mentioned but I cheated. Essentially radio stations are pre-defined in LMS as a playlist with following the naming format: Radio_StationName all in Title Case. So some of mine include:
Radio_Cbc, Radio_Q92, Radio_Country_Classics
Seemed like the easiest way to get there from here. This way all the linking is inside LMS.
Enjoy. Ynot.
Thankz! I'm really enjoying this - Now to get speakers throughout my home ;-)
I get a funny error on the radio stations after creating the playlists, Radio_Jacaranda & Radio_Highveld
The HA logs show: [homeassistant.core] Invalid service data for input_number.set_value: expected float for dictionary value @ data['value']. Got ''
Yes noticed that today when diagnosing your issue outlined above. Its a non critical error trying to set the volume and other numerical inputs to ' ' when they are not specified in the google commands. I would need to do some pre-eval to get around it but works as-is at this point. I will put it on a list to fix. Thanks.
No problem - This is an amazing piece of work. I was in the infancy stage of starting to build something similar, but nothing on this scale. I was planning on butchering in some hardcoded commands to play a few radio stations. One can see this really took some proper thinking through - Well done!
Appreciate your quick feedback and help!
Thank you I appreciate the feedback. The Google Home intrigued me, started with IFTTT but that wasn't flexible enough for my liking. This has been in the works for about 2 months or so. I am brand new to all these tools (HA, DF, GH) so it certainly was a bit of a challenge.
Now I need to dream up some further uses. Take care and enjoy. Ynot
FYI,
The file script_lms_controls.yaml
has been updated to prevent those errors in the log that were noticed yesterday from trying to set blank values.
Ynot
Awesomeness! I'm updating it now...
Radio stations still seems not to work though even with the Playlist created in LMS
I have added the radio station 947 94.7 (Top 40 & Pop Music)
in my config and it seems to be working fine. So the steps were:
Radio_947
(not saving in presets but as a playlist)I did the same with the Jacaranda station Radio_Jacaranda
and it worked as well.
A quick way to check is look at the HA GUI, the playlist field will be updated with the name of the radio station (ie: 947 or Jacaranda). If it's correct there it should go. Using simple names for radio stations leads to a better experience.
All working now - I had permission errors on the playlist directory. Never used playlists before, and the LMS web interface didn't give any errors. It created the playlist entry in the DB, but nothing to fulfill the request once called.
Sorted out the permissions, recreated the playlists and it worked 1st time. ;-)
Have you thought of streamlining the DF that one can call this directly? e.g: Hey Google, Ask LMS Commander to play artist Nirvana in the living room with shuffle on. OR Hey Google, Ask LMS Commander to set living room volume to 60%
Good idea but not sure I can do that with the development license I'm currently using.
Seems to me, I gave this a shot but was having a hard time getting google to pass on the values properly. I will give it another shot in the near future but in the meantime, if you figure that out let me know.
I got it working, sort of.. I get the data through to HA, but the command "play song" or "play artist" is not triggered. Which mechanism did you use to trigger the commands?
*EDIT: I believe I found it in the scripts.... Will report back
*EDIT2: Got it working - going to take some serious tweaking in both the HA script & DF to fully deploy all commands, will share the tweaks once I'm done...
Nice that would streamline it some. Simpler is better. If you share the proper df method to go straight in, I'm sure I can update it sometime in the next couple of weeks when I get a bit of free time. Or you make a branch of this project make it work and I can likely merge it back into the master. Thanks, Ynot
Looking into it a bit, a simple streamline to get you in with the proper mediaplayer (without it asking) would be: "Ask LMS commander for the kitchen". In order to make this work the default intent needs to be changed to for the <player name>
rather than LMS commander for the <player name>
. I have changed my personal copy as of now to reflect this change. Will test it out for a bit. Thanks :)..
As for deeper intents you're quite right, that would take some thinking. Not sure I could handle that many differing types of requests reliably with a simple default intent and I can't see a way to directly bypass the default intent and go right into the app (maybe follow-up intents). But likely I could handle a couple of simple ones like:
I got my implementation working - Not the prettiest solution, but its working ;-) I'm sure there is a more elegant solution, but with my little knowledge/experience with this I pulled it together using "Implicit Intents".
In a nutshell - I pretty much duplicated all your intents with webhooks, and added a prefix to them. So the intent "play_radio" became "implicit_intent_play radio". I then edited that intext to have no input context and juggled with the training phrases a bit to make the sentences sound more normal if one would call them directly using "Ask ..."
Then under integration I added all the new intents as "Implicit Intents".
Then in the script I duplicated all the if statements under "### check lms_command and call appropriate script" and added the prefix there aswell. Here I cheated a little, since I don't have a spotify account I removed the second test on the if statement.
It all works like a charm. I also built an HA interface to sync my LMS speakers on demand, thinking of pulling that into DF too....
Another thought I had was to build a HA interface to add songs to a playlist then have the option to save that playlist. Thought behind it being having local artists which Google cant pronounce correctly, thus typing them makes more sense and being able to save a playlist as you built it would be a nice to have. Also perhaps an option to clear a playlist.
*EDIT: I uploaded the HA File I edited, Still need to figure out how to "Sanitize" the DF file then I'll upload it.
Nice that works, seems simple enough. Never used an implicit intent but will look it up.
To sanitize DF simply modify the webhooks to remove your HA_Link and HA_API_Password.
For more detailed LMS work like syncing, building playlists, etc I personally prefer to use the LMS interface directly as it provides more control, precision and easier to query stuff, mix and match and ensure you have the right thing.
FYI, playlists are cleared automatically when using the play command with HA/GH.
Thanks for the help. Feel free to show off what you build for this in the future and perhaps I can add some (with your permission of course) to the project.
Take care. Ynot
Will definitely share as it matures - And your welcome to use any of my stuff. You did the grunt of the footwork after all. ;-)
I say that the play command clears the current playlist, which can be handy too for automations...
The LMS interface is clunky from a mobile interface, hence thinking of making a user friendly interface HA with very basic integration. E.g when having a party guests can use it to add music to the current playlist via wall panel/tablet etc. A playlist built during a party is usually a nice one to keep for future use hence the save idea.
I will copy the DF stuff to a new agent and remove the fulfillment URL and export then upload here tomorrow, but for now its bedtime - 02:30am....
*EDIT: I added a snip of my sync controls in HA
Sounds good. And i do agree LMS interface is not very functional on a phone type device. I use Squeeze Ctrl for that. Nice interface for linking players, clean and simple.
Reviewed the implicit intent thing (my input context was preventing it) and will implement that approach as well in the next release in a few weeks from now likely (time away from screens this week I hope). Likely also include the linking of players. You're approach works fine, but I will likely tweak it a bit to limit the amount of if, then, else requirements and recycle code as much as practical (less lines is better).
I will open an issue in github describing the change, you can track that if you wish.
Thanks for input and good ideas. Cheers. Ynot.
Awesome - I will definitely track it.
Enjoy your time off...
Making good progress on the implicit linking front. Struggling a bit with the sync command. Did you do the sync using the mac addresses or were you able to find a way to do it using the entity itself inside HA. Seems like I can't reference entity.unique_id
which is essentially the mac address of the players to perform the sync properly. Any advice would be helpful. Thanks, Ynot.
Hi, Yes I used the mac addresses to sync. I added a custom attribute to the media_player.x in customize.yaml
media_player.daspoort: friendly_name: Daspoort playerid: aa:aa:c0:0a:c5:ab
I then called the attribute in a script with {{ states.media_player.daspoort.attributes.playerid }}.
Hope it helps...
I have an additional idea which could be incorporated- I have an input_select which plays a url on the selected speaker. The values of the input select is a list of radio stations which is then kicked off from a script. Here is a copy of the script:
alias: Play Radio on Speakers
sequence:
- service: media_player.volume_set
data:
entity_id: media_player.sitkamer
volume_level: '0.70'
- service: media_player.volume_set
data:
entity_id: media_player.picade
volume_level: '0.70'
- service: media_player.volume_set
data:
entity_id: media_player.daspoort
volume_level: '0.70'
- service: media_player.play_media
data_template:
entity_id: >
{% if is_state("input_select.radio_knop", "Daspoort") %} media_player.daspoort
{% elif is_state("input_select.radio_knop", "Living Room") %} media_player.sitkamer
{% elif is_state("input_select.radio_knop", "Picade") %} media_player.picade
{% elif is_state("input_select.radio_knop", "PiInTheSky") %} media_player.testspeaker
{% elif is_state("input_select.radio_knop", "Everywhere") %} media_player.kakofonie
{% endif %}
media_content_id: >
{% if is_state("input_select.radio_station", "Jacaranda") %} http://opml.radiotime.com/Tune.ashx?id=s6410&formats=aac,ogg,mp3,wmpro,wma,wmvoice&partnerId=16&serial=2d444aedc36f4d5f2d3e7d45d67d7683
{% elif is_state("input_select.radio_station", "Highveld 94.7") %} http://opml.radiotime.com/Tune.ashx?id=s6400&formats=aac,ogg,mp3,wmpro,wma,wmvoice&partnerId=16&serial=2d444aedc36f4d5f2d3e7d45d67d7683
{% elif is_state("input_select.radio_station", "Impact") %} http://opml.radiotime.com/Tune.ashx?id=s6412&formats=aac,ogg,mp3,wmpro,wma,wmvoice&partnerId=16&serial=2d444aedc36f4d5f2d3e7d45d67d7683
{% elif is_state("input_select.radio_station", "702") %} http://opml.radiotime.com/Tune.ashx?id=s25727&formats=aac,ogg,mp3,wmpro,wma,wmvoice&partnerId=16&serial=2d444aedc36f4d5f2d3e7d45d67d7683
{% elif is_state("input_select.radio_station", "RSG") %} http://opml.radiotime.com/Tune.ashx?id=s143888&formats=aac,ogg,mp3,wmpro,wma,wmvoice&partnerId=16&serial=2d444aedc36f4d5f2d3e7d45d67d7683
{% elif is_state("input_select.radio_station", "Groot FM") %} http://opml.radiotime.com/Tune.ashx?id=s8386&formats=aac,ogg,mp3,wmpro,wma,wmvoice&partnerId=16&serial=2d444aedc36f4d5f2d3e7d45d67d7683
{% elif is_state("input_select.radio_station", "Classic FM") %} http://opml.radiotime.com/Tune.ashx?id=s24967&formats=aac,ogg,mp3,wmpro,wma,wmvoice&partnerId=16&serial=2d444aedc36f4d5f2d3e7d45d67d7683
{% elif is_state("input_select.radio_station", "Radio 538") %} http://vip-icecast.538.lw.triple-it.nl:80/RADIO538_MP3
{% elif is_state("input_select.radio_station", "Veronica") %} http://8543.live.streamtheworld.com/VERONICACMP3
{% elif is_state("input_select.radio_station", "Sky Radio") %} http://8623.live.streamtheworld.com:80/SKYRADIOAAC_SC
{% elif is_state("input_select.radio_station", "SLAM! Hardstyle") %} http://vip-icecast.538.lw.triple-it.nl/WEB17_MP3
{% elif is_state("input_select.radio_station", "Sleep Radio") %} http://37.59.28.208:8722/stream
{% elif is_state("input_select.radio_station", "Ambient Sleeping Pill") %} http://perseus.shoutca.st:8447/h
{% elif is_state("input_select.radio_station", "Radio Art - Sleep") %} http://live.radioart.com/fSleep.mp3
{% elif is_state("input_select.radio_station", "Calm Radio - Sleep") %} http://streams.calmradio.com/api/39/128/stream
{% elif is_state("input_select.radio_station", "Dinamo.FM Sleep") %} http://channels.dinamo.fm/sleep-aac
{% endif %}
media_content_type: 'audio/mp4'
Thanks that's kinda what i figured. I was just trying to make the code as efficient as I can and limiting the data entry for each user.
Update:
The linking and implicit intent commands seem to work well, with some additional streamlining done in DF and the ability to add more intents which can trigger the same or different commands in the HA scripts. Each intent now has a lms_command
parameter which can be set to trigger the required actions in HA.
The all intents are both explicit and implicit. When called in implicit fashion Hey goggle ask LMS Controls to play artist Pink Floyd in the mediaroom
, once the command executes DF waits for 10 seconds or so for other commands like set volume to 40
or set shuffle on
, etc. If no input is given in the 10 second period, it exits automatically with a "goodbye".
As for the radio links and other simple LMS specific GUI tasks, I will have to think about that. Wasn't really part of the plan initially at least.
Hi, Firstly thank you for an awesome integration. Unfortunately I cant get it up and running.
I see these errors in my HA logs:
Error rendering data template: UndefinedError: 'queryResult' is undefined
Google Assistant is responding 100% but LMS is not triggered. Any suggestions?