Automate Music (Google Play Music, Spotify, Youtube) with Google Home and Chromecast Audio

Since Google finally supports room based commands (Google Home linked to a room, only controlling devices in the room) i decided to ditch my Alexa setup and to completely move to Google. For this i setup 3x Google Home, 1x Google Home Mini & 3x Chromecast Audio. While Multiroom worked with Alexa the Cast Multiroom is much more reliable and much more flexible.

However, my biggest problem was that i could not find a reliable way to trigger my Music from an Automation to play on my Multiroom Group from within homeassistant while still being able to use the basic voice commands like: Next Song, Like this song, etc.

I tried several things, like LMS, the Google play music addon etc. However, all of them never worked as i wished they would. So, the next idea was to use the voice commands directly. Since Google Assistant does accept written commands on Android and they do have a Google Assistant SDK this was the next logical step. So i installed the plugins that are available only to find out, that google blocked the mediaplay capabilities from this SDK. So while you can easily send a text message to dim your lights, you cannot trigger a playlist from Spotify or Play Music.

So, then i thought to take a detour until there is an easier way. Since i anyway have an always on android tablet (using it to show my Dashboard from Hassio) which supports Google Assistant i setup an automation that basically checks for notifications with a specific topic (in my case: Command). If it detects such a notification, it will unlock the device and call the Voice Assistant and will post the command that was sent in the notification.

In order to achieve this, i use 3 tools:
1x Notification using PUSHBULLET
2x Automate by Llamalabs as the app to do the automation flow on the android device (Tasker as an alternative)
3x AutoInput Plugin for Tasker (works also with Automate)

I then tried out several commands and created a input_select list with several playlists that i like listening to for Spotify and Google Play Music. Whenever i select a playlist and press play, it will send this command to my Tablet using Pushbullet and this will then be posted to the Google Assistant.
It will look similar to this:

Play “My Favorite Songs” from “Google Play Music” on “Everywhere”

Where the Playlist and Speakertarget is selected from a dropdown list, and the music provider is selected by the Play Button. Below a screenshot of this:

Music

The Automate Flow is very basic and follows this guide:

This is a screenshot from the flow:

Now, i finally have my Google Homes and Chromecast Audios greet me with Music as soon as i step a foot through the door, and in the morning im woken by music which slowly increases in volume.

Hope this will help someone who is in the same boat as me to also replicate this and enjoy it aslong as there is not an easier, more integrated solution available.

One thing to note though, is that for my tablet the automation only works because its on Android 7.0 which is required to wake and simulate touch without root. (doubleclick which i need because of my always on “lock screen”). In the above screenshot i deleted this step as this is only required in a special scenario.

6 Likes

Exactly in the same boat.
Quite literally.
Would have saved me so much trouble and disappointment if I saw this earlier.

It was so disappointing to find out playing music wasn’t part of SDK, I even tried a workaround by trying routines which also didn’t work.

Next was to try Automate as I’m currently using it to update a few things on my HA anyway.

Will try this and get back.
Thanks a lot!

Also would really appreciate if you could send the .Flo file or share it on the Automate community?

Thanks

Is there any way I can do this without tasker?

Hey a tad late, but I found the solution here:

3 Likes