Google routines based on room

I have a few Google nest speakers and set it up to toggle a home assistant switch when I call the “good night” routine to Google assistant. Based on that toggle a script runs that will turn off lights, heater and speaks (on the speaker in the living room) if I need to put the bin outside… But i would like to get another action depending on the room i am…
Is there a way to let home assistant know which speaker changed the toggle? Or is there another way around to take action depending on the used speaker?

This comes from somebody else (I’d cite them, but honestly I can’t find the reference).

I adapted it for myself and do the logic in NodeRed and it works quite well. Since all the data in my NR is coming from HA - it should work for you too (I just have no idea how to script in HA)

  1. In your google routine when you say goodnight, add a bonus action at the end which is “Play and control media” and pick some sound that you would never use (I use “Relaxing Sounds”).
  2. In HA, listen for events from all your Googles and check for “Relaxing Sounds”) - and make note of the one that is playing it
  3. Immediately tell that Google to Stop playing (you’ll never actually hear “Relaxing Sounds”)
  4. In Step 2 you found out which Google it was … so you can use that to do whatever else you want with that specific google.

Hey there, did you end up figuring it out?

@putch, can you elaborate a little more on how exactly you are doing this, i cant really understand it. (perhaps because I dont use NR but plain yaml?)

sorry that i did not respond… but the suggestion of putch was great.

I now have configured google assistant to only play a relaxing music as automation; for nighttime i use country_night; while for morning routine i use another song/sound.
And for HomeAssistant the following automation for example:

alias: Google reponse
description: ""
trigger:
  - platform: state
    entity_id:
      - media_player.device1
      - media_player.device2
      - media_player.device3
    to: playing
condition:
  - condition: template
    value_template: "{{ trigger.to_state.attributes.app_name == \"Relaxing Sounds\" }}"
  - condition: template
    value_template: "{{ \"country_night\" in trigger.to_state.attributes.media_content_id }}"
action:
  - service: media_player.media_stop
    data: {}
    target:
      entity_id: |
        {{ trigger.entity_id }}
  - if:
      - condition: template
        value_template: "{{ trigger.entity_id == 'media_player.device1' }}"
    then:
      - service: light.turn_off
        data: {}
        target:
          area_id: bedroom
  - service: tts.google_translate_say
    data:
      entity_id: |
        {{ trigger.entity_id }}
      message: >-
        Good night.
mode: single