Google Assistant morning announcement with Home Assistant

I have been using both Home Assistant and several Google Home devices for a few years now and a while back I decided to get them to be a bit more talkative to me. If you have seen my previous washer and dryer notification projects you may have noticed I am using Home Assistant’s Google TTS (text to speech) service to tell me when either machine is done. Below I am taking this TTS service further to give me a Good Morning weather announcement when I enter my kitchen.

Prerequisites 

To get my automation that is listed below to work, you will need to adjust to suit your own entities as well as have to Google Translate TTS and Dark Sky weather services configured on Home Assistant. Info on the latter two can be found on the Home Assistant website below.

https://www.home-assistant.io/components/google_translate/
https://www.home-assistant.io/components/weather.darksky/

Example of my configuration.yaml

sensor:
  - platform: darksky
    api_key: fill_in_your_own_key_here
    scan_interval:
      hours: 3
    forecast:
      - 0
    monitored_conditions:
      - temperature    
      - summary
      - temperature_high 
      - temperature_low
      - precip_probability

tts:
  platform: google_translate
  cache: true
  cache_dir: /tts
  time_memory: 57300

The Good Morning Automation

If you are familiar with Home Assistant’s automation yaml format, the below may make a lot of sense to you. Basically to recap what I am doing here is casting a TTS message to my kitchen Home Hub when my kitchen entry motion detector gets triggered in the morning. To stop the message replaying when I go into the kitchen a second time there is a template condition to not play within a certain time.

The message pulls values from my outdoor Netatmo temp sensor, my hallway temp sensor and the Dark Sky forecast service.

If you don’t have a Netatmo you could replace the outdoor entity from ‘sensor.netatmo_outdoor_temperature’ to ‘sensor.dark_sky_temperature’.

Remember to adjust trigger and media player entities to suit your setup.

You will note I have a 22 second delay prior to turning off the media player, you may have to adjust this time slightly if the spoken sentence gets chopped off.

My Good Morning Automation (adjust to suit and add to your automations.yaml)

# Morning announcement
- id: good_morning
  alias: Play Good Morning
  trigger:
    - platform: state
      entity_id: binary_sensor.kitchen_entry_motion
      to: 'on'
  condition:
    - condition: time
      after: '06:30'
      before: '10:30'
    - condition: template
      # Only run if more than 6 hours (21,600 sec) since it last ran 
      value_template: '{{(as_timestamp(now()) - as_timestamp(state_attr("automation.play_good_morning", "last_triggered") | default(0)) | int > 21600 )}}'
  action:
    - service: tts.google_translate_say
      data_template:
        entity_id: media_player.kitchen_display
        message: "Good Morning Gary, It’s currently {{states('sensor.netatmo_outdoor_temperature') | round (0)}} degrees and {{states.sensor.dark_sky_summary.state}} today in your town. The hallway is currently {{states('sensor.hallway_temperature') | round (0)}} degrees. Today's high will be {{states.sensor.dark_sky_daytime_high_temperature_0d.state|round}} degrees with a low of {{states.sensor.dark_sky_overnight_low_temperature_0d.state|round}} degrees. You can expect a {{states('sensor.dark_sky_precip_probability_0d') | round (0)}}} % chance of rain today."
    - delay:
        seconds: 22
    - service: media_player.turn_off
      entity_id: media_player.kitchen_display