How to set up speaker announcements, when certain events happen

Hi there.

I am still very much a beginner but have managed to set up HA, so that it now turns a Ikea bulb (connected via Zigbee2MQTT) on when the sun goes down.

I also have another Ikea bulb that automatically comes on at 6pm.

I am running HA on a Raspberry Pi3, with a USB speaker plugged into it.

My next project is to try and have HA announce when the bulbs are turned on - for example, it will say “Bedroom Light On”, when said bulb turns on.

Via these pages:

I have updated my yaml configuration, so it shows the following:


# Configure a default setup of Home Assistant (frontend, api, etc)
default_config:

media_player:
  - platform: mpd
    host: 192.168.1.4

tts:
  - platform: google_translate
    service_name: google_say

notify:
  - platform: tts
    name: in_the_living_room
    tts_service: tts.google_say
    media_player: media_player.living_room

What I have, now, is a grey box on my Overview that I can type a phrase in and it will play that phrase back over the speaker.

I am sort of getting there but what do I do now to get HA to announce when each of the bulbs turns on?

I need two messages:

  1. Bedroom light on

  2. Kitchen light on

Hi there, you will have to create automation for that. The config of your automation should look like below.

alias: Announcing Light
description: ''
mode: single
trigger:
  - platform: state
    entity_id: light.kitchen_light
    id: kitchen
    to: 'on'
    from: 'off'
  - platform: state
    entity_id: light.bedroom_light
    id: bedroom_light
    to: 'on'
    from: 'off'
condition: []
action:
  - choose:
      - conditions:
          - condition: trigger
            id: kitchen
        sequence:
          - service: tts.google_say
            data:
              entity_id: media_player.living_room
              message: Kitchen Light On
      - conditions:
          - condition: trigger
            id: bedroom_light
        sequence:
          - service: tts.google_say
            data:
              entity_id: media_player.living_room
              message: Bedroom Light On
    default: []

The above config uses choose type action in accordance with trigger_id while there can be other ways to implement this. You should change the entity ids and service names to yours for this to work with your system. If you have any doubts regarding how to implement this, just check the gif below.

1 Like