How to Make Google Home Speak When You Toggle a Switch in Home Assistant

by

Want your Google Home to announce something when you flip a switch? Here’s a simple automation that does exactly that.

What This Automation Does

This automation listens to your smart switch. Whenever you toggle it (turn it on or off), it triggers your Google Home speaker to say a message out loud. Simple as that! You can use it for confirmations, announcements, or just to add some voice feedback to your smart home.

The Code

yaml code

alias: New automation
description: ""
triggers:
  - trigger: state
    entity_id:
      - switch.conbre_4_switches_module_switch_4
conditions: []
actions:
  - action: tts.speak
    metadata: {}
    data:
      cache: true
      media_player_entity_id: media_player.living_room_speaker
      message: Hi
    target:
      entity_id: tts.google_translate_en_com
mode: single

How to Use It

  1. Copy the code above
  2. Go to Settings → Automations in Home Assistant
  3. Create a new automation and paste the code
  4. Change switch.conbre_4_switches_module_switch_4 to your switch entity ID
  5. Change media_player.living_room_speaker to your Google Home entity ID
  6. Change the message to whatever you want it to say
  7. Save and test!

That’s it! Now your home will talk to you.