Best way I've found to identify Google Home spoken to

Rather than revive this old solution to identifying the Google Home device which was spoken to so you can answer back, I thought it better to create a new one, since I have some suggested improvements, and it’s still not a simple process. Does anybody have a better/simpler solution?

The (brilliant) solution offered by @ben1492 was to create a Google Home routine that played silence for 10 seconds, and then detect this in the “song” name.

This is how I’m now doing it:

  1. I have Spotify Premium, but using that will cause Spotify to stop on any other playing device. So I also linked Deezer in the GH app, and only use it for this purpose.
  2. I couldn’t find “silence” on Deezer, and setting the volume to 0 in the GH routine will not work. However, it turns out to be unnecessary.
  3. I use Node Red with an events: state node to pick up all “media_player.” (substring) entities, and if “data.new_state.state” is “idle” and “data.new_state.attributes.app_name” is “Deezer”, then I store off the entity in “global.current_google_home” and call the “turn_off” service for the same device. This prevents it from actually playing anything from Deezer, but now I know the device you spoke to.
  4. I also use an “input_select.command”, which is exposed to Google Assistant, for all the possible commands I want to handle, like “Dad’s location” or “Trains to city”. Adding a new command means adding it to the list, adding the code, and doing “check for new devices” in the GH app.
  5. So now my “Where is Dad” GH routine first does “Play music on Deezer”, and then “Set Command to Dad’s location”. Node Red picks up the change to “input_select.command”, and sends the results to “global.current_google_home”, which was set by the Deezer music.
  6. It would also be possible to detect that the Google Home was already doing something else (eg. Spotify), but it hasn’t been an issue for me yet, so I haven’t bothered.

In terms of sensor questions, I can get most answers directly from Google Home these days with the HA cloud integration.

I’ve not found an easier solution for the “where is x?” question. I switched to Life360’s Google Assistant integration for this a couple of years ago, but that functionality went away several months ago. I no longer have the Google Music subscription, so if I were to revive my “where is x” hack I would have to do something similar to what you outline above.

Agree, though, that there should be a simpler solution to “choose” the correct speaker for response. Google Home (or Nest Hub, or Nest Mini, or even Alexa) speakers should have a state called “listening” when triggered that’s available to Home Assistant. For those with multiple devices, maybe this state is triggered after the devices have gone through their routine to determine which one you were addressing (Google gets this right about 90% of the time for me). With that, it’d be easy enough to pick the speaker without going through all the silliness we have to do now.

Hey this sounds fantastic, but, I know nothing at all about node red. I’m fairly new to Home Assistant.

Would you mind explaining how you set the nod red bit up?

I understand this may be a big ask, but you don’t get if you don’t ask :wink:

@michaelblight