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:
- 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.
- 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.
- 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. - 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.
- 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.
- 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.