TTS anouncements: Google calendar and family message box

This is my approach for playing announcements in home speakers whenever a family member arrives home.

There is a field to leave a message to a family member.
This creates a persistant_notification that will be spoken and dismissed when a certain person arrives.

I’ve also created a google agenda for each family member in hass. Basically if there is an active event for this person, it will be announced when this person arrives. It gives the flexibility I want to implement things like garbage collection reminders and household chores.

Finally, the tts announcement code:

- id: tts_familia
  alias: Anunciar família
    platform: state
    entity_id: person.alexandre, person.najla, person.gabriela
    to: home
      minutes: 1
    condition: time
    after: 08:00:00
    before: '21:00:00'
  - service: media_player.volume_set
      entity_id: media_player.som_ambiente
      volume_level: '0.5'
  - wait_template: '{{ not(is_state(''media_player.som_ambiente'', ''playing'')) }}'
    timeout: 00:03:00
    continue_on_timeout: 'false'
  - service: tts.google_say
      entity_id: media_player.som_ambiente
      message: >
        Olá {{ trigger.to_state.attributes.friendly_name }}, são {{now().strftime('%H:%M')}}.
        {%- for entity_id in -%}
          {% set parts = entity_id.split('.') %}
          {% if ((as_timestamp(now()) - (as_timestamp(states[parts[0]][parts[1]].last_changed))))/60> 5 %} 
            {{ states[parts[0]][parts[1]].name }} {{ states[parts[0]][parts[1]].state.replace('not_home','está fora').replace('home','chegou') }} há {{ relative_time(states[parts[0]][parts[1]].last_changed).replace('day','dia').replace('hour','hora').replace('minute','minuto').replace('second','segundo')}}.
          {%- endif -%}
        {%- endfor %}
        A temperatura está em {{ states('sensor.yr_temperature') | round(0) }} graus.
        {% for notifs in states.persistent_notification -%}
          {%if trigger.to_state.attributes.friendly_name == notifs.attributes.title -%}
            {{ notifs.attributes.message }}
          {%- endif %}
        {%- endfor -%}
        {% for cal_events in states.calendar -%}
          {%if 'hass_' + trigger.to_state.attributes.friendly_name.lower() in cal_events.attributes.friendly_name-%}
            {%if cal_events.state == 'on' -%}
              {{ cal_events.attributes.message }}
            {%- endif %}
          {%- endif %}
        {%- endfor -%}

It also say the whereabouts of other family members, and the external temperature.


  • Announcements queue: currently when two family members arrive together, only one get announcements. I thought the action to wait the speaker status “not playing” would fix that, but unfortunately is not working.
  • Deal with multiple active events in calendar
  • When saying the whereabouts of the family, combine the status for people that left or arrived together.
  • Identify other useful info to include in the announcements message.

I do something similar but announce 15 mins before my google calendar events like kids lessons, school bus, dentist etc. I set the start time for day events like garbage collection so that it announces during breakfast.

Here is a time till next event sensor that you might change for your needs.

  - platform: template
        friendly_name: Time to Calendar Event
        entity_id: sensor.time
        value_template: >-
          {% if states.calendar.calendar.attributes.start_time %}
            {{((as_timestamp(states.calendar.calendar.attributes.start_time) - as_timestamp(now())) / 60 ) | default(99)  | int  }}
          {%- else -%}
          {%- endif %}

Thanks for sharing. In my case I’ve set a calendars just for home assistant announcements, so there is no need to adjust event time.
Also note that my announcements take place only when people arrive home. Still need to figure out a trigger for morning events that makes sense for me, like you did for the breakfast.

I like the idea. Thank you for sharing. I will try to reuse.

Hi, it’s cool to leave message. Can you share the code of it? Do You use input text?