Control Google Music with TTS (using Google Home)

I may not be the first to do this, but the concept amused me enough that I thought I’d post what I did.

I have Chromecast audio in every room, and I wanted home assistant to play Google Music on all my speakers. I haven’t seen a way of doing it directly with HA; but, I can tell Google Music to play whatever I want through my Google Home… So now every morning I hear HA announce: “Hey Google, play some music!” (using the TTS component)

I’m delighted with the results :slight_smile:

3 Likes

Could you share more details?

you run HA on the pi? If so you have a pseaker connected to the pi/

This is actually a very nice idea!!!

There are loads of people that have looked for a way to control Spotify but as Spotify doesn’t have an API you can’t… but this way you can :slight_smile:

So the way to do it is have a speaker with a chromecast and have HA playing a TTS saying “Hey Google play xmas music on xxx speaker” so Google home can hear it and you have a automated way to start spotify … works I guess also on an echo…

well done and :slight_smile:

So my next automation is setting the alarm by playing a TTS msg to play xxx on the bedroom speaker … super

1 Like

Alexa is also pleased with commands from my Chromecast Audio :smiley:

I’ve considered this but I can’t find a real use case beyond, “Hey look what I can do!”

Unfortunately, I’m a pretty lonely guy so there’s no point in showing off. :pensive:

What are you using it for?

2 Likes

My use case is as follows:

I have a google home in my kitchen and a couple of speakers with a chromecast throughout my house (wife wanted to be able to play music in every room :wink: )

I have various playlists in Spotify and I like to wake up with music…

So I will adapt my alarm clock script to play music from spotify instead of playing a selection of my own MP3s.

so the script will do the following when it is time to wake up:

On the kitchen speaker so GH can hear it I use TTS to say:

OK Google set volume bedroom 5%
OK Google play XXX on bedroom
after 5 mins : OK Google volume bed room up 5%
after 5 mins : OK Google volume bed room up 5%
etc etc

It works perfect! so now waking up with music that slowly is increasing in volume from spotify…

Now I could do this always with my local playlists but now also with Spotify…

Other option you could use it is TV with Netflix and Chromecast to start program x every evening/morning, order a pizza every Friday evening, Get Uber taxi

in fact everything echo or GH can do for you that HASS can’t… yet :wink:

1 Like

I also don’t understand well.

Use a front-end to run a command to a chromecast audio that tells a command to a Google Home …

I am sure there are some useful cases … but …

you can do this already? How?

Look at this example:

Not front end…

Using a script:

alias: Play Jazz Music
sequence:
  - service: tts.google_say
    data:
      entity_id: media_player.kitchen
      message: "OK Google play some Jazz on bedroom"

Call that script via automation and

Hehehe, way to run with the idea! Glad my post was of use :slight_smile: The concept came to me when I was pondering the security ramifications of having a voice assistant, “What personal info could an attacker get if they took over my speakers and recorded the results?” But I like the idea of malware that orders me pizza, I’m ok with those ramifications :smiley:

Just to clarify; are you playing the tts through the speaker connected to a Chromecast in the kitchen or through the Google Home itself?

i think this is a nice way to go around complicated yaml.
creating an alarm or setting a timer in yaml can be painfull, making an automation to send a notify to TTS is straight forward.

i played around with it and let Alexa tell me a joke on unexpected moments.

i even can imagine to make a custom component and then all that you put in the yaml:

timer:
  lightson:
    - time: 18:00:00
    - message: lights in livingroom on
  telljoke:
    - time: 19:45:00
    - message: tell me a joke
  settimer:
    - time: 20:00:00
    - message: set timer for 5 minutes
  playmusic:
    - time: 7:00:00
    - message: play some music

Unfortunately it doesn’t work when playing the TTS on GH… you would expect it does as when it is playing music it does capture commands…

I believe it has to do with the echo canceling algorithm as to capture something GH probably filters out his own noise (in this case the playing of the TTS) so it will not recognize it as it will be filtered out

So the answer is…???

I’m guessing you are playing this on the Chromecast speaker but still not sure.

Yes Im using a chromecast speaker but you can use any media player as long as GH can hear it

You can cast TuneIn and Youtube directly to Google Home without the need for TTS. Might be a little more pleasant in the morning to not hear TTS, but instead some nice music. Another option could be using Autocast/Autoinput along with the “I’m feeling lucky” option from an Android device.

I took this idea and applied in another way for my family movie night. I now have an IFTTT applet that is triggered with “tell the fam that we’re watching $ in x minutes”. This will then start my automation that will:

  1. Set the volume of all other GHs/CCs in the house
  2. TTS to all other GHs/CCs in the house “$ is about to start in x minutes in the basement, come on down”
  3. Delay x minutes
  4. Turn on my surround sound
  5. Turn off the lights
  6. Turn on the stair’s track lights
  7. Set the audio input
  8. Set the volume of the surround sound
  9. Set my TV’s backlights to blue
  10. Set the volume of my CCA
  11. TTS to basement CCA to say “okay google, play $ on the basement tv”
2 Likes